thirdweb

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAINNET           ChainID = 1
	RINKEBY                   = 4
	GOERLI                    = 5
	POLYGON                   = 137
	FANTOM                    = 250
	FANTOM_TESTNET            = 4002
	AVALANCHE_TESTNET         = 43113
	AVALANCHE                 = 43114
	MUMBAI                    = 80001
	OPTIMISM                  = 10
	OPTIMISM_TESTNET          = 69
	ARBITRUM                  = 42161
	ARBITRUM_TESTNET          = 421611
)
View Source
const (
	NotEnoughSupply     ClaimEligibility = "There is not enough supply to claim."
	AddressNotAllowed                    = "This address is not on the allowlist."
	InsufficientBalance                  = "There isn't enough of the required currency in the wallet to pay for the claim."
	NoActiveClaimPhase                   = "There is no active claim phase at the moment. Please check back in later."
	NoClaimConditionSet                  = "There is no claim condition set."
	ExceedsMaxClaimable                  = "The quantity of tokens to claim is above the remaining limit for this wallet."
	NoWallet                             = "No wallet connected."
	Unknown                              = "No claim conditions found."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuctionListing

type AuctionListing struct {
	Id                                string
	AssetContractAddress              string
	TokenId                           int
	Asset                             *NFTMetadata
	StartTimeInEpochSeconds           int
	EndTimeInEpochSeconds             int
	Quantity                          int
	CurrencyContractAddress           string
	ReservePrice                      string
	BuyoutPrice                       string
	BuyoutCurrencyValuePerToken       *CurrencyValue
	ReservePriceCurrencyValuePerToken *CurrencyValue
	SellerAddress                     string
}

type ChainID

type ChainID int

type ChainName

type ChainName string

type ClaimArguments

type ClaimArguments struct {
	TxValue        *big.Int
	Receiver       common.Address
	Quantity       *big.Int
	Currency       common.Address
	PricePerToken  *big.Int
	AllowlistProof abi.IDropAllowlistProof
	Data           []byte
}

type ClaimConditionInput

type ClaimConditionInput struct {
	StartTime                   *time.Time
	CurrencyAddress             string
	Price                       float64
	MaxQuantity                 int
	QuantityLimitPerTransaction int
	WaitInSeconds               int
	MerkleRootHash              string
	Snapshot                    []*SnapshotInput
}

type ClaimConditionOutput

type ClaimConditionOutput struct {
	StartTime             time.Time
	MaxClaimableSupply    *big.Int
	MaxClaimablePerWallet *big.Int
	CurrentMintSupply     *big.Int
	AvailableSupply       *big.Int
	WaitInSeconds         *big.Int
	Price                 *big.Int
	CurrencyAddress       string
	CurrencyMetadata      *CurrencyValue
	MerkleRootHash        [32]byte
}

type ClaimEligibility

type ClaimEligibility string

type ClaimInfo

type ClaimInfo struct {
	PricePerToken      *big.Int
	CurrencyAddress    common.Address
	RemainingClaimable *big.Int
}

type ClaimVerification

type ClaimVerification struct {
	Value                  *big.Int
	Proofs                 [][32]byte
	MaxClaimable           *big.Int
	Price                  *big.Int
	CurrencyAddress        string
	PriceInProof           *big.Int
	CurrencyAddressInProof string
}

type ContractDeployer

type ContractDeployer struct {
	*ProviderHandler
	// contains filtered or unexported fields
}

The contract deployer lets you deploy new contracts to the blockchain using just the thirdweb SDK. You can access the contract deployer interface as follows:

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

privateKey = "..."

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

// Now you can deploy a contract
address, err := sdk.Deployer.DeployNFTCollection(
	&thirdweb.DeployNFTCollectionMetadata{
		Name: "Go NFT",
	}
})

func (*ContractDeployer) DeployEdition

func (deployer *ContractDeployer) DeployEdition(ctx context.Context, metadata *DeployEditionMetadata) (string, error)

Deploy a new Edition contract.

metadata: the contract metadata

returns: the address of the deployed contract

Example

	address, err := sdk.Deployer.DeployEdition(
     context.Background(),
		&thirdweb.DeployEditionMetadata{
			Name: "Go Edition",
		}
	})

func (*ContractDeployer) DeployEditionDrop

func (deployer *ContractDeployer) DeployEditionDrop(ctx context.Context, metadata *DeployEditionDropMetadata) (string, error)

Deploy a new Edition Drop contract.

metadata: the contract metadata

returns: the address of the deployed contract

Example

	address, err := sdk.Deployer.DeployEditionDrop(
     context.Background(),
		&thirdweb.DeployEditionDropMetadata{
			Name: "Go Edition Drop",
		}
	})

func (*ContractDeployer) DeployMarketplace

func (deployer *ContractDeployer) DeployMarketplace(ctx context.Context, metadata *DeployMarketplaceMetadata) (string, error)

Deploy a new Marketplace contract.

metadata: the contract metadata

returns: the address of the deployed contract

Example

	address, err := sdk.Deployer.DeployMarketplace(
     context.Background()
		&thirdweb.DeployMarketplaceMetadata{
			Name: "Go Marketplace",
		}
	})

func (*ContractDeployer) DeployMultiwrap

func (deployer *ContractDeployer) DeployMultiwrap(ctx context.Context, metadata *DeployMultiwrapMetadata) (string, error)

Deploy a new Multiwrap contract.

metadata: the contract metadata

returns: the address of the deployed contract

Example

	address, err := sdk.Deployer.DeployMultiwrap(
     context.Background()
		&thirdweb.DeployMultiwrapMetadata{
			Name: "Go Multiwrap",
		}
	})

func (*ContractDeployer) DeployNFTCollection

func (deployer *ContractDeployer) DeployNFTCollection(ctx context.Context, metadata *DeployNFTCollectionMetadata) (string, error)

Deploy a new NFT Collection contract.

metadata: the contract metadata

returns: the address of the deployed contract

Example

	address, err := sdk.Deployer.DeployNFTCollection(
     context.Background(),
		&thirdweb.DeployNFTCollectionMetadata{
			Name: "Go NFT",
		}
	})

func (*ContractDeployer) DeployNFTDrop

func (deployer *ContractDeployer) DeployNFTDrop(ctx context.Context, metadata *DeployNFTDropMetadata) (string, error)

Deploy a new NFT Drop contract.

metadata: the contract metadata

returns: the address of the deployed contract

Example

	address, err := sdk.Deployer.DeployNFTDrop(
     context.Background(),
		&thirdweb.DeployNFTDropMetadata{
			Name: "Go NFT Drop",
		}
	})

func (*ContractDeployer) DeployToken

func (deployer *ContractDeployer) DeployToken(ctx context.Context, metadata *DeployTokenMetadata) (string, error)

Deploy a new Token contract.

metadata: the contract metadata

returns: the address of the deployed contract

Example

	address, err := sdk.Deployer.DeployToken(
     context.Background(),
		&thirdweb.DeployTokenMetadata{
			Name: "Go Token",
		}
	})

type ContractEncoder

type ContractEncoder struct {
	// contains filtered or unexported fields
}

This interface is currently supported by all contract encoder classes and provides a generic method to encode write function calls.

func (*ContractEncoder) Encode

func (encoder *ContractEncoder) Encode(ctx context.Context, signerAddress string, method string, args ...interface{}) (*types.Transaction, error)

Get the unsigned transaction data for any contract call on a contract.

signerAddress: the address expected to sign this transaction

method: the name of the contract function to encode transaction data for

args: the arguments to pass to the contract function.

returns: the encoded transaction data for the transaction.

Example

toAddress := "0x..."
amount := 1

// Now you can get the transaction data for the contract call.
tx, err := contract.Encoder.Encode(context.Background(), "transfer", toAddress, amount)
fmt.Println(tx.Data()) // Now you can access all transaction data, like the following fields
fmt.Println(tx.Nonce())
fmt.Println(tx.Value())

type ContractEvent

type ContractEvent struct {
	EventName   string
	Data        map[string]interface{}
	Transaction types.Log
}

type ContractEvents

type ContractEvents struct {
	// contains filtered or unexported fields
}

This interface provides a way to query past events or listen for future events on any contract. It's currently support on all pre-built and custom contracts!

Example

// First get an instance of your contract
contract, _ := sdk.GetContract("0x...");

// Now, get all Transfer events from a specific block range
contract.Events.GetEvents("Transfer", thirdweb.EventQueryOptions{
  FromBlock: 100000000,
  ToBlock:   100000001,
})

// And setup a listener to listen for future Transfer events
contract.Events.AddEventListener("Transfer", func (event thirdweb.ContractEvent) {
  fmt.Printf("%#v\n", event)
})

func (*ContractEvents) AddEventListener

func (events *ContractEvents) AddEventListener(ctx context.Context, eventName string, listener func(event ContractEvent)) EventSubscription

Add a listener to listen in the background for any future events of a specific type.

eventName: The name of the event to listen for

listener: The listener function that will be called whenever a new event is received

returns: An EventSubscription object that can be used to unsubscribe from the event or check for errors

Example

// Define a listener function to be called whenever a new Transfer event is received
listener := func (event thirdweb.ContractEvent) {
  fmt.Printf("%#v\n", event)
}

// Add a new listener for the Transfer event
subscription := contract.Events.AddEventListener(context.Background(), "Transfer", listener)

// Unsubscribe from the Transfer event at some time in the future, closing the listener
subscription.Unsubscribe()

func (*ContractEvents) GetEvents

func (events *ContractEvents) GetEvents(ctx context.Context, eventName string, options EventQueryOptions) ([]ContractEvent, error)

Query past events of a specific type on the contract.

eventName: The name of the event to query for

options: The options to use when querying for events, including block range specifications and filters

returns: a list of ContractEvent objects that match the query

Example

// First we define a filter to only get Transfer events where the "from" address is "0x..."
// Note that you can only add filters for indexed parameters on events
filters := map[string]interface{} {
  "from": common.HexToAddress("0x...")
}

// Now we can define the query options, including the block range and the filter
queryOptions := thirdweb.EventQueryOptions{
  FromBlock: 100000000, // Defaults to block 0 if you don't specify this field
  ToBlock:   100000001, // Defaults to latest block if you don't specify this field
  Filters:   filters,
}

// Now we can query for the Transfer events
events, _ := contract.Events.GetEvents("Transfer", queryOptions)

type Currency

type Currency struct {
	Name     string
	Symbol   string
	Decimals int
}

type CurrencyValue

type CurrencyValue struct {
	Name         string
	Symbol       string
	Decimals     int
	Value        *big.Int
	DisplayValue float64
}

type DeployEditionDropMetadata

type DeployEditionDropMetadata struct {
	Name                   string      `mapstructure:"name" json:"name"`
	Description            string      `mapstructure:"description" json:"description"`
	Image                  interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalLink           string      `mapstructure:"external_link,omitempty" json:"external_link"`
	SellerFeeBasisPoints   int         `mapstructure:"seller_fee_basis_points" json:"seller_fee_basis_points"`
	FeeRecipient           string      `mapstructure:"fee_recipient" json:"fee_recipient"`
	Merkle                 interface{} `mapstructure:"merkle" json:"merkle"`
	Symbol                 string      `mapstructure:"symbol" json:"symbol"`
	PrimarySaleRecipient   string      `mapstructure:"primary_sale_recipient" json:"primary_sale_recipient"`
	PlatformFeeBasisPoints int         `mapstructure:"platform_fee_basis_points" json:"platform_fee_basis_points"`
	PlatformFeeRecipient   string      `mapstructure:"platform_fee_recipient" json:"platform_fee_recipient"`
	TrustedForwarders      []string    `mapstructure:"trusted_forwarders" json:"trusted_forwarders"`
}

type DeployEditionMetadata

type DeployEditionMetadata struct {
	Name                   string      `mapstructure:"name" json:"name"`
	Description            string      `mapstructure:"description" json:"description"`
	Image                  interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalLink           string      `mapstructure:"external_link,omitempty" json:"external_link"`
	SellerFeeBasisPoints   int         `mapstructure:"seller_fee_basis_points" json:"seller_fee_basis_points"`
	FeeRecipient           string      `mapstructure:"fee_recipient" json:"fee_recipient"`
	Symbol                 string      `mapstructure:"symbol" json:"symbol"`
	PrimarySaleRecipient   string      `mapstructure:"primary_sale_recipient" json:"primary_sale_recipient"`
	PlatformFeeBasisPoints int         `mapstructure:"platform_fee_basis_points" json:"platform_fee_basis_points"`
	PlatformFeeRecipient   string      `mapstructure:"platform_fee_recipient" json:"platform_fee_recipient"`
	TrustedForwarders      []string    `mapstructure:"trusted_forwarders" json:"trusted_forwarders"`
}

type DeployMarketplaceMetadata

type DeployMarketplaceMetadata struct {
	Name                   string      `mapstructure:"name" json:"name"`
	Description            string      `mapstructure:"description" json:"description"`
	Image                  interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalLink           string      `mapstructure:"external_link,omitempty" json:"external_link"`
	PlatformFeeBasisPoints int         `mapstructure:"platform_fee_basis_points" json:"platform_fee_basis_points"`
	PlatformFeeRecipient   string      `mapstructure:"platform_fee_recipient" json:"platform_fee_recipient"`
	TrustedForwarders      []string    `mapstructure:"trusted_forwarders" json:"trusted_forwarders"`
}

type DeployMultiwrapMetadata

type DeployMultiwrapMetadata struct {
	Name                 string      `mapstructure:"name" json:"name"`
	Description          string      `mapstructure:"description" json:"description"`
	Image                interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalLink         string      `mapstructure:"external_link,omitempty" json:"external_link"`
	SellerFeeBasisPoints int         `mapstructure:"seller_fee_basis_points" json:"seller_fee_basis_points"`
	FeeRecipient         string      `mapstructure:"fee_recipient" json:"fee_recipient"`
	Symbol               string      `mapstructure:"symbol" json:"symbol"`
	TrustedForwarders    []string    `mapstructure:"trusted_forwarders" json:"trusted_forwarders"`
}

type DeployNFTCollectionMetadata

type DeployNFTCollectionMetadata struct {
	Name                   string      `mapstructure:"name" json:"name"`
	Description            string      `mapstructure:"description" json:"description"`
	Image                  interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalLink           string      `mapstructure:"external_link,omitempty" json:"external_link"`
	SellerFeeBasisPoints   int         `mapstructure:"seller_fee_basis_points" json:"seller_fee_basis_points"`
	FeeRecipient           string      `mapstructure:"fee_recipient" json:"fee_recipient"`
	Symbol                 string      `mapstructure:"symbol" json:"symbol"`
	PrimarySaleRecipient   string      `mapstructure:"primary_sale_recipient" json:"primary_sale_recipient"`
	PlatformFeeBasisPoints int         `mapstructure:"platform_fee_basis_points" json:"platform_fee_basis_points"`
	PlatformFeeRecipient   string      `mapstructure:"platform_fee_recipient" json:"platform_fee_recipient"`
	TrustedForwarders      []string    `mapstructure:"trusted_forwarders" json:"trusted_forwarders"`
}

type DeployNFTDropMetadata

type DeployNFTDropMetadata struct {
	Name                   string      `mapstructure:"name" json:"name"`
	Description            string      `mapstructure:"description" json:"description"`
	Image                  interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalLink           string      `mapstructure:"external_link,omitempty" json:"external_link"`
	SellerFeeBasisPoints   int         `mapstructure:"seller_fee_basis_points" json:"seller_fee_basis_points"`
	FeeRecipient           string      `mapstructure:"fee_recipient" json:"fee_recipient"`
	Merkle                 interface{} `mapstructure:"merkle" json:"merkle"`
	Symbol                 string      `mapstructure:"symbol" json:"symbol"`
	PrimarySaleRecipient   string      `mapstructure:"primary_sale_recipient" json:"primary_sale_recipient"`
	PlatformFeeBasisPoints int         `mapstructure:"platform_fee_basis_points" json:"platform_fee_basis_points"`
	PlatformFeeRecipient   string      `mapstructure:"platform_fee_recipient" json:"platform_fee_recipient"`
	TrustedForwarders      []string    `mapstructure:"trusted_forwarders" json:"trusted_forwarders"`
}

type DeployTokenMetadata

type DeployTokenMetadata struct {
	Name                   string      `mapstructure:"name" json:"name"`
	Description            string      `mapstructure:"description" json:"description"`
	Image                  interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalLink           string      `mapstructure:"external_link,omitempty" json:"external_link"`
	Symbol                 string      `mapstructure:"symbol" json:"symbol"`
	PrimarySaleRecipient   string      `mapstructure:"primary_sale_recipient" json:"primary_sale_recipient"`
	PlatformFeeBasisPoints int         `mapstructure:"platform_fee_basis_points" json:"platform_fee_basis_points"`
	PlatformFeeRecipient   string      `mapstructure:"platform_fee_recipient" json:"platform_fee_recipient"`
	TrustedForwarders      []string    `mapstructure:"trusted_forwarders" json:"trusted_forwarders"`
}

type DirectListing

type DirectListing struct {
	Id                          string
	AssetContractAddress        string
	TokenId                     int
	Asset                       *NFTMetadata
	StartTimeInEpochSeconds     int
	EndTimeInEpochSeconds       int
	Quantity                    int
	CurrencyContractAddress     string
	BuyoutCurrencyValuePerToken *CurrencyValue
	BuyoutPrice                 string
	SellerAddress               string
}

type ERC1155

type ERC1155 struct {
	ClaimConditions *EditionDropClaimConditions
	// contains filtered or unexported fields
}

This interface is currently support by the Edition and Edition Drop contracts. You can access all of its functions through an Edition or Edition Drop contract instance.

func (*ERC1155) Balance

func (erc1155 *ERC1155) Balance(ctx context.Context, tokenId int) (int, error)

Get NFT balance

@extension: ERC1155

tokenId: the token ID of a specific token to check the balance of

returns: the number of NFTs of the specified token ID owned by the connected wallet

func (*ERC1155) BalanceOf

func (erc1155 *ERC1155) BalanceOf(ctx context.Context, address string, tokenId int) (int, error)

Get NFT balance of a specific wallet

@extension: ERC1155

address: the address of the wallet to get the NFT balance of

returns: the number of NFTs of the specified token ID owned by the specified wallet

Example

address := "{{wallet_address}}"
tokenId := 0
balance, err := contract.BalanceOf(context.Background(), address, tokenId)

func (*ERC1155) Burn

func (erc1155 *ERC1155) Burn(ctx context.Context, tokenId int, amount int) (*types.Transaction, error)

Burn NFTs

@extension: ERC1155Burnable

tokenId: tokenID of the token to burn

amount: number of NFTs of the token ID to burn

returns: the transaction receipt of the burn

Example

tokenId := 0
amount := 1
tx, err := contract.Burn(context.Background(), tokenId, amount)

func (*ERC1155) Claim

func (erc1155 *ERC1155) Claim(ctx context.Context, tokenId int, quantity int) (*types.Transaction, error)

Claim an NFT

@extension: ERC1155ClaimCustom | ERC1155ClaimPhasesV2 | ERC1155ClaimConditionsV2

tokenId: the token ID of the NFT to claim

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

tokenId = 0
quantity = 1

tx, err := contract.ClaimTo(context.Background(), tokenId, quantity)

func (*ERC1155) ClaimTo

func (erc1155 *ERC1155) ClaimTo(ctx context.Context, destinationAddress string, tokenId int, quantity int) (*types.Transaction, error)

Claim an NFT to a specific wallet

@extension: ERC1155ClaimCustom | ERC1155ClaimPhasesV2 | ERC1155ClaimConditionsV2

tokenId: the token ID of the NFT to claim

destinationAddress: the address of the wallet to claim the NFTs to

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

address = "{{wallet_address}}"
tokenId = 0
quantity = 1

tx, err := contract.ClaimTo(context.Background(), address, tokenId, quantity)

func (*ERC1155) CreateBatch

func (erc1155 *ERC1155) CreateBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Lazy mint NFTs

@extension: ERC1155LazyMintableV2

metadatas: a list of the metadatas of the NFTs to create

returns: the transaction receipt of the batch creation

Example

image0, err := os.Open("path/to/image/0.jpg")
defer image0.Close()

image1, err := os.Open("path/to/image/1.jpg")
defer image1.Close()

metadatasWithSupply := []*thirdweb.EditionMetadataInput{
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
			Image: image0,
		},
		Supply: 100,
	},
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
			Image: image1,
		},
		Supply: 100,
	},
}

tx, err := contract.CreateBatch(context.Background(), metadatasWithSupply)

func (*ERC1155) Get

func (erc1155 *ERC1155) Get(ctx context.Context, tokenId int) (*EditionMetadata, error)

Get an NFT

@extension: ERC1155

tokenId: token ID of the token to get the metadata for

returns: the metadata for the NFT and its supply

Example

nft, err := contract.Get(context.Background(), 0)
supply := nft.Supply
name := nft.Metadata.Name

func (*ERC1155) GetAll

func (erc1155 *ERC1155) GetAll(ctx context.Context) ([]*EditionMetadata, error)

Get all NFTs

@extension: ERC1155

returns: the metadatas and supplies of all the NFTs on this contract

Example

nfts, err := contract.GetAll(context.Background())
supplyOne := nfts[0].Supply
nameOne := nfts[0].Metadata.Name

func (*ERC1155) GetOwned

func (erc1155 *ERC1155) GetOwned(ctx context.Context, address string) ([]*EditionMetadataOwner, error)

Get owned NFTs

@extension: ERC1155Enumerable

address: the address of the owner of the NFTs

returns: the metadatas and supplies of all the NFTs owned by the address

Example

owner := "{{wallet_address}}"
nfts, err := contract.GetOwned(context.Background(), owner)
name := nfts[0].Metadata.Name

func (*ERC1155) GetTotalCount

func (erc1155 *ERC1155) GetTotalCount(ctx context.Context) (int, error)

Get the total number of NFTs

@extension: ERC1155Enumerable

returns: the total number of NFTs on this contract

Example

totalCount, err := contract.GetTotalCount(context.Background())

func (*ERC1155) IsApproved

func (erc1155 *ERC1155) IsApproved(ctx context.Context, owner string, operator string) (bool, error)

Check NFT approval

@extension: ERC1155

address: the address whose assets are to be checked

operator: the address of the operator to check

returns: true if the operator is approved for all operations of the assets, otherwise false

Example

owner := "{{wallet_address}}"
operator := "0x..."

isApproved, err := contract.IsApproved(context.Background, owner, operator)

func (*ERC1155) Mint

func (erc1155 *ERC1155) Mint(ctx context.Context, metadataWithSupply *EditionMetadataInput) (*types.Transaction, error)

Mint an NFT

@extension: ERC1155Mintable

metadataWithSupply: nft metadata with supply of the NFT to mint

returns: the transaction receipt of the mint

Example

image, err := os.Open("path/to/image.jpg")
defer image.Close()

metadataWithSupply := &thirdweb.EditionMetadataInput{
	Metadata: &thirdweb.NFTMetadataInput{
		Name: "Cool NFT",
		Description: "This is a cool NFT",
		Image: image,
	},
	Supply: 100,
}

tx, err := contract.Mint(context.Background(), metadataWithSupply)

func (*ERC1155) MintAdditionalSupply

func (erc1155 *ERC1155) MintAdditionalSupply(ctx context.Context, tokenId int, additionalSupply int) (*types.Transaction, error)

Mint additionaly supply of an NFT

@extension: ERC1155Mintable

tokenId: token ID to mint additional supply of

additionalSupply: additional supply to mint

returns: the transaction receipt of the mint

Example

tokenId := 0
additionalSupply := 100

tx, err := contract.MintAdditionalSupply(context.Background(), tokenId, additionalSupply)

func (*ERC1155) MintAdditionalSupplyTo

func (erc1155 *ERC1155) MintAdditionalSupplyTo(ctx context.Context, to string, tokenId int, additionalSupply int) (*types.Transaction, error)

Mint additional supply of an NFT to a specific wallet

@extension: ERC1155Mintable

to: address of the wallet to mint NFTs to

tokenId: token Id to mint additional supply of

additionalySupply: additional supply to mint

returns: the transaction receipt of the mint

Example

to := "{{wallet_address}}"
tokenId := 0
additionalSupply := 100

tx, err := contract.MintAdditionalSupplyTo(context.Background(), to, tokenId, additionalSupply)

func (*ERC1155) MintAdditionalSupplyToWithEIP1559TipSelection added in v2.3.0

func (erc1155 *ERC1155) MintAdditionalSupplyToWithEIP1559TipSelection(ctx context.Context, to string, tokenId int, additionalSupply int, tipname string) (*types.Transaction, error)

func (*ERC1155) MintBatch

func (erc1155 *ERC1155) MintBatch(ctx context.Context, metadatasWithSupply []*EditionMetadataInput) (*types.Transaction, error)

Mint many NFTs

@extension: ERC1155BatchMintable

metadatasWithSupply: list of NFT metadatas with supplies to mint

returns: the transaction receipt of the mint

Example

metadatasWithSupply := []*thirdweb.EditionMetadataInput{
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
		},
		Supply: 100,
	},
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
		},
		Supply: 100,
	},
}

tx, err := contract.MintBatch(context.Background(), metadatasWithSupply)

func (*ERC1155) MintBatchTo

func (erc1155 *ERC1155) MintBatchTo(ctx context.Context, to string, metadatasWithSupply []*EditionMetadataInput) (*types.Transaction, error)

Mint many NFTs to a specific wallet

@extension: ERC1155BatchMintable

to: address of the wallet to mint NFTs to

metadatasWithSupply: list of NFT metadatas with supplies to mint

returns: the transaction receipt of the mint

Example

metadatasWithSupply := []*thirdweb.EditionMetadataInput{
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
		},
		Supply: 100,
	},
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
		},
		Supply: 100,
	},
}

tx, err := contract.MintBatchTo(context.Background(), "{{wallet_address}}", metadatasWithSupply)

func (*ERC1155) MintTo

func (erc1155 *ERC1155) MintTo(ctx context.Context, address string, metadataWithSupply *EditionMetadataInput) (*types.Transaction, error)

Mint an NFT to a specific wallet

@extension: ERC1155Mintable

address: the wallet address to mint the NFT to

metadataWithSupply: nft metadata with supply of the NFT to mint

returns: the transaction receipt of the mint

Example

image, err := os.Open("path/to/image.jpg")
defer image.Close()

metadataWithSupply := &thirdweb.EditionMetadataInput{
	Metadata: &thirdweb.NFTMetadataInput{
		Name: "Cool NFT",
		Description: "This is a cool NFT",
		Image: image,
	},
	Supply: 100,
}

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

func (*ERC1155) SetApprovalForAll

func (erc1155 *ERC1155) SetApprovalForAll(ctx context.Context, operator string, approved bool) (*types.Transaction, error)

Set approval for all NFTs

@extension: ERC1155

address: the address whose assets are to be approved

operator: the address of the operator to set the approval for

approved: true if the operator is approved for all operations of the assets, otherwise false

returns: the transaction receipt of the approval

Example

operator := "{{wallet_address}}"
approved := true

tx, err := contract.SetApprovalForAll(context.Background(), operator, approved)

func (*ERC1155) TotalSupply

func (erc1155 *ERC1155) TotalSupply(ctx context.Context, tokenId int) (int, error)

Get the total supply of an NFT

@extension: ERC1155

tokenId: the token ID to check the total supply of

returns: the supply of NFTs on the specified token ID

Example

tokenId := 0

totalSupply, err := contract.TotalSupply(context.Background, tokenId)

func (*ERC1155) Transfer

func (erc1155 *ERC1155) Transfer(ctx context.Context, to string, tokenId int, amount int) (*types.Transaction, error)

Transfer NFTs

@extension: ERC1155

to: wallet address to transfer the tokens to

tokenId: the token ID of the NFT to transfer

amount: number of NFTs of the token ID to transfer

returns: the transaction of the NFT transfer

Example

to := "0x..."
tokenId := 0
amount := 1

tx, err := contract.Transfer(context.Background(), to, tokenId, amount)

type ERC1155SignatureMinting

type ERC1155SignatureMinting struct {
	Helper *contractHelper
	// contains filtered or unexported fields
}

You can access this interface from the edition contract under the signature interface

func (*ERC1155SignatureMinting) Generate

func (signature *ERC1155SignatureMinting) Generate(ctx context.Context, payloadToSign *Signature1155PayloadInput) (*SignedPayload1155, error)

Generate a payload to mint a new token ID

payloadToSign: the payload containing the data for the signature mint

returns: the payload signed by the minter's private key

Example

payload := &thirdweb.Signature721PayloadInput{
	To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6", // address to mint to
	Price:                0,                                            // cost of minting
	CurrencyAddress:      "0x0000000000000000000000000000000000000000", // currency to pay in order to mint
	MintStartTime:        0,                                            // time where minting is allowed to start (epoch seconds)
	MintEndTime:          100000000000000,                              // time when this signature expires (epoch seconds)
	PrimarySaleRecipient: "0x0000000000000000000000000000000000000000", // address to receive the primary sales of this mint
	Metadata: &thirdweb.NFTMetadataInput{																// metadata of the NFT to mint
 		Name:  "ERC721 Sigmint!",
	},
	RoyaltyRecipient: "0x0000000000000000000000000000000000000000",     // address to receive royalties of this mint
	RoyaltyBps:       0,                                                // royalty cut of this mint in basis points
	Quantity:         1,   																					    // number of tokens to mint
}

signedPayload, err := contract.Signature.Generate(context.Background(), payload)

func (*ERC1155SignatureMinting) GenerateBatch

func (signature *ERC1155SignatureMinting) GenerateBatch(ctx context.Context, payloadsToSign []*Signature1155PayloadInput) ([]*SignedPayload1155, error)

Generate a batch of payloads to mint multiple new token IDs

payloadToSign: the payloads containing the data for the signature mint

returns: the payloads signed by the minter's private key

Example

payload := []*thirdweb.Signature1155PayloadInput{
	&thirdweb.Signature1155PayloadInput{
		To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
		Price:                0,
		CurrencyAddress:      "0x0000000000000000000000000000000000000000",
		MintStartTime:        0,
		MintEndTime:          100000000000000,
		PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
		Metadata: &thirdweb.NFTMetadataInput{
 			Name:  "ERC1155 Sigmint 1",
		},
		RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
		RoyaltyBps:       0,
		Quantity:         1,
	},
	&thirdweb.Signature1155PayloadInput{
		To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
		Price:                0,
		CurrencyAddress:      "0x0000000000000000000000000000000000000000",
		MintStartTime:        0,
		MintEndTime:          100000000000000,
		PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
		Metadata: &thirdweb.NFTMetadataInput{
 			Name:  "ERC1155 Sigmint 2",
		},
		RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
		RoyaltyBps:       0,
		Quantity:         1,
	},
}

signedPayload, err := contract.Signature.GenerateBatch(context.Background(), payload)

func (*ERC1155SignatureMinting) GenerateBatchFromTokenIds

func (signature *ERC1155SignatureMinting) GenerateBatchFromTokenIds(ctx context.Context, payloadsToSign []*Signature1155PayloadInputWithTokenId) ([]*SignedPayload1155, error)

Generate a batch of payloads to mint multiple new token IDs

payloadToSign: the payloads containing the data for the signature mint

returns: the payloads signed by the minter's private key

Example

payload := []*thirdweb.Signature1155PayloadInputWithTokenId{
	&thirdweb.Signature1155PayloadInputWithTokenId{
		To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
		Price:                0,
		CurrencyAddress:      "0x0000000000000000000000000000000000000000",
		MintStartTime:        0,
		MintEndTime:          100000000000000,
		PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
		Metadata: &thirdweb.NFTMetadataInput{
 			Name:  "ERC1155 Sigmint 1",
		},
		RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
		RoyaltyBps:       0,
		Quantity:         1,
		TokenId:          0,
	},
	&thirdweb.Signature1155PayloadInputWithTokenId{
		To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
		Price:                0,
		CurrencyAddress:      "0x0000000000000000000000000000000000000000",
		MintStartTime:        0,
		MintEndTime:          100000000000000,
		PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
		Metadata: nil
		RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
		RoyaltyBps:       0,
		Quantity:         1,
		TokenId:          1,
	},
}

signedPayload, err := contract.Signature.GenerateBatchFromTokenIds(context.Background(), payload)

func (*ERC1155SignatureMinting) GenerateFromTokenId

func (signature *ERC1155SignatureMinting) GenerateFromTokenId(ctx context.Context, payloadToSign *Signature1155PayloadInputWithTokenId) (*SignedPayload1155, error)

Generate a new payload to mint additionaly supply to an existing token ID

payloadToSign: the payload containing the data for the signature mint

returns: the payload signed by the minter's private key

Example

	payload := &thirdweb.Signature1155PayloadInputWithTokenId{
		To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
		Price:                0,
		CurrencyAddress:      "0x0000000000000000000000000000000000000000",
		MintStartTime:        0,
		MintEndTime:          100000000000000,
		PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
		Metadata:             nil,                                          // we don't need to pass NFT metadata since we are minting an existing token
		RoyaltyRecipient:     "0x0000000000000000000000000000000000000000",
		RoyaltyBps:           0,
		Quantity:             1,
 	TokenId:              0,                                            // now we need to specify the token ID to mint supply to
	}

	signedPayload, err := contract.Signature.GenerateFromTokenId(context.Background(), payload)

func (*ERC1155SignatureMinting) Mint

func (signature *ERC1155SignatureMinting) Mint(ctx context.Context, signedPayload *SignedPayload1155) (*types.Transaction, error)

Mint a token with the data in given payload.

signedPayload: the payload signed by the minters private key being used to mint

returns: the transaction receipt of the mint

Example

// Learn more about how to craft a payload in the Generate() function
signedPayload, err := contract.Signature.Generate(payload)
tx, err := contract.Signature.Mint(signedPayload)

func (*ERC1155SignatureMinting) MintBatch

func (signature *ERC1155SignatureMinting) MintBatch(ctx context.Context, signedPayloads []*SignedPayload1155) (*types.Transaction, error)

Mint a batch of token with the data in given payload.

signedPayload: the list of payloads signed by the minters private key being used to mint

returns: the transaction receipt of the batch mint

Example

// Learn more about how to craft multiple payloads in the GenerateBatch() function
signedPayloads, err := contract.Signature.GenerateBatch(payloads)
tx, err := contract.Signature.MintBatch(signedPayloads)

func (*ERC1155SignatureMinting) MintWithOpts

func (signature *ERC1155SignatureMinting) MintWithOpts(ctx context.Context, signedPayload *SignedPayload1155, txOpts *bind.TransactOpts) (*types.Transaction, error)

func (*ERC1155SignatureMinting) Verify

func (signature *ERC1155SignatureMinting) Verify(ctx context.Context, signedPayload *SignedPayload1155) (bool, error)

Verify that a signed payload is valid

signedPayload: the payload to verify

returns: true if the payload is valid, otherwise false.

Example

// Learn more about how to craft a payload in the Generate() function
signedPayload, err := contract.Signature.Generate(payload)
isValid, err := contract.Signature.Verify(context.Background(), signedPayload)

type ERC1155Standard

type ERC1155Standard struct {
	// contains filtered or unexported fields
}

This interface is currently support by the Edition and Edition Drop contracts. You can access all of its functions through an Edition or Edition Drop contract instance.

func (*ERC1155Standard) Balance

func (erc1155 *ERC1155Standard) Balance(ctx context.Context, tokenId int) (int, error)

Get the NFT balance of the connected wallet for a specific token ID.

tokenId: the token ID of a specific token to check the balance of

returns: the number of NFTs of the specified token ID owned by the connected wallet

func (*ERC1155Standard) BalanceOf

func (erc1155 *ERC1155Standard) BalanceOf(ctx context.Context, address string, tokenId int) (int, error)

Get the NFT balance of a specific wallet.

address: the address of the wallet to get the NFT balance of

returns: the number of NFTs of the specified token ID owned by the specified wallet

Example

address := "{{wallet_address}}"
tokenId := 0
balance, err := contract.BalanceOf(context.Background(), address, tokenId)

func (*ERC1155Standard) Burn

func (erc1155 *ERC1155Standard) Burn(ctx context.Context, tokenId int, amount int) (*types.Transaction, error)

Burn an amount of a specified NFT from the connected wallet.

tokenId: tokenID of the token to burn

amount: number of NFTs of the token ID to burn

returns: the transaction receipt of the burn

Example

tokenId := 0
amount := 1
tx, err := contract.Burn(context.Background(), tokenId, amount)

func (*ERC1155Standard) Get

func (erc1155 *ERC1155Standard) Get(ctx context.Context, tokenId int) (*EditionMetadata, error)

Get metadata for a token.

tokenId: token ID of the token to get the metadata for

returns: the metadata for the NFT and its supply

Example

	nft, err := contract.Get(context.Background(), 0)
 supply := nft.Supply
	name := nft.Metadata.Name

func (*ERC1155Standard) GetAll

func (erc1155 *ERC1155Standard) GetAll(ctx context.Context) ([]*EditionMetadata, error)

Get the metadata of all the NFTs on this contract.

returns: the metadatas and supplies of all the NFTs on this contract

Example

nfts, err := contract.GetAll(context.Background())
supplyOne := nfts[0].Supply
nameOne := nfts[0].Metadata.Name

func (*ERC1155Standard) GetOwned

func (erc1155 *ERC1155Standard) GetOwned(ctx context.Context, address string) ([]*EditionMetadataOwner, error)

Get the metadatas of all the NFTs owned by a specific address.

address: the address of the owner of the NFTs

returns: the metadatas and supplies of all the NFTs owned by the address

Example

owner := "{{wallet_address}}"
nfts, err := contract.GetOwned(context.Background(), owner)
name := nfts[0].Metadata.Name

func (*ERC1155Standard) GetTotalCount

func (erc1155 *ERC1155Standard) GetTotalCount(ctx context.Context) (int, error)

Get the total number of NFTs on this contract.

returns: the total number of NFTs on this contract

func (*ERC1155Standard) IsApproved

func (erc1155 *ERC1155Standard) IsApproved(ctx context.Context, address string, operator string) (bool, error)

Check whether an operator address is approved for all operations of a specifc addresses assets.

address: the address whose assets are to be checked

operator: the address of the operator to check

returns: true if the operator is approved for all operations of the assets, otherwise false

func (*ERC1155Standard) SetApprovalForAll

func (erc1155 *ERC1155Standard) SetApprovalForAll(ctx context.Context, operator string, approved bool) (*types.Transaction, error)

Set the approval for all operations of a specific address's assets.

address: the address whose assets are to be approved

operator: the address of the operator to set the approval for

approved: true if the operator is approved for all operations of the assets, otherwise false

returns: the transaction receipt of the approval

func (*ERC1155Standard) TotalSupply

func (erc1155 *ERC1155Standard) TotalSupply(ctx context.Context, tokenId int) (int, error)

Get the total number of NFTs of a specific token ID.

tokenId: the token ID to check the total supply of

returns: the supply of NFTs on the specified token ID

func (*ERC1155Standard) Transfer

func (erc1155 *ERC1155Standard) Transfer(ctx context.Context, to string, tokenId int, amount int) (*types.Transaction, error)

Transfer a specific quantity of a token ID from the connected wallet to a specified address.

to: wallet address to transfer the tokens to

tokenId: the token ID of the NFT to transfer

amount: number of NFTs of the token ID to transfer

returns: the transaction of the NFT transfer

Example

to := "0x..."
tokenId := 0
amount := 1

tx, err := contract.Transfer(context.Background(), to, tokenId, amount)

type ERC20

type ERC20 struct {
	// contains filtered or unexported fields
}

This interface is currently support by the Token contract. You can access all of its functions through a Token contract instance.

func (*ERC20) Allowance

func (erc20 *ERC20) Allowance(ctx context.Context, spender string) (*CurrencyValue, error)

Get token allowance for a specific spender

@extension: ERC20

spender: wallet address to check the allowance of

returns: allowance of the spender for the connected wallets tokens

Example

spender := "0x..."

allowance, err := contract.ERC20.Allowance(spender)
allowanceValue := allowance.DisplayValue

func (*ERC20) AllowanceOf

func (erc20 *ERC20) AllowanceOf(ctx context.Context, owner string, spender string) (*CurrencyValue, error)

Get token allowance for a specific spender and owner

@extension: ERC20

owner: wallet address who owns the assets

spender: wallet address to check the allowance of

returns: allowance of the spender for the connected wallets tokens

Example

address := "{{wallet_address}}"
spender := "0x..."

allowance, err := contract.ERC20.AllowanceOf(address, spender)
allowanceValue := allowance.DisplayValue

func (*ERC20) Balance

func (erc20 *ERC20) Balance(ctx context.Context) (*CurrencyValue, error)

Get token balance

@extension: ERC20

returns: balance of the connected wallet

Example

balance, err := contract.ERC20.Balance()
balanceValue := balance.DisplayValue

func (*ERC20) BalanceOf

func (erc20 *ERC20) BalanceOf(ctx context.Context, address string) (*CurrencyValue, error)

Get token balance of a specific wallet

@extension: ERC20

address: wallet address to check the balance of

returns: balance of the specified wallet

Example

address := "{{wallet_address}}"
balance, err := contract.ERC20.BalanceOf()
balanceValue := balance.DisplayValue

func (*ERC20) Burn

func (erc20 *ERC20) Burn(ctx context.Context, amount float64) (*types.Transaction, error)

Burn tokens

@extension: ERC20Burnable

amount: amount of tokens to burn

returns: transaction receipt of the burn

Example

amount := 1
tx, err := contract.ERC20.Burn(context.Background(), amount)

func (*ERC20) BurnFrom

func (erc20 *ERC20) BurnFrom(ctx context.Context, holder string, amount float64) (*types.Transaction, error)

Burn tokens from a specific wallet

@extension: ERC20Burnable

holder: wallet address to burn the tokens from

amount: amount of tokens to burn

returns: transaction receipt of the burn

Example

holder := "0x..."
amount := 1

tx, err := contract.ERC20.BurnFrom(context.Background(), holder, amount)

func (*ERC20) Get

func (erc20 *ERC20) Get(ctx context.Context) (*Currency, error)

Get token metadata

@extension: ERC20

returns: the metadata for the token

Example

currency, err := contract.ERC20.Get()
symbol := currency.Symbol

func (*ERC20) Mint

func (erc20 *ERC20) Mint(ctx context.Context, amount float64) (*types.Transaction, error)

Mint tokens

@extension: ERC20Mintable

amount: amount of tokens to mint

returns: transaction receipt of the mint

Example

tx, err := contract.ERC20.Mint(context.Background(), 1)

func (*ERC20) MintBatchTo

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

Mint tokens to many wallets

@extension: ERC20BatchMintable

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.ERC20.MintBatchTo(context.Background(), args)

func (*ERC20) MintTo

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

Mint tokens to a specific wallet

@extension: ERC20Mintable

to: wallet address to mint tokens to

amount: amount of tokens to mint

returns: transaction receipt of the mint

Example

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

func (*ERC20) SetAllowance

func (erc20 *ERC20) SetAllowance(ctx context.Context, spender string, amount float64) (*types.Transaction, error)

Set token allowance

@extension: ERC20

spender: wallet address to set the allowance of

amount: amount of tokens to grant the spender allowance of

returns: transaction receipt of the allowance set

Example

spender := "0x..."
amount := 1

tx, err := contract.ERC20.SetAllowance(context.Background(), spender, amount)

func (*ERC20) TotalSupply

func (erc20 *ERC20) TotalSupply(ctx context.Context) (*CurrencyValue, error)

Get the total minted supply

@extension: ERC20

returns: total minted supply of the token

Example

supply, err := contract.ERC20.TotalSupply(context.Background())

func (*ERC20) Transfer

func (erc20 *ERC20) Transfer(ctx context.Context, to string, amount float64) (*types.Transaction, error)

Transfer tokens

@extension: ERC20

to: address to transfer the tokens to

amount: amount of tokens to transfer

returns: transaction receipt of the transfer

Example

to := "0x..."
amount := 1

tx, err := contract.ERC20.Transfer(context.Background(), to, amount)

func (*ERC20) TransferBatch

func (erc20 *ERC20) TransferBatch(ctx context.Context, args []*TokenAmount) (*types.Transaction, error)

Transfer many tokens

args: list of token amounts with amounts and addresses to transfer to

returns: transaction receipt of the transfers

Example

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

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

func (*ERC20) TransferFrom

func (erc20 *ERC20) TransferFrom(ctx context.Context, from string, to string, amount float64) (*types.Transaction, error)

Transfer tokens from a specific wallet

@extension: ERC20

from: address to transfer the tokens from

to: address to transfer the tokens to

amount: amount of tokens to transfer

returns: transaction receipt of the transfer

Example

from := "{{wallet_address}}"
to := "0x..."
amount := 1

tx, err := contract.ERC20.TransferFrom(context.Background(), from, to, amount)

type ERC20Standard

type ERC20Standard struct {
	// contains filtered or unexported fields
}

This interface is currently support by the Token contract. You can access all of its functions through a Token contract instance.

func (*ERC20Standard) Allowance

func (erc20 *ERC20Standard) Allowance(ctx context.Context, spender string) (*CurrencyValue, error)

Get a specified spenders allowance for the connected wallets tokens.

spender: wallet address to check the allowance of

returns: allowance of the spender for the connected wallets tokens

Example

spender := "0x..."

allowance, err := contract.Allowance(spender)
allowanceValue := allowance.DisplayValue

func (*ERC20Standard) AllowanceOf

func (erc20 *ERC20Standard) AllowanceOf(ctx context.Context, owner string, spender string) (*CurrencyValue, error)

Get a specified spenders allowance for the a specific wallets tokens.

owner: wallet address who owns the assets

spender: wallet address to check the allowance of

returns: allowance of the spender for the connected wallets tokens

Example

address := "{{wallet_address}}"
spender := "0x..."

allowance, err := contract.AllowanceOf(address, spender)
allowanceValue := allowance.DisplayValue

func (*ERC20Standard) Balance

func (erc20 *ERC20Standard) Balance(ctx context.Context) (*CurrencyValue, error)

Get the token balance of the connected wallet.

returns: balance of the connected wallet

Example

	balance, err := contract.Balance()
 balanceValue := balance.DisplayValue

func (*ERC20Standard) BalanceOf

func (erc20 *ERC20Standard) BalanceOf(ctx context.Context, address string) (*CurrencyValue, error)

Get the balance of the specified wallet.

address: wallet address to check the balance of

returns: balance of the specified wallet

Example

	address := "{{wallet_address}}"
	balance, err := contract.BalanceOf()
 balanceValue := balance.DisplayValue

func (*ERC20Standard) Burn

func (erc20 *ERC20Standard) Burn(ctx context.Context, amount float64) (*types.Transaction, error)

Burn a specified amount of tokens from the connected wallet.

amount: amount of tokens to burn

returns: transaction receipt of the burn

Example

amount := 1
tx, err := contract.Burn(context.Background(), amount)

func (*ERC20Standard) BurnFrom

func (erc20 *ERC20Standard) BurnFrom(ctx context.Context, holder string, amount float64) (*types.Transaction, error)

Burn a specified amount of tokens from a specific wallet.

holder: wallet address to burn the tokens from

amount: amount of tokens to burn

returns: transaction receipt of the burn

Example

holder := "0x..."
amount := 1

tx, err := contract.BurnFrom(context.Background(), holder, amount)

func (*ERC20Standard) Get

func (erc20 *ERC20Standard) Get(ctx context.Context) (*Currency, error)

Get token metadata including name, symbol, decimals, etc.

returns: the metadata for the token

Example

currency, err := contract.Get()
symbol := currency.Symbol

func (*ERC20Standard) SetAllowance

func (erc20 *ERC20Standard) SetAllowance(ctx context.Context, spender string, amount float64) (*types.Transaction, error)

Sets the allowance of a wallet to spend the connected wallets funds.

spender: wallet address to set the allowance of

amount: amount of tokens to grant the spender allowance of

returns: transaction receipt of the allowance set

Example

spender := "0x..."
amount := 1

tx, err := contract.SetAllowance(context.Background(), spender, amount)

func (*ERC20Standard) TotalSupply

func (erc20 *ERC20Standard) TotalSupply(ctx context.Context) (*CurrencyValue, error)

Get the total minted supply of the token.

returns: total minted supply of the token

func (*ERC20Standard) Transfer

func (erc20 *ERC20Standard) Transfer(ctx context.Context, to string, amount float64) (*types.Transaction, error)

Transfer a specified amount of tokens from the connected wallet to a specified address.

to: address to transfer the tokens to

amount: amount of tokens to transfer

returns: transaction receipt of the transfer

Example

to := "0x..."
amount := 1

tx, err := contract.Transfer(context.Background(), to, amount)

func (*ERC20Standard) TransferBatch

func (erc20 *ERC20Standard) TransferBatch(ctx context.Context, args []*TokenAmount) (*types.Transaction, error)

Transfer tokens from the connected wallet to many wallets.

args: list of token amounts with amounts and addresses to transfer to

returns: transaction receipt of the transfers

Example

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

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

func (*ERC20Standard) TransferFrom

func (erc20 *ERC20Standard) TransferFrom(ctx context.Context, from string, to string, amount float64) (*types.Transaction, error)

Transfer a specified amount of tokens from one specified address to another.

from: address to transfer the tokens from

to: address to transfer the tokens to

amount: amount of tokens to transfer

returns: transaction receipt of the transfer

Example

from := "{{wallet_address}}"
to := "0x..."
amount := 1

tx, err := contract.TransferFrom(context.Background(), from, to, amount)

type ERC721

type ERC721 struct {
	ClaimConditions *NFTDropClaimConditions
	// contains filtered or unexported fields
}

This interface is currently support by the NFT Collection and NFT Drop contracts. You can access all of its functions through an NFT Collection or NFT Drop contract instance.

func (*ERC721) Balance

func (erc721 *ERC721) Balance(ctx context.Context) (int, error)

Get NFT balance

@extension: ERC721

returns: the number of NFTs on this contract owned by the connected wallet

Example

balance, err := contract.ERC721.Balance(context.Background())

func (*ERC721) BalanceOf

func (erc721 *ERC721) BalanceOf(ctx context.Context, address string) (int, error)

Get NFT balance of a specific wallet

@extension: ERC721

address: the address of the wallet to get the NFT balance of

returns: the number of NFTs on this contract owned by the specified wallet

Example

address := "{{wallet_address}}"
balance, err := contract.ERC721.BalanceOf(context.Background(), address)

func (*ERC721) Burn

func (erc721 *ERC721) Burn(ctx context.Context, tokenId int) (*types.Transaction, error)

Burna an NFT

@extension: ERC721Burnable

tokenId: tokenID of the token to burn

returns: the transaction receipt of the burn

Example

tokenId := 0
tx, err := contract.ERC721.Burn(context.Background(), tokenId)

func (*ERC721) Claim

func (erc721 *ERC721) Claim(ctx context.Context, quantity int) (*types.Transaction, error)

Claim an NFT

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

quantity = 1

tx, err := contract.ERC721.Claim(context.Background(), quantity)

func (*ERC721) ClaimTo

func (erc721 *ERC721) ClaimTo(ctx context.Context, destinationAddress string, quantity int) (*types.Transaction, error)

Claim NFTs to a specific wallet

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

destinationAddress: the address of the wallet to claim the NFTs to

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

address := "{{wallet_address}}"
quantity = 1

tx, err := contract.ERC721.ClaimTo(context.Background(), address, quantity)

func (*ERC721) CreateBatch

func (erc721 *ERC721) CreateBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Lazy mint NFTs

@extension: ERC721LazyMintable

metadatas: a list of the metadatas of the NFTs to create

returns: the transaction receipt of the batch creation

Example

image0, err := os.Open("path/to/image/0.jpg")
defer image0.Close()

image1, err := os.Open("path/to/image/1.jpg")
defer image1.Close()

metadatas := []*thirdweb.NFTMetadataInput{
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT",
		Description: "This is a cool NFT",
		Image: image1
	}
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT 2",
		Description: "This is also a cool NFT",
		Image: image2
	}
}

tx, err := contract.ERC721.CreateBatch(context.Background(), metadatas)

func (*ERC721) Get

func (erc721 *ERC721) Get(ctx context.Context, tokenId int) (*NFTMetadataOwner, error)

Get an NFT

@extension: ERC721

tokenId: token ID of the token to get the metadata for

returns: the metadata for the NFT and its owner

Example

nft, err := contract.ERC721.Get(context.Background(), 0)
owner := nft.Owner
name := nft.Metadata.Name

func (*ERC721) GetAll

func (erc721 *ERC721) GetAll(ctx context.Context) ([]*NFTMetadataOwner, error)

Get all NFTs

@extension: ERC721Supply | ERC721Enumerable

returns: the metadata of all the NFTs on this contract

Example

nfts, err := contract.ERC721.GetAll(context.Background())
ownerOne := nfts[0].Owner
nameOne := nfts[0].Metadata.Name

func (*ERC721) GetAllClaimed

func (erc721 *ERC721) GetAllClaimed(ctx context.Context) ([]*NFTMetadataOwner, error)

Get all claimed NFTs

returns: a list of the metadatas of the claimed NFTs

Example

claimedNfts, err := contract.ERC721.GetAllClaimed(context.Background())
firstOwner := claimedNfts[0].Owner

func (*ERC721) GetAllUnclaimed

func (erc721 *ERC721) GetAllUnclaimed(ctx context.Context) ([]*NFTMetadata, error)

Get all unclaimed NFTs

returns: a list of the metadatas of the unclaimed NFTs

Example

unclaimedNfts, err := contract.ERC721.GetAllUnclaimed(context.Background())
firstNftName := unclaimedNfts[0].Name

func (*ERC721) GetClaimArguments

func (erc721 *ERC721) GetClaimArguments(
	ctx context.Context,
	destinationAddress string,
	quantity int,
) (
	*ClaimArguments,
	error,
)

func (*ERC721) GetClaimIneligibilityReasons

func (erc721 *ERC721) GetClaimIneligibilityReasons(ctx context.Context, quantity int, addressToCheck string) ([]ClaimEligibility, error)

func (*ERC721) GetClaimInfo

func (erc721 *ERC721) GetClaimInfo(ctx context.Context, address string) (*ClaimInfo, error)

func (*ERC721) GetTotalCount

func (erc721 *ERC721) GetTotalCount(ctx context.Context) (int, error)

Get the total number of NFTs

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

returns: the total number of NFTs on this contract

Example

totalCount, err := contract.ERC721.GetTotalCount(context.Background())

func (*ERC721) IsApproved

func (erc721 *ERC721) IsApproved(ctx context.Context, owner string, operator string) (bool, error)

Check NFT approval

@extension: ERC721

address: the address whose assets are to be checked

operator: the address of the operator to check

returns: true if the operator is approved for all operations of the assets, otherwise false

Example

owner := "{{wallet_address}}"
operator := "0x..."

isApproved, err := contract.ERC721.IsApproved(ctx, owner, operator)

func (*ERC721) Mint

func (erc721 *ERC721) Mint(ctx context.Context, metadata *NFTMetadataInput) (*types.Transaction, error)

Mint an NFT

@extension: ERC721Mintable

metadata: metadata of the NFT to mint

returns: the transaction receipt of the mint

Example

image, err := os.Open("path/to/image.jpg")
defer image.Close()

metadata := &thirdweb.NFTMetadataInput{
	Name: "Cool NFT",
	Description: "This is a cool NFT",
	Image: image,
}

tx, err := contract.ERC721.Mint(context.Background(), metadata)

func (*ERC721) MintBatch

func (erc721 *ERC721) MintBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Mint many NFTs

@extension: ERC721BatchMintable

metadatas: list of metadata of the NFTs to mint

returns: the transaction receipt of the mint

Example

metadatas := []*thirdweb.NFTMetadataInput{
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT",
		Description: "This is a cool NFT",
	}
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT 2",
		Description: "This is also a cool NFT",
	}
}

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

func (*ERC721) MintBatchTo

func (erc721 *ERC721) MintBatchTo(ctx context.Context, address string, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Mint many NFTs to a specific wallet

@extension: ERC721BatchMintable

to: the wallet address to mint to

metadatas: list of metadata of the NFTs to mint

returns: the transaction receipt of the mint

Example

metadatas := []*thirdweb.NFTMetadataInput{
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT",
		Description: "This is a cool NFT",
	}
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT 2",
		Description: "This is also a cool NFT",
	}
}

tx, err := contract.ERC721.MintBatchTo(context.Background(), "{{wallet_address}}", metadatas)

func (*ERC721) MintTo

func (erc721 *ERC721) MintTo(ctx context.Context, address string, metadata *NFTMetadataInput) (*types.Transaction, error)

Mint an NFT to a specific wallet

@extension: ERC721Mintable

address: the wallet address to mint to

metadata: metadata of the NFT to mint

returns: the transaction receipt of the mint

Example

image, err := os.Open("path/to/image.jpg")
defer image.Close()

metadata := &thirdweb.NFTMetadataInput{
	Name: "Cool NFT",
	Description: "This is a cool NFT",
	Image: image,
}

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

func (*ERC721) OwnerOf

func (erc721 *ERC721) OwnerOf(ctx context.Context, tokenId int) (string, error)

Get the owner of an NFT

@extension: ERC721

tokenId: the token ID of the NFT to get the owner of

returns: the owner of the NFT

Example

tokenId := 0
owner, err := contract.ERC721.OwnerOf(context.Background(), tokenId)

func (*ERC721) SetApprovalForAll

func (erc721 *ERC721) SetApprovalForAll(ctx context.Context, operator string, approved bool) (*types.Transaction, error)

Set approval for all NFTs

@extension: ERC721

address: the address whose assets are to be approved

operator: the address of the operator to set the approval for

approved: true if the operator is approved for all operations of the assets, otherwise false

returns: the transaction receipt of the approval

Example

operator := "{{wallet_address}}"
approved := true

tx, err := contract.ERC721.SetApprovalForAll(context.Background(), operator, approved)

func (*ERC721) SetApprovalForToken

func (erc721 *ERC721) SetApprovalForToken(ctx context.Context, operator string, tokenId int) (*types.Transaction, error)

Set approval for a specific NFT

@extension: ERC721

operator: the address of the operator to approve

tokenId: the token ID of the NFT to approve

returns: the transaction receipt of the approval

Example

operator := "{{wallet_address}}"
approved := "0x..."
tokenId := 0

tx, err := contract.ERC721.SetApprovalForToken(context.Background(), operator, approved, tokenId)

func (*ERC721) TotalClaimedSupply

func (erc721 *ERC721) TotalClaimedSupply(ctx context.Context) (int, error)

Get the number of claimed NFTs

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

Example

totalClaimed, err := contract.ERC721.TotalClaimedSupply(context.Background())

func (*ERC721) TotalSupply

func (erc721 *ERC721) TotalSupply(ctx context.Context) (int, error)

Get the total number of NFTs

@extension: ERC721

returns: the supply of NFTs on this contract

Example

supply, err := contract.ERC721.TotalSupply(context.Background)

func (*ERC721) TotalUnclaimedSupply

func (erc721 *ERC721) TotalUnclaimedSupply(ctx context.Context) (int, error)

Get the number of unclaimed NFTs

@extension: ERC721ClaimCustom | ERC721ClaimPhasesV2 | ERC721ClaimConditionsV2

Example

totalUnclaimed, err := contract.ERC721.TotalUnclaimedSupply(context.Background())

func (*ERC721) Transfer

func (erc721 *ERC721) Transfer(ctx context.Context, to string, tokenId int) (*types.Transaction, error)

Transfer an NFT

@extension: ERC721

to: wallet address to transfer the tokens to

tokenId: the token ID of the NFT to transfer

returns: the transaction of the NFT transfer

Example

to := "0x..."
tokenId := 0

tx, err := contract.ERC721.Transfer(context.Background(), to, tokenId)

type ERC721SignatureMinting

type ERC721SignatureMinting struct {
	Helper *contractHelper
	// contains filtered or unexported fields
}

You can access this interface from the NFT Collection contract under the signature interface.

func (*ERC721SignatureMinting) Generate

func (signature *ERC721SignatureMinting) Generate(ctx context.Context, payloadToSign *Signature721PayloadInput) (*SignedPayload721, error)

Generate a new payload from the given data

payloadToSign: the payload containing the data for the signature mint

returns: the payload signed by the minter's private key

Example

payload := &thirdweb.Signature721PayloadInput{
	To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6", // address to mint to
	Price:                0,                                            // cost of minting
	CurrencyAddress:      "0x0000000000000000000000000000000000000000", // currency to pay in order to mint
	MintStartTime:        0,                                            // time where minting is allowed to start (epoch seconds)
	MintEndTime:          100000000000000,                              // time when this signature expires (epoch seconds)
	PrimarySaleRecipient: "0x0000000000000000000000000000000000000000", // address to receive the primary sales of this mint
	Metadata: &thirdweb.NFTMetadataInput{																// metadata of the NFT to mint
 		Name:  "ERC721 Sigmint!",
	},
	RoyaltyRecipient: "0x0000000000000000000000000000000000000000",     // address to receive royalties of this mint
	RoyaltyBps:       0,                                                // royalty cut of this mint in basis points
}

signedPayload, err := contract.Signature.Generate(payload)

func (*ERC721SignatureMinting) GenerateBatch

func (signature *ERC721SignatureMinting) GenerateBatch(ctx context.Context, payloadsToSign []*Signature721PayloadInput) ([]*SignedPayload721, error)

Generate a batch of new payload from the given data

payloadToSign: the payloads containing the data for the signature mint

returns: the payloads signed by the minter's private key

Example

payload := []*thirdweb.Signature721PayloadInput{
	&thirdweb.Signature721PayloadInput{
		To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
		Price:                0,
		CurrencyAddress:      "0x0000000000000000000000000000000000000000",
		MintStartTime:        0,
		MintEndTime:          100000000000000,
		PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
		Metadata: &thirdweb.NFTMetadataInput{
 			Name:  "ERC721 Sigmint!",
 			Image: imageFile,
		},
		RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
		RoyaltyBps:       0,
	},
	&thirdweb.Signature721PayloadInput{
		To:                   "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
		Price:                0,
		CurrencyAddress:      "0x0000000000000000000000000000000000000000",
		MintStartTime:        0,
		MintEndTime:          100000000000000,
		PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
		Metadata: &thirdweb.NFTMetadataInput{
 			Name:  "ERC721 Sigmint!",
 			Image: imageFile,
		},
		RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
		RoyaltyBps:       0,
	},
}

signedPayload, err := contract.Signature.GenerateBatch(context.Background(), payload)

func (*ERC721SignatureMinting) GenerateBatchWithUris

func (signature *ERC721SignatureMinting) GenerateBatchWithUris(ctx context.Context, payloadsToSign []*Signature721PayloadInputWithUri) ([]*SignedPayload721, error)

func (*ERC721SignatureMinting) Mint deprecated

func (signature *ERC721SignatureMinting) Mint(ctx context.Context, signedPayload *SignedPayload721) (*types.Transaction, error)

Deprecated: use MintAndAwait

func (*ERC721SignatureMinting) MintAndAwait

func (signature *ERC721SignatureMinting) MintAndAwait(ctx context.Context, signedPayload *SignedPayload721) (*types.Transaction, error)

func (*ERC721SignatureMinting) MintBatch

func (signature *ERC721SignatureMinting) MintBatch(ctx context.Context, signedPayloads []*SignedPayload721) (*types.Transaction, error)

Mint a batch of token with the data in given payload.

signedPayload: the list of payloads signed by the minters private key being used to mint

returns: the transaction receipt of the batch mint

Example

// Learn more about how to craft multiple payloads in the GenerateBatch() function
signedPayloads, err := contract.Signature.GenerateBatch(payloads)
tx, err := contract.Signature.MintBatch(context.Background(), signedPayloads)

func (*ERC721SignatureMinting) MintWithOpts

func (signature *ERC721SignatureMinting) MintWithOpts(ctx context.Context, signedPayload *SignedPayload721, txOpts *bind.TransactOpts) (*types.Transaction, error)

func (*ERC721SignatureMinting) Verify

func (signature *ERC721SignatureMinting) Verify(ctx context.Context, signedPayload *SignedPayload721) (bool, error)

Verify that a signed payload is valid

signedPayload: the payload to verify

returns: true if the payload is valid, otherwise false.

Example

// Learn more about how to craft a payload in the Generate() function
signedPayload, err := contract.Signature.Generate(payload)
isValid, err := contract.Signature.Verify(signedPayload)

type ERC721Standard

type ERC721Standard struct {
	// contains filtered or unexported fields
}

This interface is currently support by the NFT Collection and NFT Drop contracts. You can access all of its functions through an NFT Collection or NFT Drop contract instance.

func (*ERC721Standard) Balance

func (erc721 *ERC721Standard) Balance(ctx context.Context) (int, error)

Get the NFT balance of the connected wallet.

returns: the number of NFTs on this contract owned by the connected wallet

func (*ERC721Standard) BalanceOf

func (erc721 *ERC721Standard) BalanceOf(ctx context.Context, address string) (int, error)

Get the NFT balance of a specific wallet.

address: the address of the wallet to get the NFT balance of

returns: the number of NFTs on this contract owned by the specified wallet

Example

address := "{{wallet_address}}"
balance, err := contract.BalanceOf(context.Background(), address)

func (*ERC721Standard) Burn

func (erc721 *ERC721Standard) Burn(ctx context.Context, tokenId int) (*types.Transaction, error)

Burn a specified NFT from the connected wallet.

tokenId: tokenID of the token to burn

returns: the transaction receipt of the burn

Example

tokenId := 0
tx, err := contract.Burn(context.Background(), tokenId)

func (*ERC721Standard) Get

func (erc721 *ERC721Standard) Get(ctx context.Context, tokenId int) (*NFTMetadataOwner, error)

Get metadata for a token.

tokenId: token ID of the token to get the metadata for

returns: the metadata for the NFT and its owner

Example

	nft, err := contract.Get(context.Background(), 0)
 owner := nft.Owner
	name := nft.Metadata.Name

func (*ERC721Standard) GetAll

func (erc721 *ERC721Standard) GetAll(ctx context.Context) ([]*NFTMetadataOwner, error)

Get the metadata of all the NFTs on this contract.

returns: the metadata of all the NFTs on this contract

Example

nfts, err := contract.GetAll(context.Background())
ownerOne := nfts[0].Owner
nameOne := nfts[0].Metadata.Name

func (*ERC721Standard) GetTotalCount

func (erc721 *ERC721Standard) GetTotalCount(ctx context.Context) (int, error)

Get the total number of NFTs on this contract.

returns: the total number of NFTs on this contract

func (*ERC721Standard) IsApproved

func (erc721 *ERC721Standard) IsApproved(ctx context.Context, address string, operator string) (bool, error)

Check whether an operator address is approved for all operations of a specifc addresses assets.

address: the address whose assets are to be checked

operator: the address of the operator to check

returns: true if the operator is approved for all operations of the assets, otherwise false

func (*ERC721Standard) OwnerOf

func (erc721 *ERC721Standard) OwnerOf(ctx context.Context, tokenId int) (string, error)

Get the owner of an NFT.

tokenId: the token ID of the NFT to get the owner of

returns: the owner of the NFT

func (*ERC721Standard) SetApprovalForAll

func (erc721 *ERC721Standard) SetApprovalForAll(ctx context.Context, operator string, approved bool) (*types.Transaction, error)

Set the approval for all operations of a specific address's assets.

address: the address whose assets are to be approved

operator: the address of the operator to set the approval for

approved: true if the operator is approved for all operations of the assets, otherwise false

returns: the transaction receipt of the approval

func (*ERC721Standard) SetApprovalForToken

func (erc721 *ERC721Standard) SetApprovalForToken(ctx context.Context, operator string, tokenId int) (*types.Transaction, error)

Approve an operator for the NFT owner, which allows the operator to call transferFrom or safeTransferFrom for the specified token.

operator: the address of the operator to approve

tokenId: the token ID of the NFT to approve

returns: the transaction receipt of the approval

func (*ERC721Standard) TotalSupply

func (erc721 *ERC721Standard) TotalSupply(ctx context.Context) (int, error)

Get the total number of NFTs on this contract.

returns: the supply of NFTs on this contract

func (*ERC721Standard) Transfer

func (erc721 *ERC721Standard) Transfer(ctx context.Context, to string, tokenId int) (*types.Transaction, error)

Transfer a specified token from the connected wallet to a specified address.

to: wallet address to transfer the tokens to

tokenId: the token ID of the NFT to transfer

returns: the transaction of the NFT transfer

Example

to := "0x..."
tokenId := 0

tx, err := contract.Transfer(context.Background(), to, tokenId)

type Edition

type Edition struct {
	*ERC1155Standard

	Helper    *contractHelper
	Signature *ERC1155SignatureMinting
	Encoder   *ContractEncoder
	Events    *ContractEvents
	// contains filtered or unexported fields
}

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

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

privateKey = "..."

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

contract, err := sdk.GetEdition("{{contract_address}}")

func (*Edition) Mint

func (edition *Edition) Mint(ctx context.Context, metadataWithSupply *EditionMetadataInput) (*types.Transaction, error)

Mint an NFT to the connected wallet.

metadataWithSupply: nft metadata with supply of the NFT to mint

returns: the transaction receipt of the mint

func (*Edition) MintAdditionalSupply

func (edition *Edition) MintAdditionalSupply(ctx context.Context, tokenId int, additionalSupply int) (*types.Transaction, error)

Mint additionaly supply of a token to the connected wallet.

tokenId: token ID to mint additional supply of

additionalSupply: additional supply to mint

returns: the transaction receipt of the mint

func (*Edition) MintAdditionalSupplyTo

func (edition *Edition) MintAdditionalSupplyTo(ctx context.Context, to string, tokenId int, additionalSupply int) (*types.Transaction, error)

Mint additional supply of a token to the specified wallet.

to: address of the wallet to mint NFTs to

tokenId: token Id to mint additional supply of

additionalySupply: additional supply to mint

returns: the transaction receipt of the mint

func (*Edition) MintAdditionalSupplyToWithEIP1559TipSelection added in v2.3.0

func (edition *Edition) MintAdditionalSupplyToWithEIP1559TipSelection(ctx context.Context, to string, tokenId int, additionalSupply int, tipname string) (*types.Transaction, error)

func (*Edition) MintBatch

func (edition *Edition) MintBatch(ctx context.Context, metadatasWithSupply []*EditionMetadataInput) (*types.Transaction, error)

Mint a batch of NFTs to the connected wallet.

metadatasWithSupply: list of NFT metadatas with supplies to mint

returns: the transaction receipt of the mint

func (*Edition) MintBatchTo

func (edition *Edition) MintBatchTo(ctx context.Context, to string, metadatasWithSupply []*EditionMetadataInput) (*types.Transaction, error)

Mint a batch of NFTs to a specific wallet.

to: address of the wallet to mint NFTs to

metadatasWithSupply: list of NFT metadatas with supplies to mint

returns: the transaction receipt of the mint

Example

metadatasWithSupply := []*thirdweb.EditionMetadataInput{
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
		},
		Supply: 100,
	},
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
		},
		Supply: 100,
	},
}

tx, err := contract.MintBatchTo(context.Background(), "{{wallet_address}}", metadatasWithSupply)

func (*Edition) MintTo

func (edition *Edition) MintTo(ctx context.Context, address string, metadataWithSupply *EditionMetadataInput) (*types.Transaction, error)

Mint a new NFT to the specified wallet.

address: the wallet address to mint the NFT to

metadataWithSupply: nft metadata with supply of the NFT to mint

returns: the transaction receipt of the mint

Example

	image, err := os.Open("path/to/image.jpg")
	defer image.Close()

	metadataWithSupply := &thirdweb.EditionMetadataInput{
        context.Background(),
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
			Image: image,
		},
		Supply: 100,
	}

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

type EditionDrop

type EditionDrop struct {
	*ERC1155Standard

	Helper          *contractHelper
	ClaimConditions *EditionDropClaimConditions
	Encoder         *ContractEncoder
	Events          *ContractEvents
	// contains filtered or unexported fields
}

You can access the Edition Drop interface from the SDK as follows:

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

privateKey = "..."

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

contract, err := sdk.GetEditionDrop("{{contract_address}}")

func (*EditionDrop) Claim

func (drop *EditionDrop) Claim(ctx context.Context, tokenId int, quantity int) (*types.Transaction, error)

Claim NFTs from this contract to the connect wallet.

tokenId: the token ID of the NFT to claim

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

func (*EditionDrop) ClaimTo

func (drop *EditionDrop) ClaimTo(ctx context.Context, destinationAddress string, tokenId int, quantity int) (*types.Transaction, error)

Claim NFTs from this contract to the connect wallet.

tokenId: the token ID of the NFT to claim

destinationAddress: the address of the wallet to claim the NFTs to

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

address = "{{wallet_address}}"
tokenId = 0
quantity = 1

tx, err := contract.ClaimTo(context.Background(), address, tokenId, quantity)

func (*EditionDrop) CreateBatch

func (drop *EditionDrop) CreateBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Create a batch of NFTs on this contract.

metadatas: a list of the metadatas of the NFTs to create

returns: the transaction receipt of the batch creation

Example

image0, err := os.Open("path/to/image/0.jpg")
defer image0.Close()

image1, err := os.Open("path/to/image/1.jpg")
defer image1.Close()

metadatasWithSupply := []*thirdweb.EditionMetadataInput{
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
			Image: image0,
		},
		Supply: 100,
	},
	&thirdweb.EditionMetadataInput{
		Metadata: &thirdweb.NFTMetadataInput{
			Name: "Cool NFT",
			Description: "This is a cool NFT",
			Image: image1,
		},
		Supply: 100,
	},
}

tx, err := contract.MintBatchTo(context.Background(), "{{wallet_address}}", metadatasWithSupply)

type EditionDropClaimConditions

type EditionDropClaimConditions struct {
	// contains filtered or unexported fields
}

This interface is currently accessible from the Edition Drop contract contract type via the ClaimConditions property.

func (*EditionDropClaimConditions) GetActive

func (claim *EditionDropClaimConditions) GetActive(ctx context.Context, tokenId int) (*ClaimConditionOutput, error)

Get the currently active claim condition for a given token

tokenId: the token ID of the token to get the active claim condition for

returns: the currently active claim condition metadata

Example

tokenId := 0
condition, err := contract.ClaimConditions.GetActive(context.Background(), tokenId)

// Now you have access to all the claim condition metadata
fmt.Println("Start Time:", condition.StartTime)
fmt.Println("Available:", condition.AvailableSupply)
fmt.Println("Quantity:", condition.MaxQuantity)
fmt.Println("Quantity Limit:", condition.QuantityLimitPerTransaction)
fmt.Println("Price:", condition.Price)
fmt.Println("Wait In Seconds", condition.WaitInSeconds)

func (*EditionDropClaimConditions) GetAll

func (claim *EditionDropClaimConditions) GetAll(ctx context.Context, tokenId int) ([]*ClaimConditionOutput, error)

Get all claim conditions on this contract for a given token

tokenId: the token ID of the token to get the claim conditions for

returns: the metadata for all the claim conditions on this contract

Example

tokenId := 0
conditions, err := contract.ClaimConditions.GetAll(context.Background(), tokenId)

// Now you have access to all the claim condition metadata
condition := conditions[0]
fmt.Println("Start Time:", condition.StartTime)
fmt.Println("Available:", condition.AvailableSupply)
fmt.Println("Quantity:", condition.MaxQuantity)
fmt.Println("Quantity Limit:", condition.QuantityLimitPerTransaction)
fmt.Println("Price:", condition.Price)
fmt.Println("Wait In Seconds", condition.WaitInSeconds)

func (*EditionDropClaimConditions) GetMerkleMetadata

func (claim *EditionDropClaimConditions) GetMerkleMetadata(ctx context.Context) (*map[string]string, error)

type EditionMetadata

type EditionMetadata struct {
	Metadata *NFTMetadata
	Supply   int
}

type EditionMetadataInput

type EditionMetadataInput struct {
	Metadata *NFTMetadataInput
	Supply   int
}

type EditionMetadataOwner

type EditionMetadataOwner struct {
	Metadata      *NFTMetadata
	Supply        int
	Owner         string
	QuantityOwned int
}

type EditionResult

type EditionResult struct {
	// contains filtered or unexported fields
}

type EventQueryOptions

type EventQueryOptions struct {
	FromBlock uint64
	ToBlock   *uint64
	Filters   map[string]interface{}
}

type EventSubscription

type EventSubscription struct {
	Err         func() <-chan error
	Unsubscribe func()
}

type IpfsStorage

type IpfsStorage struct {
	// contains filtered or unexported fields
}

func (*IpfsStorage) Get

func (ipfs *IpfsStorage) Get(ctx context.Context, uri string) ([]byte, error)

Get

Get IPFS data at a given hash and return it as byte data

uri: the IPFS URI to fetch data from

returns: byte data of the IPFS data at the URI

func (*IpfsStorage) Upload

func (ipfs *IpfsStorage) Upload(ctx context.Context, data map[string]interface{}, contractAddress string, signerAddress string) (string, error)

Upload

Upload method can be used to upload a generic payload to IPFS.

data: the individual data to upload to IPFS

contractAddress: the optional contractAddress upload is being called from

signerAddress: the optional signerAddress upload is being called from

returns: the URI of the IPFS upload

func (*IpfsStorage) UploadBatch

func (ipfs *IpfsStorage) UploadBatch(ctx context.Context, data []map[string]interface{}, fileStartNumber int, contractAddress string, signerAddress string) (*baseUriWithUris, error)

UploadBatch

UploadBatch method can be used to upload a batch of generic payloads to IPFS.

data: the array of data to upload to IPFS

contractAddress: the optional contractAddress upload is being called from

signerAddress: the optional signerAddress upload is being called from

returns: the base URI of the IPFS upload folder with the URIs of each subfile

type Marketplace

type Marketplace struct {
	Abi     *abi.Marketplace
	Helper  *contractHelper
	Encoder *MarketplaceEncoder
	Events  *ContractEvents
	// contains filtered or unexported fields
}

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

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

privateKey = "..."

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

contract, err := sdk.GetMarketplace("{{contract_address}}")

func (*Marketplace) BuyoutListing

func (marketplace *Marketplace) BuyoutListing(ctx context.Context, listingId int, quantityDesired int) (*types.Transaction, error)

Buy a specific listing from the marketplace.

listingId: listing ID of the asset you want to buy

quantityDesired: the quantity of the asset to buy from the listing

returns: transaction receipt of the purchase

func (*Marketplace) BuyoutListingTo

func (marketplace *Marketplace) BuyoutListingTo(ctx context.Context, listingId int, quantityDesired int, receiver string) (*types.Transaction, error)

Buy a specific listing from the marketplace to a specific address.

listingId: listing ID of the asset you want to buy

quantityDesired: the quantity of the asset to buy from the listing

receiver: specific address to receive the assets from the listing

returns: transaction receipt of the purchase

Example

listingId := 0
quantityDesired := 1
receiver := "0x..."
receipt, err := marketplace.BuyoutListingTo(context.Background(), listingId, quantityDesired, receiver)

func (*Marketplace) CancelListing

func (marketplace *Marketplace) CancelListing(ctx context.Context, listingId int) (*types.Transaction, error)

Cancel a listing on the marketplace.

listingId: listing ID to cancel

returns: transaction receipt of the cancellation

Example

listingId := 0
receipt, err := marketplace.CancelListing(context.Background(), listingId)

func (*Marketplace) CreateListing

func (marketplace *Marketplace) CreateListing(ctx context.Context, listing *NewDirectListing) (int, error)

Create a new listing on the marketplace where people can buy an asset directly.

listing: the data for the listing to create

returns: the ID of the listing that was created

Example

listing := &NewDirectListing{
	AssetContractAddress: "0x...", // Address of the asset contract
	TokenId: 0, // Token ID of the asset to list
	StartTimeInEpochSeconds: int(time.Now().Unix()), // Defaults to current time
	ListingDurationInSeconds: int(time.Now().Unix() + 3600), // Defaults to current time + 1 hour
	Quantity: 1, // Quantity of the asset to list
	CurrencyContractAddress: "0x...", // Contract address of currency to sell for, defaults to native token
	BuyoutPricePerToken: 1, // Price per token of the asset to list
}

listingId, err := marketplace.CreateListing(context.Background(), listing)

func (*Marketplace) GetActiveListings

func (marketplace *Marketplace) GetActiveListings(ctx context.Context, filter *MarketplaceFilter) ([]*DirectListing, error)

Get all active listings from the marketplace.

filter: optional filter parameters

returns: all active listings in the marketplace

Example

listings, err := marketplace.GetActiveListings(context.Background(), nil)
// Price per token of the first listing
listings[0].BuyoutCurrencyValuePerToken.DisplayValue

func (*Marketplace) GetAllListings

func (marketplace *Marketplace) GetAllListings(ctx context.Context, filter *MarketplaceFilter) ([]*DirectListing, error)

Get all the listings from the marketplace.

filter: optional filter parameters

returns: all listings in the marketplace

Example

listings, err := marketplace.GetAllListings(context.Background(), nil)
// Price per token of the first listing
listings[0].BuyoutCurrencyValuePerToken.DisplayValue

func (*Marketplace) GetListing

func (marketplace *Marketplace) GetListing(ctx context.Context, listingId int) (*DirectListing, error)

Get a single listing from the marketplace.

listingId: listing ID to get

returns: listing at the given listing ID

Example

listingId := 0
listing, err := marketplace.GetListing(context.Background(), listingId)

func (*Marketplace) GetTotalCount

func (marketplace *Marketplace) GetTotalCount(ctx context.Context) (int, error)

Get the total number of listings in the marketplace.

returns: total number of listings in the marketplace

type MarketplaceEncoder

type MarketplaceEncoder struct {
	*ContractEncoder
	// contains filtered or unexported fields
}

The marketplace encoder class is used to get the unsigned transaction data for marketplace contract contract calls that can be signed at a later time after generation.

It can be accessed from the SDK through the `Encoder` namespace of the marketplace contract:

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

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

	privateKey = "..."

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

	marketplace, err := sdk.GetMarketplace("{{contract_address}}")

	// Now the encoder can be accessed from the contract
 marketplace.Encoder.CreateListing(...)

func (*MarketplaceEncoder) ApproveBuyoutListing

func (encoder *MarketplaceEncoder) ApproveBuyoutListing(
	ctx context.Context,
	signerAddress string,
	listingId int,
	quantityDesired int,
	receiver string,
) (*types.Transaction, error)

Get the transaction data to approve the tokens needed for a buyout listing transaction. If the transaction wouldn't require any additional token approvals, this method will return nil.

signerAddress: the address intended to sign the transaction

listingId: the ID of the listing to buyout

quantityDesired: the quantity of the listed tokens to purchase

receiver: the address to receive the purchased tokens

returns: the transaction data for the token approval if an approval is needed, or nil

Example

// Address of the wallet we expect to sign this message
signerAddress := "0x..."
// ID of the listing to buyout
listingId := 1
// Quantity of the listed tokens to purchase
quantityDesired := 1
// receiver address to receive the purchased tokens
receiver := "0x..."

// Transaction data required for this request
tx, err := marketplace.Encoder.ApproveBuyoutListing(context.Background(), signerAddress, listingId, quantityDesired, receiver)

// Now you can get transaction all the standard data as needed
fmt.Println(tx.Data()) // Ex: get the data field or the nonce field (others are available)
fmt.Println(tx.Nonce())

func (*MarketplaceEncoder) ApproveCreateListing

func (encoder *MarketplaceEncoder) ApproveCreateListing(ctx context.Context, signerAddress string, listing *NewDirectListing) (*types.Transaction, error)

Get the transaction data to approve the tokens needed for a create liting transaction. If the transaction wouldn't require any additional token approvals, this method will return nil.

signerAddress: the address intended to sign the transaction

listing: the parameters for the new direct listing to create

returns: the transaction data for the create listing transaction

Example

// Address of the wallet we expect to sign this message
signerAddress := "0x..."

listing := &NewDirectListing{
	AssetContractAddress: "0x...", // Address of the asset contract
	TokenId: 0, // Token ID of the asset to list
	StartTimeInEpochSeconds: int(time.Now().Unix()), // Defaults to current time
	ListingDurationInSeconds: int(time.Now().Unix() + 3600), // Defaults to current time + 1 hour
	Quantity: 1, // Quantity of the asset to list
	CurrencyContractAddress: "0x...", // Contract address of currency to sell for, defaults to native token
	BuyoutPricePerToken: 1, // Price per token of the asset to list
}

// Transaction data required for this request
tx, err := marketplace.Encoder.ApproveCreateListing(context.Background(), signerAddress, listing)

// Now you can get transaction data as needed
fmt.Println(tx.Data()) // Ex: get the data field or the nonce field (others are available)
fmt.Println(tx.Nonce())

func (*MarketplaceEncoder) BuyoutListing

func (encoder *MarketplaceEncoder) BuyoutListing(
	ctx context.Context,
	signerAddress string,
	listingId int,
	quantityDesired int,
	receiver string,
) (*types.Transaction, error)

Get the transaction data for the buyout listing transaction. This method will throw an error if the listing requires payment in ERC20 tokens and the ERC20 tokens haven't yet been approved by the spender. You can get the transaction data of this required approval transaction from the `ApproveBuyoutListing` method.

signerAddress: the address intended to sign the transaction

listingId: the ID of the listing to buyout

quantityDesired: the quantity of the listed tokens to purchase

receiver: the address to receive the purchased tokens

returns: the transaction data for this purchase

Example

// Address of the wallet we expect to sign this message
signerAddress := "0x..."
// ID of the listing to buyout
listingId := 1
// Quantity of the listed tokens to purchase
quantityDesired := 1
// receiver address to receive the purchased tokens
receiver := "0x..."

// Transaction data required for this request
tx, err := marketplace.Encoder.BuyoutListing(context.Background(), signerAddress, listingId, quantityDesired, receiver)

// Now you can get transaction all the standard data as needed
fmt.Println(tx.Data()) // Ex: get the data field or the nonce field (others are available)
fmt.Println(tx.Nonce())

func (*MarketplaceEncoder) CancelListing

func (encoder *MarketplaceEncoder) CancelListing(ctx context.Context, signerAddress string, listingId int) (*types.Transaction, error)

Get the data for the transaction required to cancel a listing on the marketplace

signerAddress: the address intended to sign the transaction

listingId: the ID of the listing to cancel

returns: the transaction data for the cancellation

Example

// Address of the wallet we expect to sign this message
signerAddress := "0x..."
// ID of the listing to cancel
listingId := 1

// Transaction data required for this request
tx, err := marketplace.Encoder.CancelListing(context.Background(), signerAddress, listingId)

// Now you can get transaction all the standard data as needed
fmt.Println(tx.Data()) // Ex: get the data field or the nonce field (others are available)
fmt.Println(tx.Nonce())

func (*MarketplaceEncoder) CreateListing

func (encoder *MarketplaceEncoder) CreateListing(ctx context.Context, signerAddress string, listing *NewDirectListing) (*types.Transaction, error)

Get the data for the transaction required to create a direct listing. This method will throw an error if the tokens needed for the listing have not yet been approved by the asset owner for the marketplace to spend. You can get the transaction data of this required approval transaction from the `ApproveCreateListing` method.

signerAddress: the address intended to sign the transaction

listing: the parameters for the new direct listing to create

returns: the transaction data for the create listing transaction

Example

// Address of the wallet we expect to sign this message
signerAddress := "0x..."

listing := &NewDirectListing{
	AssetContractAddress: "0x...", // Address of the asset contract
	TokenId: 0, // Token ID of the asset to list
	StartTimeInEpochSeconds: int(time.Now().Unix()), // Defaults to current time
	ListingDurationInSeconds: int(time.Now().Unix() + 3600), // Defaults to current time + 1 hour
	Quantity: 1, // Quantity of the asset to list
	CurrencyContractAddress: "0x...", // Contract address of currency to sell for, defaults to native token
	BuyoutPricePerToken: 1, // Price per token of the asset to list
}

// Transaction data required for this request
tx, err := marketplace.Encoder.CreateListing(context.Background(), signerAddress, listing)

// Now you can get transaction data as needed
fmt.Println(tx.Data()) // Ex: get the data field or the nonce field (others are available)
fmt.Println(tx.Nonce())

type MarketplaceFilter

type MarketplaceFilter struct {
	Start         int
	Count         int
	Seller        string
	TokenContract string
}

type MerkleContent

type MerkleContent struct {
	// contains filtered or unexported fields
}

func (MerkleContent) CalculateHash

func (t MerkleContent) CalculateHash() ([]byte, error)

func (MerkleContent) Equals

func (t MerkleContent) Equals(other merkletree.Content) (bool, error)

type MerkleNode

type MerkleNode struct {
	// contains filtered or unexported fields
}

func (*MerkleNode) Serialize

func (t *MerkleNode) Serialize() ([]byte, error)

type Metadata

type Metadata struct {
	MetadataUri    string
	MetadataObject interface{}
}

type Multiwrap

type Multiwrap struct {
	*ERC721Standard

	Helper  *contractHelper
	Encoder *ContractEncoder
	// contains filtered or unexported fields
}

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

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

privateKey = "..."

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

contract, err := sdk.GetMultiwrap("{{contract_address}}")

func (*Multiwrap) GetWrappedContents

func (multiwrap *Multiwrap) GetWrappedContents(wrappedTokenId int) (*MultiwrapBundle, error)

Get the contents of a wrapped token bundle.

wrappedTokenId: the ID of the wrapped token bundle

returns: the contents of the wrapped token bundle

Example

tokenId := 0
contents, err := contract.GetWrappedContents(tokenId)
erc20Tokens := contents.Erc20Tokens
erc721Tokens := contents.Erc721Tokens
erc1155Tokens := contents.Erc1155Tokens

func (*Multiwrap) Unwrap

func (multiwrap *Multiwrap) Unwrap(ctx context.Context, wrappedTokenId int, recipientAddress string) (*types.Transaction, error)

Unwrap a wrapped token bundle into its contents

wrappedTokenId: the ID of the wrapped token bundle

recipientAddress: the optional address to send the wrapped token to

returns: the contents of the wrapped token bundle

Example

tokenId := 0
tx, err := contract.Unwrap(context.Background(), tokenId, "")

func (*Multiwrap) Wrap

func (multiwrap *Multiwrap) Wrap(ctx context.Context, contents *MultiwrapBundle, wrappedTokenMetadata interface{}, recipientAddress string) (*types.Transaction, error)

Wrap any number of ERC20, ERC721, or ERC1155 tokens into a single wrapped token

contents: the tokens to wrap into a single wrapped token

wrappedTokenMetadata: the NFT Metadata or URI to as the metadata for the wrapped token

recipientAddress: the optional address to send the wrapped token to

returns: the transaction receipt of the wrapping

Example

contents := &thirdweb.MultiwrapBundle{
	ERC20Tokens: []*thirdweb.MultiwrapERC20{
		&thirdweb.MultiwrapERC20{
			ContractAddress: "0x...",
			Quantity:        1,
		},
	},
	ERC721Tokens: []*thirdweb.MultiwrapERC721{
		&thirdweb.MultiwrapERC721{
			ContractAddress: "0x...",
			TokenId:         1,
		},
	},
	ERC1155Tokens: []*thirdweb.MultiwrapERC1155{
		&thirdweb.MultiwrapERC1155{
			ContractAddress: "0x...",
			TokenId:         1,
			Quantity:        1,
		},
	},
}

wrappedTokenMetadata := &thirdweb.NFTMetadataInput{
	Name: "Wrapped Token"
}

// This will mint the wrapped token to the connected wallet
tx, err := contract.Wrap(context.Background(), contents, wrappedTokenMetadata, "")

type MultiwrapBundle

type MultiwrapBundle struct {
	ERC20Tokens   []*MultiwrapERC20
	ERC721Tokens  []*MultiwrapERC721
	ERC1155Tokens []*MultiwrapERC1155
}

type MultiwrapERC1155

type MultiwrapERC1155 struct {
	ContractAddress string
	TokenId         int
	Quantity        int
}

type MultiwrapERC20

type MultiwrapERC20 struct {
	ContractAddress string
	Quantity        float64
}

type MultiwrapERC721

type MultiwrapERC721 struct {
	ContractAddress string
	TokenId         int
}

type NFTCollection

type NFTCollection struct {
	*ERC721Standard

	Helper    *contractHelper
	Signature *ERC721SignatureMinting
	Encoder   *ContractEncoder
	Events    *ContractEvents
	// contains filtered or unexported fields
}

You can access the NFT Collection interface from the SDK as follows:

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

privateKey = "..."

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

contract, err := sdk.GetNFTCollection("{{contract_address}}")

func (*NFTCollection) GetOwned

func (nft *NFTCollection) GetOwned(ctx context.Context, address string) ([]*NFTMetadataOwner, error)

Get the metadatas of all the NFTs owned by a specific address.

address: the address of the owner of the NFTs

returns: the metadata of all the NFTs owned by the address

Example

owner := "{{wallet_address}}"
nfts, err := contract.GetOwned(context.Background(), owner)
name := nfts[0].Metadata.Name

func (*NFTCollection) GetOwnedTokenIDs

func (nft *NFTCollection) GetOwnedTokenIDs(ctx context.Context, address string) ([]*big.Int, error)

Get the tokenIds of all the NFTs owned by a specific address.

address: the address of the owner of the NFTs

returns: the tokenIds of all the NFTs owned by the address

func (*NFTCollection) Mint

func (nft *NFTCollection) Mint(ctx context.Context, metadata *NFTMetadataInput) (*types.Transaction, error)

Mint a new NFT to the connected wallet.

metadata: metadata of the NFT to mint

returns: the transaction receipt of the mint

func (*NFTCollection) MintBatch

func (nft *NFTCollection) MintBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Mint a batch of new NFTs to the connected wallet.

metadatas: list of metadata of the NFTs to mint

returns: the transaction receipt of the mint

func (*NFTCollection) MintBatchTo

func (nft *NFTCollection) MintBatchTo(ctx context.Context, address string, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Mint a batch of new NFTs to the specified wallet.

to: the wallet address to mint to

metadatas: list of metadata of the NFTs to mint

returns: the transaction receipt of the mint

Example

metadatas := []*thirdweb.NFTMetadataInput{
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT",
		Description: "This is a cool NFT",
	}
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT 2",
		Description: "This is also a cool NFT",
	}
}

tx, err := contract.MintBatchTo(context.Background(), "{{wallet_address}}", metadatas)

func (*NFTCollection) MintTo

func (nft *NFTCollection) MintTo(ctx context.Context, address string, metadata *NFTMetadataInput) (*types.Transaction, error)

Mint a new NFT to the specified wallet.

address: the wallet address to mint to

metadata: metadata of the NFT to mint

returns: the transaction receipt of the mint

Example

image, err := os.Open("path/to/image.jpg")
defer image.Close()

metadata := &thirdweb.NFTMetadataInput{
	Name: "Cool NFT",
	Description: "This is a cool NFT",
	Image: image,
}

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

type NFTDrop

type NFTDrop struct {
	*ERC721Standard
	Abi             *abi.DropERC721
	Helper          *contractHelper
	ClaimConditions *NFTDropClaimConditions
	Encoder         *NFTDropEncoder
	Events          *ContractEvents
}

You can access the NFT Drop interface from the SDK as follows:

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

privateKey = "..."

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

contract, err := sdk.GetNFTDrop("{{contract_address}}")

func (*NFTDrop) Claim

func (drop *NFTDrop) Claim(ctx context.Context, quantity int) (*types.Transaction, error)

Claim NFTs from this contract to the connect wallet.

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

func (*NFTDrop) ClaimTo

func (drop *NFTDrop) ClaimTo(ctx context.Context, destinationAddress string, quantity int) (*types.Transaction, error)

Claim NFTs from this contract to the connect wallet.

destinationAddress: the address of the wallet to claim the NFTs to

quantity: the number of NFTs to claim

returns: the transaction receipt of the claim

Example

address := "{{wallet_address}}"
quantity = 1

tx, err := contract.ClaimTo(context.Background(), address, quantity)

func (*NFTDrop) CreateBatch

func (drop *NFTDrop) CreateBatch(ctx context.Context, metadatas []*NFTMetadataInput) (*types.Transaction, error)

Create a batch of NFTs on this contract.

metadatas: a list of the metadatas of the NFTs to create

returns: the transaction receipt of the batch creation

Example

image0, err := os.Open("path/to/image/0.jpg")
defer image0.Close()

image1, err := os.Open("path/to/image/1.jpg")
defer image1.Close()

metadatas := []*thirdweb.NFTMetadataInput{
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT",
		Description: "This is a cool NFT",
		Image: image1
	}
	&thirdweb.NFTMetadataInput{
		Name: "Cool NFT 2",
		Description: "This is also a cool NFT",
		Image: image2
	}
}

tx, err := contract.CreateBatch(context.Background(), metadatas)

func (*NFTDrop) GetAllClaimed

func (drop *NFTDrop) GetAllClaimed(ctx context.Context) ([]*NFTMetadataOwner, error)

Get a list of all the NFTs that have been claimed from this contract.

returns: a list of the metadatas of the claimed NFTs

Example

claimedNfts, err := contract.GetAllClaimed(context.Background())
firstOwner := claimedNfts[0].Owner

func (*NFTDrop) GetAllUnclaimed

func (drop *NFTDrop) GetAllUnclaimed(ctx context.Context) ([]*NFTMetadata, error)

Get a list of all the NFTs on this contract that have not yet been claimed.

returns: a list of the metadatas of the unclaimed NFTs

Example

unclaimedNfts, err := contract.GetAllUnclaimed(context.Background())
firstNftName := unclaimedNfts[0].Name

func (*NFTDrop) GetClaimArguments

func (drop *NFTDrop) GetClaimArguments(
	ctx context.Context,
	destinationAddress string,
	quantity int,
) (
	*ClaimArguments,
	error,
)

func (*NFTDrop) GetClaimIneligibilityReasons

func (drop *NFTDrop) GetClaimIneligibilityReasons(ctx context.Context, quantity int, addressToCheck string) ([]ClaimEligibility, error)

func (*NFTDrop) GetClaimInfo

func (drop *NFTDrop) GetClaimInfo(ctx context.Context, address string) (*ClaimInfo, error)

func (*NFTDrop) GetOwned

func (nft *NFTDrop) GetOwned(ctx context.Context, address string) ([]*NFTMetadataOwner, error)

Get the metadatas of all the NFTs owned by a specific address.

address: the address of the owner of the NFTs

returns: the metadata of all the NFTs owned by the address

Example

owner := "{{wallet_address}}"
nfts, err := contract.GetOwned(context.Background(), owner)
name := nfts[0].Metadata.Name

func (*NFTDrop) GetOwnedTokenIDs

func (nft *NFTDrop) GetOwnedTokenIDs(ctx context.Context, address string) ([]*big.Int, error)

Get the tokenIds of all the NFTs owned by a specific address.

address: the address of the owner of the NFTs

returns: the tokenIds of all the NFTs owned by the address

func (*NFTDrop) GetTotalClaimed

func (drop *NFTDrop) GetTotalClaimed(ctx context.Context, address string) (*big.Int, error)

func (*NFTDrop) TotalClaimedSupply

func (drop *NFTDrop) TotalClaimedSupply(ctx context.Context) (int, error)

Get the total number of NFTs that have been claimed.

func (*NFTDrop) TotalUnclaimedSupply

func (drop *NFTDrop) TotalUnclaimedSupply(ctx context.Context) (int, error)

Get the total number of NFTs that have not yet been claimed.

type NFTDropClaimConditions

type NFTDropClaimConditions struct {
	// contains filtered or unexported fields
}

This interface is currently accessible from the NFT Drop contract contract type via the ClaimConditions property.

func (*NFTDropClaimConditions) Get

func (claim *NFTDropClaimConditions) Get(ctx context.Context, claimConditionId int) (*ClaimConditionOutput, error)

func (*NFTDropClaimConditions) GetActive

Get the currently active claim condition

returns: the currently active claim condition metadata

Example

condition, err := contract.ClaimConditions.GetActive()

// Now you have access to all the claim condition metadata
fmt.Println("Start Time:", condition.StartTime)
fmt.Println("Available:", condition.AvailableSupply)
fmt.Println("Quantity:", condition.MaxQuantity)
fmt.Println("Quantity Limit:", condition.QuantityLimitPerTransaction)
fmt.Println("Price:", condition.Price)
fmt.Println("Wait In Seconds", condition.WaitInSeconds)

func (*NFTDropClaimConditions) GetAll

Get all claim conditions on this contract

returns: the metadata for all the claim conditions on this contract

Example

conditions, err := contract.ClaimConditions.GetAll()

// Now you have access to all the claim condition metadata
condition := conditions[0]
fmt.Println("Start Time:", condition.StartTime)
fmt.Println("Available:", condition.AvailableSupply)
fmt.Println("Quantity:", condition.MaxQuantity)
fmt.Println("Quantity Limit:", condition.QuantityLimitPerTransaction)
fmt.Println("Price:", condition.Price)
fmt.Println("Wait In Seconds", condition.WaitInSeconds)

func (*NFTDropClaimConditions) GetClaimerProofs

func (claim *NFTDropClaimConditions) GetClaimerProofs(
	ctx context.Context,
	claimerAddress string,
) (*SnapshotEntryWithProof, error)

type NFTDropEncoder

type NFTDropEncoder struct {
	*ContractEncoder
	// contains filtered or unexported fields
}

The nft drop encoder class is used to get the unsigned transaction data for nft drop contract contract calls that can be signed at a later time after generation.

It can be accessed from the SDK through the `Encoder` namespace of the nft drop contract:

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

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

privateKey = "..."

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

contract, err := sdk.GetNFTDrop("{{contract_address}}")

// Now the encoder can be accessed from the contract
contract.Encoder.ClaimTo(...)

func (*NFTDropEncoder) ApproveClaimTo

func (encoder *NFTDropEncoder) ApproveClaimTo(ctx context.Context, signerAddress string, quantity int) (*types.Transaction, error)

Get the data for the transaction data required to approve the ERC20 token transfers necessary to claim NFTs from this contract.

signerAddress: the address intended to sign the transaction

destinationAddress: the address of the wallet to claim the NFTs to

quantity: the number of NFTs to claim

returns: the transaction data of the token approval for the claim

Example

// Address of the wallet we expect to sign this message
signerAddress := "0x..."
// Number of NFTs to claim
quantity = 1

tx, err := contract.Encoder.ApproveClaimTo(context.Background(), signerAddress, quantity)

// Now you can get all the standard transaction data as needed
fmt.Println(tx.Data()) // Ex: get the data field or the nonce field (others are available)
fmt.Println(tx.Nonce())

func (*NFTDropEncoder) ClaimTo

func (encoder *NFTDropEncoder) ClaimTo(ctx context.Context, signerAddress string, destinationAddress string, quantity int) (*types.Transaction, error)

Get the data for the transaction required to claim NFTs from this contract.

signerAddress: the address intended to sign the transaction

destinationAddress: the address of the wallet to claim the NFTs to

quantity: the number of NFTs to claim

returns: the transaction data of the claim

Example

// Address of the wallet we expect to sign this message
signerAddress := "0x..."
// Address of the wallet we want to claim the NFTs to
destinationAddress := "{{wallet_address}}"
// Number of NFTs to claim
quantity = 1

tx, err := contract.Encoder.ClaimTo(context.Background(), signerAddress, destinationAddress, quantity)

// Now you can get all the standard transaction data as needed
fmt.Println(tx.Data()) // Ex: get the data field or the nonce field (others are available)
fmt.Println(tx.Nonce())

type NFTMetadata

type NFTMetadata struct {
	Id              *big.Int    `json:"id"`
	Uri             string      `json:"uri"`
	Name            string      `json:"name"`
	Description     string      `json:"description"`
	Image           interface{} `json:"image"`
	ExternalUrl     string      `json:"external_url"`
	AnimationUrl    string      `json:"animation_url"`
	BackgroundColor string      `json:"background_color"`
	Properties      interface{} `json:"properties,omitempty"`
	Attributes      interface{} `json:"attributes,omitempty"`
}

type NFTMetadataInput

type NFTMetadataInput struct {
	Name            string      `mapstructure:"name" json:"name"`
	Description     string      `mapstructure:"description,omitempty" json:"description"`
	Image           interface{} `mapstructure:"image,omitempty" json:"image"`
	ExternalUrl     string      `mapstructure:"external_url,omitempty" json:"external_url"`
	AnimationUrl    string      `mapstructure:"animation_url,omitempty" json:"animation_url"`
	BackgroundColor string      `mapstructure:"background_color,omitempty" json:"background_color"`
	Properties      interface{} `mapstructure:"properties,omitempty" json:"properties,omitempty"`
	Attributes      interface{} `mapstructure:"attributes,omitempty" json:"attributes,omitempty"`
}

type NFTMetadataOwner

type NFTMetadataOwner struct {
	Metadata *NFTMetadata
	Owner    string
}

type NFTResult

type NFTResult struct {
	// contains filtered or unexported fields
}

type NativeToken

type NativeToken struct {
	// contains filtered or unexported fields
}

type NewDirectListing

type NewDirectListing struct {
	AssetContractAddress     string
	TokenId                  int
	StartTimeInEpochSeconds  int
	ListingDurationInSeconds int
	Quantity                 int
	CurrencyContractAddress  string
	BuyoutPricePerToken      float64
}

type ProviderHandler

type ProviderHandler struct {
	// contains filtered or unexported fields
}

func NewProviderHandler

func NewProviderHandler(provider *ethclient.Client, privateKey string) (*ProviderHandler, error)

func (*ProviderHandler) GetChainID

func (handler *ProviderHandler) GetChainID(ctx context.Context) (*big.Int, error)

func (*ProviderHandler) GetPrivateKey

func (handler *ProviderHandler) GetPrivateKey() *ecdsa.PrivateKey

func (*ProviderHandler) GetProvider

func (handler *ProviderHandler) GetProvider() *ethclient.Client

func (*ProviderHandler) GetRawPrivateKey

func (handler *ProviderHandler) GetRawPrivateKey() string

func (*ProviderHandler) GetSignerAddress

func (handler *ProviderHandler) GetSignerAddress() common.Address

func (*ProviderHandler) UpdatePrivateKey

func (handler *ProviderHandler) UpdatePrivateKey(privateKey string) error

func (*ProviderHandler) UpdateProvider

func (handler *ProviderHandler) UpdateProvider(provider *ethclient.Client)

type SDKOptions

type SDKOptions struct {
	PrivateKey string
	GatewayUrl string
	HttpClient *http.Client
}

type ShardData

type ShardData struct {
	Proofs  []string        `json:"proofs"`
	Entries []SnapshotEntry `json:"entries"`
}

type ShardedMerkleTree

type ShardedMerkleTree struct {
	// contains filtered or unexported fields
}

func (*ShardedMerkleTree) FetchAndCacheDecimals

func (tree *ShardedMerkleTree) FetchAndCacheDecimals(
	ctx context.Context,
	cache map[string]int,
	provider *ethclient.Client,
	currencyAddress string,
) (int, error)

func (*ShardedMerkleTree) GetProof

func (tree *ShardedMerkleTree) GetProof(
	ctx context.Context,
	address string,
	provider *ethclient.Client,
) (*SnapshotEntryWithProof, error)

func (*ShardedMerkleTree) HashEntry

func (tree *ShardedMerkleTree) HashEntry(
	entry *SnapshotEntry,
	tokenDecimals int,
	currencyDecimals int,
) (string, error)

type ShardedMerkleTreeInfo

type ShardedMerkleTreeInfo struct {
	MerkleRoot         string `json:"merkleRoot"`
	BaseUri            string `json:"baseUri"`
	OriginalEntriesUri string `json:"originalEntriesUri"`
	ShardNybbles       int    `json:"shardNybbles"`
	TokenDecimals      int    `json:"tokenDecimals"`
}

type Signature1155PayloadInput

type Signature1155PayloadInput struct {
	To                   string
	Price                float64
	CurrencyAddress      string
	MintStartTime        int
	MintEndTime          int
	PrimarySaleRecipient string
	Metadata             *NFTMetadataInput
	RoyaltyRecipient     string
	RoyaltyBps           int
	Quantity             int
}

type Signature1155PayloadInputWithTokenId

type Signature1155PayloadInputWithTokenId struct {
	To                   string
	Price                float64
	CurrencyAddress      string
	MintStartTime        int
	MintEndTime          int
	PrimarySaleRecipient string
	Metadata             *NFTMetadataInput
	TokenId              int
	RoyaltyRecipient     string
	RoyaltyBps           int
	Quantity             int
}

type Signature1155PayloadOutput

type Signature1155PayloadOutput struct {
	To                   string            `json:"to"`
	Price                string            `json:"price"`
	CurrencyAddress      string            `json:"currencyAddress"`
	MintStartTime        int               `json:"mintStartTime"`
	MintEndTime          int               `json:"mintEndTime"`
	PrimarySaleRecipient string            `json:"primarySaleRecipient"`
	Metadata             *NFTMetadataInput `json:"metadata"`
	RoyaltyRecipient     string            `json:"royaltyRecipient"`
	RoyaltyBps           int               `json:"royaltyBps"`
	TokenId              int               `json:"tokenId"`
	Quantity             int               `json:"quantity"`
	Uri                  string            `json:"uri"`
	Uid                  [32]byte          `json:"uid"`
}

type Signature721PayloadInput

type Signature721PayloadInput struct {
	To                   string
	Price                float64
	CurrencyAddress      string
	MintStartTime        int
	MintEndTime          int
	PrimarySaleRecipient string
	Metadata             *NFTMetadataInput
	RoyaltyRecipient     string
	RoyaltyBps           int
}

type Signature721PayloadInputWithUri

type Signature721PayloadInputWithUri struct {
	To                   string
	Price                float64
	CurrencyAddress      string
	MintStartTime        int
	MintEndTime          int
	PrimarySaleRecipient string
	MetadataUri          string
	RoyaltyRecipient     string
	RoyaltyBps           int
}

type Signature721PayloadOutput

type Signature721PayloadOutput struct {
	To                   string   `json:"to"`
	Price                string   `json:"price"`
	CurrencyAddress      string   `json:"currencyAddress"`
	MintStartTime        int      `json:"mintStartTime"`
	MintEndTime          int      `json:"mintEndTime"`
	PrimarySaleRecipient string   `json:"primarySaleRecipient"`
	RoyaltyRecipient     string   `json:"royaltyRecipient"`
	RoyaltyBps           int      `json:"royaltyBps"`
	Uri                  string   `json:"uri"`
	Uid                  [32]byte `json:"uid"`
}

type SignedPayload1155

type SignedPayload1155 struct {
	Payload   *Signature1155PayloadOutput `json:"payload"`
	Signature string                      `json:"signature"`
}

type SignedPayload721

type SignedPayload721 struct {
	Payload   *Signature721PayloadOutput `json:"payload"`
	Signature string                     `json:"signature"`
}

type SmartContract

type SmartContract struct {
	Helper  *contractHelper
	Encoder *ContractEncoder
	Events  *ContractEvents
	ERC20   *ERC20
	ERC721  *ERC721
	ERC1155 *ERC1155
	// contains filtered or unexported fields
}

Custom Contracts

With the thirdweb SDK, you can get a contract instance for any contract. Additionally, if you deployed your contract using thirdweb deploy, you can get a more explicit and intuitive interface to interact with your contracts.

Getting a Custom Contract Instance

Let's take a look at how you can get a custom contract instance for one of your contracts deployed using the thirdweb deploy flow:

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

privateKey = "..."

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

// You can replace your own contract address here
contractAddress := "{{contract_address}}"

// Now you have a contract instance ready to go
contract, err := sdk.GetContract(contractAddress)

Alternatively, if you didn't deploy your contract with thirdweb deploy, you can still get a contract instance for any contract using your contracts ABI:

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

privateKey = "..."

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

// You can replace your own contract address here
contractAddress := "{{contract_address}}"

// Add your contract ABI here
abi := "[...]"

// Now you have a contract instance ready to go
contract, err := sdk.GetContractFromAbi(contractAddress, abi)

Calling Contract Functions

Now that you have an SDK instance for your contract, you can easily call any function on your contract with the contract "call" method as follows:

// The first parameter to the call function is the method name
// All other parameters to the call function get passed as arguments to your contract
balance, err := contract.Call("balanceOf", "{{wallet_address}}")

// You can also make a transaction to your contract with the call method
tx, err := contract.Call("mintTo", "{{wallet_address}}", "ipfs://...")

func (*SmartContract) Call

func (c *SmartContract) Call(ctx context.Context, method string, args ...interface{}) (interface{}, error)

Call any function on your contract.

method: the name of the method on your contract you want to call

args: the arguments to pass to the method

Example

// The first parameter to the call function is the method name
// All other parameters to the call function get passed as arguments to your contract
balance, err := contract.Call("balanceOf", "{{wallet_address}}")

// You can also make a transaction to your contract with the call method
tx, err := contract.Call(context.Background(), "mintTo", "{{wallet_address}}", "ipfs://...")

type SnapshotClaim

type SnapshotClaim struct {
	Address      string   `json:"address"`
	MaxClaimable int      `json:"maxClaimable"`
	Proof        []string `json:"proof"`
}

type SnapshotEntry

type SnapshotEntry struct {
	Address         string `json:"address"`
	MaxClaimable    string `json:"maxClaimable"`
	Price           string `json:"price"`
	CurrencyAddress string `json:"currencyAddress"`
}

type SnapshotEntryWithProof

type SnapshotEntryWithProof struct {
	Address         string
	MaxClaimable    string
	Price           string
	CurrencyAddress string
	Proof           [][32]byte
}

type SnapshotInfo

type SnapshotInfo struct {
	MerkleRoot string          `json:"merkleRoot"`
	Claims     []SnapshotClaim `json:"claims"`
}

type SnapshotInfos

type SnapshotInfos struct {
	Snapshot    SnapshotInfo
	MerkleRoot  string
	SnapshotUri string
}

type SnapshotInput

type SnapshotInput struct {
	Address      string
	MaxClaimable int
}

type ThirdwebSDK

type ThirdwebSDK struct {
	*ProviderHandler
	Storage  IpfsStorage
	Deployer ContractDeployer
	Auth     WalletAuthenticator
}

func NewThirdwebSDK

func NewThirdwebSDK(rpcUrlOrChainName string, options *SDKOptions) (*ThirdwebSDK, error)

NewThirdwebSDK

Create a new instance of the Thirdweb SDK

rpcUrlOrName: the name of the chain to connection to (e.g. "rinkeby", "mumbai", "polygon", "mainnet", "fantom", "avalanche") or the RPC URL to connect to

options: an SDKOptions instance to specify a private key and/or an IPFS gateway URL

func NewThirdwebSDKFromProvider

func NewThirdwebSDKFromProvider(provider *ethclient.Client, options *SDKOptions) (*ThirdwebSDK, error)

func (*ThirdwebSDK) GetContract

func (sdk *ThirdwebSDK) GetContract(ctx context.Context, address string) (*SmartContract, error)

GetContract

Get an instance of a custom contract deployed with thirdweb deploy

address: the address of the contract

func (*ThirdwebSDK) GetContractFromAbi

func (sdk *ThirdwebSDK) GetContractFromAbi(address string, abi string) (*SmartContract, error)

GetContractFromABI

Get an instance of ant custom contract from its ABI

address: the address of the contract

abi: the ABI of the contract

func (*ThirdwebSDK) GetEdition

func (sdk *ThirdwebSDK) GetEdition(address string) (*Edition, error)

GetEdition

Get an Edition contract SDK instance

address: the address of the Edition contract

func (*ThirdwebSDK) GetEditionDrop

func (sdk *ThirdwebSDK) GetEditionDrop(address string) (*EditionDrop, error)

GetEditionDrop

Get an Edition Drop contract SDK instance

address: the address of the Edition Drop contract

func (*ThirdwebSDK) GetMarketplace

func (sdk *ThirdwebSDK) GetMarketplace(address string) (*Marketplace, error)

GetMarketplace

Get a Marketplace contract SDK instance

address: the address of the Marketplace contract

func (*ThirdwebSDK) GetMultiwrap

func (sdk *ThirdwebSDK) GetMultiwrap(address string) (*Multiwrap, error)

GetMultiwrap

Get a Multiwrap contract SDK instance

address: the address of the Multiwrap contract

func (*ThirdwebSDK) GetNFTCollection

func (sdk *ThirdwebSDK) GetNFTCollection(address string) (*NFTCollection, error)

GetNFTCollection

Get an NFT Collection contract SDK instance

address: the address of the NFT Collection contract

func (*ThirdwebSDK) GetNFTDrop

func (sdk *ThirdwebSDK) GetNFTDrop(address string) (*NFTDrop, error)

GetNFTDrop

Get an NFT Drop contract SDK instance

address: the address of the NFT Drop contract

func (*ThirdwebSDK) GetToken

func (sdk *ThirdwebSDK) GetToken(address string) (*Token, error)

GetToken

Returns a Token contract SDK instance

address: address of the token contract

Returns a Token contract SDK instance

type Token

type Token struct {
	*ERC20Standard

	Helper  *contractHelper
	Encoder *ContractEncoder
	Events  *ContractEvents
	// contains filtered or unexported fields
}

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

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

privateKey = "..."

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

contract, err := sdk.GetToken("{{contract_address}}")

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
}

type WalletAuthenticationOptions

type WalletAuthenticationOptions struct {
	InvalidBefore  time.Time
	ExpirationTime time.Time
}

type WalletAuthenticationPayloadData

type WalletAuthenticationPayloadData struct {
	Iss string `json:"iss"`
	Sub string `json:"sub"`
	Aud string `json:"aud"`
	Exp int64  `json:"exp"`
	Nbf int64  `json:"nbf"`
	Iat int64  `json:"iat"`
	Jti string `json:"jti"`
}

type WalletAuthenticator

type WalletAuthenticator struct {
	*ProviderHandler
}

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

The wallet authenticator enables server-side applications to securely identify the connected wallet address of users on the client-side, and also enables users to authenticate to any backend using just their wallet. It implements the JSON Web Token (JWT) authentication standard.

You can use the wallet authenticator as follows:

// First we specify the domain of the application to authenticate to
domain := "example.com"

// We can then generate a payload for the connected wallet to login
// This can also be done on the client side with the thirdweb TypeScript SDK
payload, err := sdk.Auth.Login(domain, nil)

// Then, on the server, we can securely verify the connected address that signed the payload
address, err := sdk.Auth.Verify(domain, payload, nil)

// And we can also generate an authentication token to send back to the original payload sender
token, err := sdk.Auth.GenerateAuthToken(domain, payload, nil)

// Finally, the token can be use dby the original payload sender to authenticate to the backend
// And the server can use the following function to authenticate the token and verify the address
address, err := sdk.Auth.Authenticate(domain, token)

func (*WalletAuthenticator) Authenticate

func (auth *WalletAuthenticator) Authenticate(
	domain string,
	token string,
) (string, error)

Server-side function that authenticates the provided JWT token. This function verifies that the provided authentication token is valid and returns the address of the authenticated wallet.

domain: The domain of the application to authenticate the token to

token: The authentication token to authenticate with

returns: The address of the authenticated wallet

Example

domain := "example.com"
payload, err := sdk.Auth.Login(domain)
token, err := sdk.Auth.GenerateAuthToken(domain, payload)

// Authenticate the token and get the address of the authenticating wallet
address, err := sdk.Auth.Authenticate(domain, token)

func (*WalletAuthenticator) GenerateAuthToken

func (auth *WalletAuthenticator) GenerateAuthToken(
	domain string,
	payload *WalletLoginPayload,
	options *WalletAuthenticationOptions,
) (string, error)

Server-side function that generates a JWT token from the provided login request that the client-side wallet can use to authenticate to the server-side application.

domain: The domain of the application to authenticate to

payload: The login payload to authenticate with

options: Optional configuration options for the authentication token

returns: An authentication token that can be used to make authenticated requests to the server

Example

domain := "example.com"
payload, err := sdk.Auth.Login(domain, nil)

// Generate an authentication token for the logged in wallet
token, err := sdk.Auth.GenerateAuthToken(domain, payload, nil)

func (*WalletAuthenticator) Login

func (auth *WalletAuthenticator) Login(
	domain string,
	options *WalletLoginOptions,
) (*WalletLoginPayload, error)

Client-side function that allows the connected wallet to login to a server-side application. Generates a login payload that can be sent to the server-side for verification or authentication.

domain: The domain of the application that you want to log in to

options: Optional configuration options for the login payload

returns: A login payload that can be sent to the server-side for verification or authentication

Example

// Add the domain of the application that you want to log in to
domain := "example.com"

// Generate a signed login payload for the connected wallet to authenticate with
payload, err := sdk.Auth.Login(domain, nil)

func (*WalletAuthenticator) Verify

func (auth *WalletAuthenticator) Verify(
	domain string,
	payload *WalletLoginPayload,
	options *WalletVerifyOptions,
) (string, error)

Server-side function to securely verify the address of the logged in client-side wallet by validating the provided client-side login request.

domain: The domain of the application to verify the login request for

payload: The login payload to verify

returns: The address of the logged in wallet that signed the payload

Example

domain := "example.com"
payload, err := sdk.Auth.Login(domain, nil)

// Verify the login request
address, err := sdk.Auth.Verify(domain, payload, nil)

type WalletLoginOptions

type WalletLoginOptions struct {
	Nonce          string
	ExpirationTime time.Time
	ChainId        int
}

type WalletLoginPayload

type WalletLoginPayload struct {
	Payload   *WalletLoginPayloadData `json:"payload"`
	Signature string                  `json:"signature"`
}

type WalletLoginPayloadData

type WalletLoginPayloadData struct {
	Domain         string    `json:"domain"`
	Address        string    `json:"address"`
	Nonce          string    `json:"nonce"`
	ExpirationTime time.Time `json:"expiration_time"`
	ChainId        int       `json:"chain_id"`
}

type WalletVerifyOptions

type WalletVerifyOptions struct {
	ChainId int
}

type WrappedToken

type WrappedToken struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL