Skip to main content

Token

You can access the Token interface from the SDK as follows:

import (
"github.com/thirdweb-dev/go-sdk/v2/thirdweb"
)

privateKey := "..."
secretKey := "..."

sdk, err := thirdweb.NewThirdwebSDK("mumbai", &thirdweb.SDKOptions{
PrivateKey: privateKey,
SecretKey: secretKey
})

contract, err := sdk.GetToken("{{contract_address}}")
type Token struct {
*ERC20Standard

Helper *contractHelper
Encoder *ContractEncoder
Events *ContractEvents
}

func (*Token) DelegateTo

func (token *Token) DelegateTo(ctx context.Context, delegatreeAddress string) (*types.Transaction, error)

Delegate the connected wallets tokens to a specified wallet.

delegateeAddress: wallet address to delegate tokens to

returns: transaction receipt of the delegation

func (*Token) GetDelegation

func (token *Token) GetDelegation(ctx context.Context) (string, error)

Get the connected wallets delegatee address for this token.

returns: delegation address of the connected wallet

func (*Token) GetDelegationOf

func (token *Token) GetDelegationOf(ctx context.Context, address string) (string, error)

Get a specified wallets delegatee for this token.

returns: delegation address of the connected wallet

func (*Token) GetVoteBalance

func (token *Token) GetVoteBalance(ctx context.Context) (*CurrencyValue, error)

Get the connected wallets voting power in this token.

returns: vote balance of the connected wallet

func (*Token) GetVoteBalanceOf

func (token *Token) GetVoteBalanceOf(ctx context.Context, address string) (*CurrencyValue, error)

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

address: wallet address to check the vote balance of

returns: vote balance of the specified wallet

func (*Token) Mint

func (token *Token) Mint(ctx context.Context, amount float64) (*types.Transaction, error)

Mint tokens to the connected wallet.

amount: amount of tokens to mint

returns: transaction receipt of the mint

func (*Token) MintBatchTo

func (token *Token) MintBatchTo(ctx context.Context, args []*TokenAmount) (*types.Transaction, error)

Mint tokens to a list of wallets.

args: list of wallet addresses and amounts to mint

returns: transaction receipt of the mint

Example

args = []*thirdweb.TokenAmount{
&thirdweb.TokenAmount{
ToAddress: "{{wallet_address}}",
Amount: 1
}
&thirdweb.TokenAmount{
ToAddress: "{{wallet_address}}",
Amount: 2
}
}

tx, err := contract.MintBatchTo(context.Background(), args)

func (*Token) MintTo

func (token *Token) MintTo(ctx context.Context, to string, amount float64) (*types.Transaction, error)

Mint tokens to a specified wallet.

to: wallet address to mint tokens to

amount: amount of tokens to mint

returns: transaction receipt of the mint

Example

tx, err := contract.MintTo(context.Background(), "{{wallet_address}}", 1)

type TokenAmount

type TokenAmount struct {
ToAddress string
Amount float64
}