9. Asset Transfers
For various reasons, users may wish to transfer their assets from one wallet to another, for example, to send assets as gifts.
Initialize SDK
You need to initialize the SDK in order to use it.
Create transfer
All NFT transactions will be confirmed by Zecrey. Zecrey will ensure that it is submitted to L1 once the transaction is confirmed.
Parameters needed:
Parameter
Parameter usage and meaning
Required vs Optional
accountName
The account name used to initialize the client
✅
seed
The user's L2 seed used to initialize the client
✅
toAccountName
The receiver's account name
✅
📚SDK REFERENCE
Example
TransferNftallows users to change the owner of NFT. However, the creator of the NFT will never change. Each time an NFT is transferred, the creator will receive a royalty, which is calculated by the NFT'sTreasuryRateset by its creator.Alice transfers to Bob the NFT with
NftId= 6Initialize the client
Transfer the NFT to Bob
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
var NftId int64 = 6
accountName := "Alice"
seed := "0x6a1a320d14790f2d9aa9a37769f4833d583a3f7f974fd452a3990aeb0e7a6052"
toAccountName := "Bob"
c, err := sdk.NewClient(accountName, seed)
if err != nil { panic(err) }
result, err := c.TransferNft(NftId, toAccountName)
if err != nil { panic(err) }
data, _ := json.Marshal(result)
fmt.Println("TransferNft:", string(data))
}Example result
Example
TransferNft allows users to change the owner of NFT. However, the creator of the NFT will never change. Each time an NFT is transferred, the creator will receive a royalty, which is calculated by the NFT's TreasuryRate set by its creator.
Alice transfers to Bob the NFT with
NftId= 6Initialize the client
Transfer the NFT to Bob
With the private key:
With the wallet:
Example result
Last updated
Was this helpful?