Skip to main content

Token

When using the Token smart contract, additional top-level functionality is available to use.

To access the top-level functionality, use the get_token method when creating the contract instance:

contract = python.get_token(
"{{contract_address}}",
)

The extensions that the Token Drop contract supports are listed below.

mint

Mint tokens to the connected wallet.

amount = 100

receipt = contract.mint(amount)
Configuration

amount

The amount of tokens to mint.

Must be a float.

tx_result = contract.mint(
1.5,
)

mint_to

The same as mint, but allows you to specify the address to mint the tokens to.

address = "0x7fDae677aA6f94Edff9872C4b91D26407709c790"
amount = 100

receipt = contract.mint_to(address, amount)
Configuration

to

The wallet address to mint the tokens to.

Must be a string.

tx_result = contract.mint_to(
"{{wallet_address}}",
1.5
)

amount

The number of tokens to mint.

Must be a float.

tx_result = contract.mint_to(
"{{wallet_address}}",
1.5
)

mint_batch_to

Mint tokens to many wallets in one transaction.

from thirdweb.types.currency import TokenAmount

# Data of the tokens you want to mint
args = [
TokenAmount("0x7fDae677aA6f94Edff9872C4b91D26407709c790", 1),
TokenAmount("0x7fDae677aA6f94Edff9872C4b91D26407709c790", 2),
]

contract.mint_batch_to(args)
Configuration

args

A List of TokenAmount objects containing the following properties:

class TokenAmount:
to_address: str
amount: Price
contract.mint_batch_to(
[
TokenAmount("{{wallet_address}}", 0.2),
TokenAmount("0x...", 1.4),
]
)

get_vote_balance

Get the connected wallet's voting power in this token.

vote_balance = contract.get_vote_balance()
Configuration

Return Value

A CurrencyValue object representing the vote balance of the connected wallet.

class CurrencyValue(Currency):
value: PriceWei
display_value: Price

get_vote_balance_of

Get the voting power of the specified wallet in this token.

account = "0x..."
vote_balance = contract.get_vote_balance(account)
Configuration

account

The wallet address to check the balance of. Must be of type str.

account = "0x..."
vote_balance = contract.get_vote_balance(account)

Return Value

A CurrencyValue object representing the vote balance of the specified wallet.

class CurrencyValue(Currency):
value: PriceWei
display_value: Price

get_delegation

Get the connected wallets delegatee address for this token.

delegation_address = contract.get_delegation()
Configuration

Return Value

A str representing the delegation address of the connected wallet.

get_delegation_of

Get a specified wallets delegatee for this token.

account = "0x..."
delegation_address = contract.get_delegation_of(account)
Configuration

account

The wallet address to check the delegation of. Must be of type str.

account = "0x..."
delegation_address = contract.get_delegation_of(account)

Return Value

A str representing the delegation address of the specified wallet.

delegate_to

Delegate the connected wallet's tokens to a specified wallet.

delegatee_address = "0x..."
contract.delegate_to(delegatee_address)
Configuration

delegatee_address

Wallet address to delegate tokens to. Must be of type str.

delegatee_address = "0x..."
contract.delegate_to(delegatee_address)