Zebec Network
  • 💰Zebec Network
  • ➡️ZBC to ZBCN Migration Guide
  • 🗞️Zebec Network white Paper
  • 📈ZBCN Tokemonics
  • 🥳Getting Started
    • How to get started?
    • Benefits of Using Zebec Protocol
    • Deposit
    • Start Streaming
    • Withdraw Funds
  • 👾Safe
    • Create Safe
    • Deposit in Safe
    • Sending a Transaction
    • Zapps
    • Signing a Transaction
  • ZEBEC SOLANA
    • 🖥️Zebec Solana Sdk
      • 🖱️Streaming
        • Initialize Zebec Stream
        • Create Fee Vault
        • Update Fee Vault
        • Collect Fees
        • Deposit
        • Withdraw Deposited Token
        • Start Streaming
        • Pause Stream
        • Resume Stream
        • Cancel Stream
        • Withdraw Streamed Token
  • ZEBEC SILVER CARD
    • 💳Silver Card Sdk
      • 🔧Installation
      • 👨‍🚀Quick Start
      • ✉️Fetch Quote
      • ⚖️Configuration Parameters
      • 📦Recipient Fields
      • 🔁Responses
      • 🔢Environment Variables
      • 🌎Supported Countries
  • Zebec Bridge
    • Bridge Sdk
      • Creating clients
      • Initialize Proxy Account
      • Initialize Token Account
      • Deposit
        • Token Transfer
        • Deposit to Zebec
      • Withdraw Deposited
        • Withdraw From Zebec
        • Token Transfer
      • Init Stream
      • Pause/Resume Stream
      • Cancel Stream
      • Update Stream
  • Zebec Near
    • Zebec Near Sdk
      • Normal Stream
        • Initialize Near Stream
        • Initialize Token Stream
        • Pause/Resume Stream
        • Withdraw Stream
        • Update Stream
        • Cancel Stream
        • Claim Stream
        • View methods
      • Multisig Factory
        • Create Multisig Account
      • Multisig Stream
        • Initialize Near Stream
        • Initialize Token Stream
        • Pause/Resume Stream
        • Withdraw Stream
        • Update Stream
        • Cancel Stream
        • Claim Stream
        • View methods
  • ZEBEC EVM
    • Zebec Evm Sdk
      • Zebec Stream Client
        • Creating Clients
        • Whitelisting Tokens
        • Deposit into Zebec Wallet
        • Withdraw from Zebec Wallet
        • Initiating a Stream
        • Pause/Resume/Cancel Stream
        • Updating a Stream
        • Withdraw Streamed Tokens
        • Getting Stream Details
        • Whitelisted Tokens on BSC and Nautilus
      • Zebec Bulk Client
        • Bulk Instant Transfer
      • Zebec Multisig Stream
        • NFT
    • Zapps Compatible
Powered by GitBook
On this page
  1. Zebec Bridge
  2. Bridge Sdk
  3. Withdraw Deposited

Withdraw From Zebec

Withdraw from vault to proxy accounts

At first, you have to withdraw your assets from the Zebec. To withdraw you can do as follows.

const withdrawer = signer.address

const withdrawerAddrInSolana = ZebecSolBridgeClient.getProxyUserKey(
   withdrawer,
   sourceChain,
   SOL_ZEBEC_BRIDGE_ADDRESS,
);

const tokenAddrInSolana = "<solana mint key>";
const amount = "1";

const reciept = await ethClient.withdraw(amount, withdrawer, tokenAddrInSolana);

Now you can find signed Vaa bytes of your payload sent from wormhole guardian rpc hosts.

const sequence = parseSequenceFromLogEth(
   receipt, 
   getBridgeAddressForChain(sourceChain)
);
const zebecEmitterAddress = getEmitterAddressEth(BSC_ZEBEC_BRIDGE_ADDRESS);
const { vaaBytes } = await getSignedVAAWithRetry(
   WORMHOLE_RPC_HOSTS, 
   sourceChain, 
   zebecEmitterAddress, 
   sequence
);

Now post this signed vaa to wormhole solana core bridge program, parse the payloads from vaa and send the parsed data to solana zebec bridge program. Posting vaa and calling solana bridge (also called as proxy) program. This is optional because it's handled by zebec's specialized relayer.



const payerAddress = wallet.publicKey.toString();

const bridgeAddress = getBridgeAddressForChain(targetChain);
const tokenBridgeAddress = getTokenBridgeAddressForChain(targetChain);
const vaaBuf = Buffer.from(vaaBytes);

setDefaultWasm("node"); // use bundler for browser
const { parse_vaa } = await importCoreWasm();

// posting vaa in solana
await postVaaSolanaWithRetry(
   connection,
   wallet.signTransaction,
   bridgeAddress,
   payerAddress,
   vaaBuf,
   MAX_VAA_UPLOAD_RETRIES_SOLANA,
);

const { parse_vaa } = await importCoreWasm();
const parsedVaa = parse_vaa(tes)
const parsedPayload = parseZebecPayload(Buffer.from(parsedVaa.payload));

const result = await solanaClient.withdrawDeposit(withdrawVaa, parsedPayload as TokenWithdrawPayload);
PreviousWithdraw DepositedNextToken Transfer

Last updated 2 years ago