11. Full Exit

  • In order to ensure the security of users' assets, users are given the right to take out their assets at any time. They can return the assets to their accounts by sending a transaction to L1.

Initialize SDK

  • You need to initialize the SDK in order to use it.

NFT Full Exit

  • Parameters needed:

📚SDK REFERENCE

Example

  • FullExit the NFT with nftIndex = 130

    • Initialize client

    • FullExit the NFT with nftIndex = 130

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
    accountName := "alice"
    privateKey := "0xe94a8b4ddd33b2865a89bb764d70a0c3e3276007ece8f114a47a4e9581ec3567"
    nftIndex := uint32(130)
    seed := "13243b9a9fdec6dc90c7cc1eb1c939134dfb659d2f0asdfas5413213213213213"
    c, err := NewClient(accountName, seed)
    fullExitNftTransaction, err := c.FullExitNft(accountName, privateKey, nftIndex)
    if err != nil {
       t.Fatal(err)
    }
    fmt.Println("tx hash:", fullExitNftTransaction.Hash())
}

Example Result

tx hash: 0x3e78bf427bbe8bc6be629b6bcd3a88cb65234b7da209134787a8f39c8ace1d4a

FT Full Exit

  • Parameters needed

    • BNB、LEG、REY's token addresses are needed and the details can be obtained through GetAssetsList

📚SDK REFERENCE

Example

  • Deposit 10000 BNB to L2

    • Initialize client

    • FullExit 100000 BNB

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
    accountName := "alice"
    privateKey := "0xe94a8b4ddd33b2865a89bb764d70a0c3e3276007ece8f114a47a4e9581ec3567"
    assetAddress := common.HexToAddress("")//_asset Token address, 0 address for BNB
    seed := "13243b9a9fdec6dc90c7cc1eb1c939134dfb659d2f0asdfas5413213213213213"
    c, err := NewClient(accountName, seed)
    var amount int64 = 100000
    if err != nil {
       t.Fatal(err)
    }
    fullExitTransaction, err := c.FullExit(accountName, privateKey, assetAddress)
    if err != nil {
       t.Fatal(err)
    }
    fmt.Println("tx hash:",fullExitTransaction)
}

Example Result

tx hash: 0x72aac80edfcb5c2f5c34e4b7acccc4831ef8ad61b1ef0396407b9fb31ed151fd

Last updated