Zecrey
  • Introduction
  • Zecrey Onepager
  • Announcements
    • Zecrey Public Testnet Announcement
    • Zecrey Testnet Beta Internal Test Announcement
    • Zecrey Ambassador Program Annoucement
  • Go & JS SDK Basic Guides
    • 1. Install and Initialize
    • 2. Get Data
    • 3. SDK Signature
    • 4. Register Users
    • 5. Mint Assets
    • 6. Creating Orders
    • 7. Match Orders
    • 8. Asset Deposits
    • 9. Asset Transfers
    • 10. Asset Withdrawals
    • 11. Full Exit
    • 12. Demo of SDK Calling
  • Education
    • Zecrey Video Guide
    • Concepts Explained
      • Crypto Knowledge
        • Layer 1 (L1)
        • Layer 2 (L2)
        • ZK-Rollup
        • Gas Fee
        • NFT
      • Zecrey Basics
        • Multi-chain asset management
        • Zecrey L1 wallet
        • Zecrey Legend L2 wallet
        • Zecrey Zero L2 wallet
        • Deposit
        • Withdraw
        • Zecrey DEX
      • The State of Transactions
    • Get Started
      • How to import an account?
      • How to create a new account?
      • How to receive and send assets with QR code?
      • How to export the private key?
      • How to export the recovery phrase?
      • How to use Zecrey NFT Marketplace?
      • How to adjust the gas fee?
      • How to check my transaction record?
      • How to manage my contacts?
      • How to set the language?
      • How to give feedback?
    • FAQs
  • Product Handbook
    • Zecrey Products Introduction
    • Set up your Zecrey Wallet
      • Download and Install Zecrey
      • Create a New Wallet
      • Import an Existing Wallet with Mnemonic
      • Claim Test Tokens for Testnet
      • Testing Requirements
      • Rewards for Phase II Testnet
    • Zecrey L1 Wallet
      • Multi-chain Assets Management
      • L1 Transfer
      • Deposit
      • L1 NFT Management
        • View NFT Assets
        • L1 NFT Transfer
        • NFT Deposit
    • Zecrey Legend L2
      • L2 Account Registration
      • L2 Transfer
      • Withdraw
    • Zecrey NFT Marketplace
      • Explore NFT Marketplace
      • Connect Zecrey Extension to NFT Marketplace
      • Create NFT Collection
      • Mint NFT
      • Buy NFT
      • Sell NFT
      • Transfer NFT
      • Withdraw NFT
      • View NFT Assets
      • Manage NFT Transactions
Powered by GitBook
On this page
  • Initialize SDK
  • NFT Full Exit
  • FT Full Exit

Was this helpful?

  1. Go & JS SDK Basic Guides

11. Full Exit

Previous10. Asset WithdrawalsNext12. Demo of SDK Calling

Last updated 2 years ago

Was this helpful?

  • 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:

    Parameter

    Parameter usage and meaning

    Requirement

    accountName

    The account name used to initialize the client

    ✅

    seed

    The user's L2 seed used to initialize the client

    ✅

    privateKey

    Since this transaction involves L1, the private key of user's L1 account is needed to sign the transaction

    ✅

    nftIndex

    The unique ID of NFT in L1

    ✅

📚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

Example

  • FullExit the NFT with nftIndex = 130

import { SDK } from "@zecrey/zecrey-legend-js-sdk";

const sdk = new SDK();
await sdk.initial();

const privateKey = "1bcb0ae8c17945acfaf9ea546c0b754a599fddf27425bac7e532590324137a7d";
const account = "alice"; 
const nft_index = 130;

const res = await sdk.fullExitNft(privateKey, account, nft_index);

FT Full Exit

  • Parameters needed

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

    Parameter

    Parameter usage and meaning

    Required or not

    accountName

    The account name used to initialize the client

    ✅

    seed

    The user's L2 seed used to initialize the client

    ✅

    privateKey

    Since this transaction involves L1, the private key of user's L1 account is needed to sign the transaction

    ✅

    asset

    asset Token address

    ✅

📚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

Example

  1. BNB

import { SDK } from "@zecrey/zecrey-legend-js-sdk";

const sdk = new SDK();
await sdk.initial();

const privateKey = "1bcb0ae8c17945acfaf9ea546c0b754a599fddf27425bac7e532590324137a7d";
const account = "alice"; 
const asset_contract = "0x00"; // this address represents BNB

const res = await sdk.fullExit(privateKey, account, asset_contract );
  1. LEG and REY and other BEP20 assets

import { SDK } from "@zecrey/zecrey-legend-js-sdk";

const sdk = new SDK();
await sdk.initial();

const privateKey = "1bcb0ae8c17945acfaf9ea546c0b754a599fddf27425bac7e532590324137a7d";
const account = "alice"; 
const asset_contract = "0x364Ed72f329f1BD56AE84b941D1c6E4E260cE152"; // contract address of LEG

const res = await sdk.fullExit(privateKey, account, asset_contract);

FullExitNft
FullExit