@kagamidigital/salt-sdk-mirror
    Preparing search index...

    Function buildTransferTransaction

    • Transforms a Transfer in to a full transaction ready for submission.

      Parameters

      Returns TransactionParams

      TransactionParams ready to pass to Salt.submitTx.

      InvalidAddress if the to address is not valid

      NotImplemented if the token standard is not supported

      import { buildTransferTransaction, TransferType } from 'salt-sdk';
      import { parseEther } from 'viem';
      import { privateKeyToAccount } from 'viem/accounts';

      // `signer` is one of the Salt account's human signers.
      const signer = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);

      const params = buildTransferTransaction({
      type: TransferType.Native,
      accountId: 'account-id', // the Salt account to send from
      to: '0xRecipientAddress',
      value: parseEther('0.1'), // wei
      userAddress: signer.address, // the calling human signer's address
      walletClient,
      publicClient,
      chainId: 11155111,
      });

      const tx = await salt.submitTx(params);
      await tx.wait();