ndatg / ton-highload-wallet-contract

TON Highload Wallet Contract
https://ndatg.github.io/ton-highload-wallet-contract/
MIT License
7 stars 1 forks source link

How to transfer nft from highload wallet v2? #2

Closed ncsft closed 3 months ago

ncsft commented 3 months ago

How to create body and send it? I get 130 error in blockchain transaction.

// We can add a comment, but it will not be displayed in the explorers,
// as it is not supported by them at the time of writing the tutorial.
const forwardPayload = beginCell()
  .storeUint(0, 32)
  .storeStringTail('gift')
  .endCell();

const transferNftBody = beginCell()
  .storeUint(0x5fcc3d14, 32) // Opcode for NFT transfer
  .storeUint(0, 64) // query_id
  .storeAddress(destinationAddress) // new_owner
  .storeAddress(walletAddress) // response_destination for excesses
  .storeBit(0) // we do not have custom_payload
  .storeCoins(toNano('0')) // forward_amount
  .storeBit(1) // we store forward_payload as a reference
  .storeRef(forwardPayload) // store forward_payload as a .reference
  .endCell();

const internalMessage = beginCell()
  .storeUint(0x18, 6)
  . // bounce
  storeAddress(nftAddress)
  .storeCoins(toNano('0'))
  .storeUint(1, 1 + 4 + 4 + 64 + 32 + 1 + 1)
  . // We store 1 that means we have body as a reference
  storeRef(transferNftBody)
  .endCell();

const res = await contract.sendTransfer({
  secretKey: key.secretKey,
  messages: [
    internal({
      to: nftAddress,
      value: '0.04',
      body: internalMessage,
    }),
  ],
});
ncsft commented 3 months ago

Solution is

// nft payload
const transferNftBody = beginCell()
  .storeUint(0x5fcc3d14, 32)
  .storeUint(0, 64)
  .storeAddress(destinationAddress)
  .storeAddress(walletAddress)
  .storeBit(0)
  .storeCoins(toNano('0'))
  .storeBit(1)
  .storeRef(forwardPayload)
  .endCell();

// send
const res = await contract.sendTransfer({
  secretKey: key.secretKey,
  messages: [
    internal({
      to: nftAddress,
      value: '0.04',
      body: transferNftBody,
    }),
  ],
});