NFT and Smart-Contracts

Smart-contracts 🤝 and NFTs 🏞

Working with NFTs using the NFT scenario step

When this step is completed, its return value (which you can save in any field) will include a hash as the result.

For example:

{ "hash": "0x...." }

Working with ERC-20 and ERC-721 from JS SDK

We are supporting the execution of contracts on Polygon network.

We have 2 methods to call contracts:

executeFunction(contract: String, method: String, in: AnyRef, out: AnyRef)

and helper method for quickly transferring Tokens (ERC-20) and NFTs (ERC-721)

transfer(`type`: String, contract: String, receiver: String, _value: Any = "")

Sending Tokens to Any Address

  var network = $D.crypto.network('polygon')
  var contractAddress = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" //USDT
  var wallet = network.wallet('... secret phrase ...')
  
  var inParam = [
    {"name": "_to", "value":"0x357...", "type": "address"},
    {"name": "_value", "value":1000, "type": "uint256"}             
  ]
  //execute method transfer on contract 0xc2132D05D31c914a87C6611C10748AEb04B58e8F (USDT) and sending 0.01 USDT
  var result = wallet.executeFunction(contractAddress, "transfer", inParam, [])
  $D.console.log("Show transaction on: https://polygonscan.com/tx/" + result['hash'])

Helper function for fast call execution contract for ERC-20 or ERC-721

//init wallet
var network = $D.crypto.network('polygon')
var contractAddress = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" //USDT
var wallet = network.wallet('... secret phrase ...')
  
var result = wallet.transfer("erc20", contractAddress, "0x...reciver...", 10000)
$D.console.log("Show transaction on: https://polygonscan.com/tx/" + result['hash'] + '\n')
//init wallet
var network = $D.crypto.network('polygon')
var contractAddress = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" //USDT
var wallet = network.wallet('... secret phrase ...')

var nftAddress = "0x2A11c19c33b59E1be2d1A684B0BE9F3e5cEaCf65"
var nftTokenID = "17095719063608835418704764119787869740203281679245365365248102562191638528001"
var result = wallet.transfer("erc721", nftAddress, "0x...reciver....", nftTokenID)
$D.console.log("Show transaction on: https://polygonscan.com/tx/" + result['hash'])

Last updated