Skip to main content

contracts.token

Interface for interacting with a token contract

Token Objects

class Token(ERC20)

Create a standard crypto token or cryptocurrency.

from thirdweb import ThirdwebSDK

# You can customize this to a supported network or your own RPC URL
network = "mumbai"

# Now we can create a new instance of the SDK
sdk = ThirdwebSDK(network)

# If you want to send transactions, you can instantiate the SDK with a private key instead:
# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)

contract = sdk.get_token("{{contract_address}}")

get_vote_balance

def get_vote_balance() -> CurrencyValue

Get the connected wallets voting power in this token.

Returns:

vote balance of the connected wallet

get_vote_balance_of

def get_vote_balance_of(account: str) -> CurrencyValue

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

Arguments:

  • account: wallet address to check the balance of

Returns:

vote balance of the specified wallet

get_delegation

def get_delegation() -> str

Get the connected wallets delegatee address for this token.

Returns:

delegation address of the connected wallet

get_delegation_of

def get_delegation_of(account: str) -> str

Get a specified wallets delegatee for this token.

Arguments:

  • account: wallet address to check the delegation of

Returns:

delegation address of the specified wallet

mint

def mint(amount: Price) -> TxReceipt

Mint tokens to the connected wallet.

Arguments:

  • amount: amount of tokens to mint

Returns:

transaction receipt of the mint

mint_to

def mint_to(to: str, amount: Price) -> TxReceipt

Mint tokens to a specified wallet.

contract.mint_to("{{wallet_address}}", 1)

Arguments:

  • to: wallet address to mint tokens to
  • amount: amount of tokens to mint

Returns:

transaction receipt of the mint

mint_batch_to

def mint_batch_to(args: List[TokenAmount]) -> TxReceipt

Mint tokens to a list of wallets.

from thirdweb.types.currency import TokenAmount

args = [
TokenAmount("{{wallet_address}}", 1),
TokenAmount("{{wallet_address}}", 2),
]

contract.mint_batch_to(args)

Arguments:

  • args: list of wallet addresses and amounts to mint

Returns:

transaction receipt of the mint

delegate_to

def delegate_to(delegatee_address: str) -> TxReceipt

Delegate the connected wallets tokens to a specified wallet.

Arguments:

  • delegatee_address: wallet address to delegate tokens to

Returns:

transaction receipt of the delegation