Edition Drop
Learn how to interact with your Edition Drop contract in the SDK.
Create an Edition Drop Contract
- React
- Javascript
- Python
- Go
const sdk = useSDK();
const contractAddress = await sdk.deployer.deployEditionDrop({
name: "My Edition Drop",
primary_sale_recipient: "your-address",
});
const contractAddress = await sdk.deployer.deployEditionDrop({
name: "My Edition Drop",
primary_sale_recipient: "your-address",
});
Python SDK support for deployEditionDrop is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for deployEditionDrop is coming soon.
Want this feature sooner? Let us know in Discord!
Getting the contract in your application
To start using your Edition Drop contract inside your application, you need to use its contract address. You can get the contract address from the dashboard.
- React
- Javascript
- Python
- Go
import { useEditionDrop } from '@thirdweb-dev/react'
export default function Component() {
const editionDrop = useEditionDrop("<YOUR-CONTRACT-ADDRESS>")
// Now you can use the edition drop contract in the rest of the component
}
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
const sdk = new ThirdwebSDK("{{chainName}}");
const contract = sdk.getEditionDrop("{{contract_address}}");
from thirdweb import ThirdwebSDK
# You can customize this to a supported network or your own RPC URL
network = "mumbai"
# Now we can create a new instance of the SDK
sdk = ThirdwebSDK(network)
# If you want to send transactions, you can instantiate the SDK with a private key instead:
# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)
contract = sdk.get_edition_drop("{{contract_address}}")
import (
"github.com/thirdweb-dev/go-sdk/thirdweb"
)
privateKey = "..."
sdk, err := thirdweb.NewThirdwebSDK("mumbai", &thirdweb.SDKOptions{
PrivateKey: privateKey,
})
contract, err := sdk.GetEditionDrop("{{contract_address}}")
Lazy Minting Your NFTs
- React
- Javascript
- Python
- Go
// Custom metadata of the NFTs to create
const metadatas = [{
name: "Cool NFT",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
}, {
name: "Cool NFT",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/image.png"),
}];
const results = await contract.createBatch(metadatas); // uploads and creates the NFTs on chain
const firstTokenId = results[0].id; // token id of the first created NFT
const firstNFT = await results[0].data(); // (optional) fetch details of the first created NFT
// Custom metadata of the NFTs to create
const metadatas = [{
name: "Cool NFT",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
}, {
name: "Cool NFT",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/image.png"),
}];
const results = await contract.createBatch(metadatas); // uploads and creates the NFTs on chain
const firstTokenId = results[0].id; // token id of the first created NFT
const firstNFT = await results[0].data(); // (optional) fetch details of the first created NFT
from thirdweb.types.nft import NFTMetadataInput, EditionMetadataInput
# Note that you can customize this metadata however you like
metadatas_with_supply = [
EditionMetadataInput(
NFTMetadataInput.from_json({
"name": "Cool NFT",
"description": "This is a cool NFT",
"image": open("path/to/file.jpg", "rb"),
}),
100
),
EditionMetadataInput(
NFTMetadataInput.from_json({
"name": "Cooler NFT",
"description": "This is a cooler NFT",
"image": open("path/to/file.jpg", "rb"),
}),
100
)
]
txs = contract.create_batch(metadata_with_supply)
first_token_id = txs[0].id
first_nft = txs[0].data()
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("{{wallet_address}}", metadatasWithSupply)
Setting Claim Phases
- React
- Javascript
- Python
- Go
const presaleStartTime = new Date();
const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
const claimConditions = [
{
startTime: presaleStartTime, // start the presale now
maxQuantity: 2, // limit how many mints for this presale
price: 0.01, // presale price
snapshot: ['0x...', '0x...'], // limit minting to only certain addresses
},
{
startTime: publicSaleStartTime, // 24h after presale, start public sale
price: 0.08, // public sale price
}
]);
const tokenId = 0; // the id of the NFT to set claim conditions on
await contract.claimConditions.set(tokenId, claimConditions);
const presaleStartTime = new Date();
const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
const claimConditions = [
{
startTime: presaleStartTime, // start the presale now
maxQuantity: 2, // limit how many mints for this presale
price: 0.01, // presale price
snapshot: ['0x...', '0x...'], // limit minting to only certain addresses
},
{
startTime: publicSaleStartTime, // 24h after presale, start public sale
price: 0.08, // public sale price
}
]);
const tokenId = 0; // the id of the NFT to set claim conditions on
await contract.claimConditions.set(tokenId, claimConditions);
Python SDK support for claimConditions is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for claimConditions is coming soon.
Want this feature sooner? Let us know in Discord!
Setting Royalty Fees
- React
- Javascript
- Python
- Go
// royalties on the whole contract
contract.royalties.setDefaultRoyaltyInfo({
seller_fee_basis_points: 100, // 1%
fee_recipient: "0x..."
});
// override royalty for a particular token
contract.royalties.setTokenRoyaltyInfo(tokenId, {
seller_fee_basis_points: 500, // 5%
fee_recipient: "0x..."
});
// royalties on the whole contract
contract.royalties.setDefaultRoyaltyInfo({
seller_fee_basis_points: 100, // 1%
fee_recipient: "0x..."
});
// override royalty for a particular token
contract.royalties.setTokenRoyaltyInfo(tokenId, {
seller_fee_basis_points: 500, // 5%
fee_recipient: "0x..."
});
Python SDK support for royalties is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for royalties is coming soon.
Want this feature sooner? Let us know in Discord!
Minting / Claiming NFTs
- React
- Javascript
- Python
- Go
const Component = () => {
const {
mutate: claimNft,
isLoading,
error,
} = useClaimNFT(DropContract);
if (error) {
console.error("failed to claim nft", error);
}
return (
<button
disabled={isLoading}
onClick={() => claimNft({ to: "0x...", quantity: 1 })}
>
Claim NFT!
</button>
);
};
const address = "{{wallet_address}}"; // address of the wallet you want to claim the NFTs
const tokenId = 0; // the id of the NFT you want to claim
const quantity = 1; // how many NFTs you want to claim
const tx = await contract.claimTo(address, tokenId, quantity);
const receipt = tx.receipt; // the transaction receipt
address = {{wallet_address}}
token_id = 0
quantity = 1
tx = contract.claim_to(address, token_id, quantity)
receipt = tx.receipt
claimed_token_id = tx.id
claimed_nft = tx.data()
address = "{{wallet_address}}"
tokenId = 0
quantity = 1
tx, err := contract.ClaimTo(address, tokenId, quantity)
Airdrop NFTs
- React
- Javascript
- Python
- Go
// The token ID of the NFT you want to airdrop
const tokenId = "0";
// Array of objects of addresses and quantities to airdrop NFTs to
const addresses = [
{
address: "0x...",
quantity: 2,
},
{
address: "0x...",
quantity: 3,
},
];
await contract.airdrop(tokenId, addresses);
// You can also pass an array of addresses, it will airdrop 1 NFT per address
const tokenId = "0";
const addresses = [
"0x...", "0x...", "0x...",
]
await contract.airdrop(tokenId, addresses);
// The token ID of the NFT you want to airdrop
const tokenId = "0";
// Array of objects of addresses and quantities to airdrop NFTs to
const addresses = [
{
address: "0x...",
quantity: 2,
},
{
address: "0x...",
quantity: 3,
},
];
await contract.airdrop(tokenId, addresses);
// You can also pass an array of addresses, it will airdrop 1 NFT per address
const tokenId = "0";
const addresses = [
"0x...", "0x...", "0x...",
]
await contract.airdrop(tokenId, addresses);
Python SDK support for airdrop is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for airdrop is coming soon.
Want this feature sooner? Let us know in Discord!
Viewing NFTs
One NFT
- React
- Javascript
- Python
- Go
const nft = await contract.get("0");
const nft = await contract.get("0");
nft = contract.get(0)
print(nft)
nft, err := contract.Get(0)
All NFTs
- React
- Javascript
- Python
- Go
const { contract } = useContract(<ContractAddress>);
const { data: nfts, isLoading, error } = useNFTs(contract?.nft, { start: 0, count: 100 });
const nfts = await contract.getAll();
metadatas = contract.get_all()
print(metadatas)
nfts, err := contract.GetAll()
supplyOne := nfts[0].Supply
nameOne := nfts[0].Metadata.Name
NFTs owned by a specific wallet
- React
- Javascript
- Python
- Go
// Address of the wallet to get the NFTs of
const address = "{{wallet_address}}";
const nfts = await contract.getOwned(address);
// Address of the wallet to get the NFTs of
const address = "{{wallet_address}}";
const nfts = await contract.getOwned(address);
address = "{{wallet_address}}"
owned = contract.get_owned(address)
print(owned)
owner := "{{wallet_address}}"
nfts, err := contract.GetOwned(owner)
name := nfts[0].Metadata.Name
Amount of tokens owned by a specific wallet
- React
- Javascript
- Python
- Go
const { contract } = useContract(<ContractAddress>);
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract?.nft, <OwnerWalletAddress>);
// Address of the wallet to check NFT balance
const walletAddress = "{{wallet_address}}";
const tokenId = 0; // Id of the NFT to check
const balance = await contract.balanceOf(walletAddress, tokenId);
address = "{{wallet_address}}"
token_id = 0
balance = contract.balance_of(address, token_id)
address := "{{wallet_address}}"
tokenId := 0
balance, err := contract.BalanceOf(address, tokenId)
Transferring NFTs
- React
- Javascript
- Python
- Go
// Address of the wallet you want to send the NFT to
const toAddress = "{{wallet_address}}";
const tokenId = "0"; // The token ID of the NFT you want to send
const amount = 3; // How many copies of the NFTs to transfer
await contract.transfer(toAddress, tokenId, amount);
// Address of the wallet you want to send the NFT to
const toAddress = "{{wallet_address}}";
const tokenId = "0"; // The token ID of the NFT you want to send
const amount = 3; // How many copies of the NFTs to transfer
await contract.transfer(toAddress, tokenId, amount);
to = "{{wallet_address}}"
token_id = 0
amount = 1
receipt = contract.transfer(to, token_id, amount)
to := "0x..."
tokenId := 0
amount := 1
tx, err := contract.Transfer(to, tokenId, amount)