Plutus Docs
  • Introduction
  • Basic Stellar Fundamentals
    • 💡Account Creation
    • ✨Transaction Lifecycle
  • Product Guides
    • 📪Stellar NFT Minting Guide
    • 📦Wrap Tokens
    • ☝️Token Contract Interaction
    • 📎Rental Smart Contract Interaction Guide
Powered by GitBook
On this page
  1. Product Guides

Wrap Tokens

To interact with the Soroban smart contract, Stellar assets have to be wrapped so that they are compatible with the Soroban token interface. Each wrap will deploy a new token contract on Soroban, with the original issuer of the asset set as administrator. Wrapping a token requires the asset code and asset issuer ID, and anyone can wrap them on Soroban.

Wrap NFT token:

soroban lab token wrap --asset
"MYNFT:GB3VRP7SLBLKZUIHEHENIGT34TUO2X7AKULJ2FE6DCTQHMMXB6U2IPVN" --rpc-url
https://rpc-futurenet.stellar.org:443 --network-passphrase 'Test SDF Future
Network ; October 2022

Please ensure you change the --asset param accordingly.

Wrap Payment token:

soroban lab token wrap --asset
"PAYMENTTOKEN:GA36RZMMQHBA2LURRSUQR7V4ID5Q7GVZRMAWY2RSXCLA4QPGT6UUWFLU"
--rpc-url https://rpc-futurenet.stellar.org:443 --network-passphrase 'Test
SDF Future Network ; October 2022'

Again, be sure to adjust the --asset param as required.

When you run a wrap command, it will return a contract_id (e.g. 38f2fb24a53d4ee70dabf456b0f13789b0fd825921ea31754d4f561c54362b87). To use this contract_id as an Address in the smart contract, you'll need to convert the contract ID to hex using Address Conversion.

Address Conversion:

Address Conversion allows you to convert a contract ID into an address, which can then be used in the smart contract. For example, when we wrap the NFT token in Soroban, we receive a contract ID. We need to convert this ID into an address so that we can store it in the rental smart contract.

You can use the following Javascript snippet:

const {Address} = require("soroban-client")
let id="38f2fb24a53d4ee70dabf456b0f13789b0fd825921ea31754d4f561c54362b87"
const address = Address.contract(Buffer.from(id, 'hex'))
console.log(address.toString())

PreviousStellar NFT Minting GuideNextToken Contract Interaction

Last updated 1 year ago

📦