# Transfer

Tokens and parameters are compiled in the same way as for other chains:

```
const sdk = new PixelBridgeCoreSdk(nodeRpcUrlsDefault);

const chainDetailsMap = await sdk.chainDetailsMap();
const sourceToken = chainDetailsMap[ChainSymbol.SRB].tokens.find((t) => t.symbol == "USDT");
const destinationToken = chainDetailsMap[ChainSymbol.ETH].tokens.find((t) => t.symbol == "USDT");
const amount = "2";
const sendParams: SendParams = {
  amount,
  fromAccountAddress: fromAddress,
  toAccountAddress: toAddress,
  sourceToken,
  destinationToken,
  messenger: Messenger.PixelBridge,
  extraGas: "1.15",
  extraGasFormat: AmountFormat.FLOAT,
  gasFeePaymentMethod: FeePaymentMethod.WITH_STABLECOIN,
};
const xdrTx: string = (await sdk.bridge.rawTxBuilder.send(sendParams)) as string;
```

Simulate the transaction before sending it. If some data is archived on Stellar, you have to restore it before sending the transaction. The simulation method can return a restore transaction, in this case, you have to send it first:

```
// SendTx
const srbKeypair = Keypair.fromSecret(privateKey);
const transaction = TransactionBuilder.fromXDR(xdrTx, mainnet.sorobanNetworkPassphrase);
transaction.sign(srbKeypair);
const signedTx = transaction.toXDR();

const restoreXdrTx = await sdk.utils.srb.simulateAndCheckRestoreTxRequiredSoroban(signedTx, fromAddress);
if (restoreXdrTx) {
  restoreXdrTx.sign(srbKeypair);
  const signedRestoreXdrTx = restoreXdrTx.toXDR();
  const sentRestoreXdrTx = await sdk.utils.srb.sendTransactionSoroban(signedRestoreXdrTx);
  const confirmRestoreXdrTx = await sdk.utils.srb.confirmTx(sentRestoreXdrTx.hash);
  if (confirmRestoreXdrTx.status === SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) {
    console.log(
      `Waited for Restore transaction to complete, but it did not. ` +
        `Check the transaction status manually. ` +
        `Hash: ${sentRestoreXdrTx.hash}`
    );
  } else if (confirmRestoreXdrTx.status === SorobanRpc.Api.GetTransactionStatus.FAILED) {
    console.log(`Transaction Restore failed. Check the transaction manually.` + `Hash: ${sentRestoreXdrTx.hash}`);
  } else {
    console.log(`Transaction Restore Confirmed. Hash: ${sentRestoreXdrTx.hash}`);
  }
  //generate new tx with updated sequences
  const xdrTx2 = (await sdk.bridge.rawTxBuilder.send(sendParams)) as string;
  const transaction2 = TransactionBuilder.fromXDR(xdrTx2, mainnet.sorobanNetworkPassphrase);
  transaction2.sign(srbKeypair);
  signedTx = transaction2.toXDR();
}
```

Then you have to send the main transaction. Please note that if you send a restore transaction before, the transaction sequence will be changed, and you have to recompile it:

```
const sent = await sdk.utils.srb.sendTransactionSoroban(signedTx);
const confirm = await sdk.utils.srb.confirmTx(sent.hash);
if (confirm.status === SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) {
  console.log(
    `Waited for transaction to complete, but it did not. ` +
      `Check the transaction status manually. ` +
      `Hash: ${sent.hash}`
  );
} else if (confirm.status === SorobanRpc.Api.GetTransactionStatus.FAILED) {
  console.log(`Transaction failed. Check the transaction manually.` + `Hash: ${sent.hash}`);
} else {
  console.log(`Transaction Confirmed. Hash: ${sent.hash}`);
}
```

Finally, if you make a transfer to Stellar, you have to ensure that you have trustlines for the destination token. Use the example below to check for the trustline/create it:

```
//TrustLine check and Set up for destinationToken if it is SRB
const destinationTokenSBR = sourceToken; // simulate destination is srb

const balanceLine = await sdk.utils.srb.getBalanceLine(fromAddress, destinationTokenSBR.tokenAddress);
console.log(`BalanceLine:`, balanceLine);
const notEnoughBalanceLine = !balanceLine || Big(balanceLine.balance).add(amount).gt(Big(balanceLine.limit));
if (notEnoughBalanceLine) {
  const xdrTx = await sdk.utils.srb.buildChangeTrustLineXdrTx({
    sender: fromAddress,
    tokenAddress: destinationTokenSBR.tokenAddress,
    // limit: "1000000",
  });

  //SignTx
  const keypair = StellarKeypair.fromSecret(privateKey);
  const transaction = StellarTransactionBuilder.fromXDR(xdrTx, mainnet.sorobanNetworkPassphrase);
  transaction.sign(keypair);
  const signedTrustLineTx = transaction.toXDR();

  const submit = await sdk.utils.srb.submitTransactionStellar(signedTrustLineTx);
  console.log("Submitted change trust tx. Hash:", submit.hash);
}
```


---

# 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://pixelbridge.gitbook.io/pixelbridge-core/pixelbridge-core-sdk/guides/stellar/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.
