Transfer Assets
With the Portal API’s assets/send endpoint, you can transfer both native and ERC20 tokens without the hassle of building transactions manually. Just a simple API call, and you’re set!
Steps to Send Tokens
To make your first transfer, you’ll need to use the https://mpc-client.portalhq.io/v1/assets/send
endpoint. This call requires you to include an authorization header with your clientApiKey
and set the content type to application/json
.
Here's a breakdown of the request body fields (see the full API spec here):
share (required): This represents your part of the signing key for secure transaction processing.
chain (required): The blockchain you are transacting on (e.g.,
ethereum
,solana
).to (required): The recipient address for your token transfer.
token (required): The token you are sending (e.g.,
USDC
,ETH
).amount (required): The quantity of the token to send. This should be specified in the standard unit of the token.
rpcUrl (required): The RPC URL of the blockchain network you are using (e.g., Infura for Ethereum, Alchemy for Solana).
nonce (optional): Use this field to specify the transaction order. If you plan to submit multiple transactions in quick succession, manually set the nonce values (e.g., "0x01", "0x02", etc.) to ensure they are processed in order.
metadataStr (required): A string used to include additional information or notes for your transaction.
Example: Sending 1 USDC on Ethereum
Let’s walk through an example. Say you want to send 1 USDC to the wallet address 0xdeadbeef
on the Solana blockchain. Here’s how you’d structure your request:
Understanding the Nonce Field
The nonce
is an optional field but extremely useful when you want to submit multiple transactions back-to-back without waiting for chain confirmations. By specifying nonces like "0x01", "0x02", and so on, you can ensure your transactions are queued properly and get confirmed in sequence.
Congratulations! 🎉
You’ve just learned how to easily send tokens using the Portal API. With just one API call, you can transfer assets securely and efficiently. Happy transacting!
Last updated