Skip to content

Latest commit

 

History

History
171 lines (129 loc) · 5.38 KB

EVMs.md

File metadata and controls

171 lines (129 loc) · 5.38 KB

NFTs on EVMs (Etherum-based blockchains)

const sdk = new CryptumSdk({
  environment: 'testnet',
  apiKey: 'YOUR-API-KEY',
})

Create NFT

sdk.nft.create(opts)

The smart contract used in this deployment is already precompiled in Cryptum. For more details, you can see the source code here ./contracts/TokenERC721.sol and ./contracts/TokenERC1155.sol.

  • opts.protocol (string) (required) - EVMs only.
  • opts.wallet (Wallet) (required) - wallet creating the token.
  • opts.name (string) (required) - token name.
  • opts.symbol (string) (required) - token symbol.
  • opts.type (string) (required) - token type ERC721 or ERC1155.
  • opts.uri (string) (optional) - token base URI. It is null by default because you can pass specific URI by minting NFTs instead.

This function returns the transaction hash from the blockchain. This hash can be used later to retrieve the token address.

const { hash } = await sdk.nft.create({
  wallet,
  name: 'NFT name',
  symbol: 'NFT',
  type: 'ERC721',
  protocol: 'ETHEREUM',
})

Transfer NFTs

sdk.nft.transfer(opts)

Transfer NFTs.

  • opts.wallet (Wallet) (required) - wallet transferring NFTs.
  • opts.token (string) (required) - token address.
  • opts.amount (string) (required) - token amount to be transferred. (this is in largest unit ether)
  • opts.destination (string) (required) - destination address.
  • opts.protocol (string) (required) - EVMs only.

This function returns the hash of this transferring transaction from the blockchain.

const { hash } = await sdk.nft.transfer({
  wallet,
  protocol: 'AVAXCCHAIN',
  token: '0x1b5e12ca...1b5e12ca',
  destination: '0x31ec6686ee15...07A931b5e12cacb920e',
  amount: '9.129045',
})

Mint NFTs

sdk.nft.mint(opts)

Mint NFTs.

*Obs: This method will only work for the NFTs created with the method sdk.nft.create.

  • opts.protocol (string) (required) - EVMs only.
  • opts.wallet (Wallet) (required) - wallet minting NFTs.
  • opts.token (string) (required) - token address.
  • opts.destination (string) (required) - destination address.
  • opts.amount (string) (required) - token amount to be minted.
  • opts.tokenId (string) (required) - token id to be minted.
  • opts.uri (string) (optional) - metadata URI.

This function returns the hash of this minting transaction from the blockchain.

const { hash } = await sdk.nft.mint({
  protocol: 'CELO',
  wallet,
  token: '0x8888888...333333',
  destination: '0x3333....555555555',
  amount: '10',
  tokenId: 0,
  uri: 'ipfs://...',
})

Burn NFTs

sdk.nft.burn(opts)

Burn NFTs.

*Obs: This method will only work for the NFTs created with the method sdk.nft.create.

  • opts.wallet (Wallet) (required) - wallet burning NFTs.
  • opts.token (string) (required) - token address.
  • opts.amount (string) (required) - token amount to be burnt.
  • opts.tokenId (string) (required) - token id to be burnt.
  • opts.protocol (string) (required) - EVMs only.

This function returns the hash of this burning transaction from the blockchain.

const { hash } = await sdk.nft.burn({
  wallet,
  protocol: 'CELO',
  token: '0x3333333...555555555',
  amount: '3',
  tokenId: 0,
})

Approve ERC-721 NFTs

sdk.nft.approve(opts)

Invoke method "approve" from ERC721-compatible smart contracts.

*Obs: This method will only work for the NFTs compatible with ERC-721 standard.

  • opts.wallet (Wallet) (required) - wallet signing transaction that owns the NFT.
  • opts.token (string) (required) - token address.
  • opts.tokenId (string) (required) - token id to be approved.
  • opts.operator (string) (required) - address to add to the set of authorized operators.
  • opts.protocol (string) (required) - EVMs only.

This function returns the hash of this transaction from the blockchain.

const { hash } = await sdk.nft.approve({
  wallet,
  protocol: 'CELO',
  token: '0x1b5e12ca...1b5e12ca',
  tokenId: '100000',
  operator: '0x9377888...3342232',
})

Set approval for all NFTs

sdk.nft.setApprovalForAll(opts)

Invoke method "setApprovalForAll" from ERC721/ERC1155-compatible smart contracts.

*Obs: This method will only work for the NFTs compatible with ERC-721/ERC-1155 standard.

  • opts.wallet (Wallet) (required) - wallet signing transaction that owns the NFTs.
  • opts.token (string) (required) - token address.
  • opts.isApproved (boolean) (required) - true if the operator is approved, false to revoke approval.
  • opts.operator (string) (required) - address to add to the set of authorized operators.
  • opts.protocol (string) (required) - EVMs only.

This function returns the hash of this transaction from the blockchain.

const { hash } = await sdk.nft.setApprovalForAll({
  wallet,
  protocol: 'CELO',
  token: '0x1b5e12ca...1b5e12ca',
  isApproved: true,
  operator: '0x9377888...3342232',
})