# Token Transfer

Token transfer can be done in following way.

```typescript
const amount = "0.1";
const sender = signer.address;
const tokenMint = "AbLwGR8A1wvsiLWrzzA5eYPoQw51NVMcMMTPvAv5LTJ";
const receiver = sender;
const sourceChain = CHAIN_ID_BSC;

const receipt = await ethClient.directTransfer(amount, sender, tokenMint, receiver);
```

You might have noticed that receiver and sender are same here, it's because the transfer will performed from the sender's proxy account in Solana to own account in evm.

&#x20;Then the vaa can be obtained after this and it must  be posted in solana chain.

```typescript
const sequence = parseSequenceFromLogEth(receipt, getBridgeAddressForChain(sourceChain));
const emitterAddress = getEmitterAddressEth(BSC_ZEBEC_BRIDGE_ADDRESS);
const { vaaBytes } = await getSignedVAAWithRetry(
	WORMHOLE_RPC_HOSTS,
	sourceChain,
	emitterAddress,
	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.

```typescript
const payerAddress = wallet.publicKey.toString();
const bridgeAddress = getBridgeAddressForChain(targetChain);
const vaaBuf = Buffer.from(vaaBytes);

setDefaultWasm("node"); // use bundler for browser

// 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(vaaBytes);
const parsedPayload = parseZebecPayload(Buffer.from(parsedVaa.payload));

const result = await solanaClient.directTokenTransfer(
   vaaBytes,
   <DirectTokenTransferPayload>parsedPayload
);
```

Then the zebec bridge program makes cpi call to token bridge program for asset transfer to evm chain. The asset is automatically redeemed by the token bridge relayer. For manual redeeming, you need to get signed vaa by emitted from token bridge and redeem asset in evm using the payload in that vaa.

<pre class="language-typescript"><code class="lang-typescript">if (!result.data) {
   throw new Error("data is missing in solana client result.");
}

const executionSignature = result.data.signatures[result.data.signatures.length - 1];
<strong>const transactionResponse = await connection.getTransaction(executionSignature);
</strong>
if (!transactionResponse) {
   throw new Error("Could not find Transaction");
}
		
const anotherSequence = parseSequenceFromLogSolana(transactionResponse);
const tokenBridgeEmitterAddress = await getEmitterAddressSolana(SOL_TOKEN_BRIDGE_ADDRESS);
const { vaaBytes: tokenBridgeVaa } = await getSignedVAAWithRetry(
   WORMHOLE_RPC_HOSTS,
   "solana",
   tokenBridgeEmitterAddress,
   anotherSequence,
);
const tokenBridgeAddress = getTokenBridgeAddressForChain(sourceChain);
const bridge = Bridge__factory.connect(tokenBridgeAddress, signer);
const tx = await bridge.completeTransfer(tokenBridgeVaa);
const receipt = await tx.wait();
console.log("receipt", receipt.transactionHash);
</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zebec.io/zebec-bridge/bridge-sdk/withdraw-deposited/token-transfer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
