Skip to main content
The Prime Onchain Wallet REST API provides programmatic access to the Onchain Wallet, enabling workflow automation for tasks such as sending, receiving, and onchain trading. This enhances operational efficiency, minimizes manual intervention, and ensures secure, seamless transactions across supported blockchains.

Creating an Onchain Wallet

An onchain wallet can be created using the same Create Wallet endpoint detailed in the Wallets concepts page. See below for examples on how to process this creation:
To learn more about this SDK, please visit the Prime Java SDK.

Receiving funds into Prime Onchain Wallet

This functionality works identically to deriving a deposit address for any other Prime wallet. See Deposits for more information.

Address groups

Prime Onchain Wallet utilizes address groups, which are collections of addresses organized for specific purposes, such as grouping addresses associated with a particular Uniswap pool. To list the available Onchain Address Groups, use the List Onchain Address Groups endpoint. An example request is shown below:
To learn more about this SDK, please visit the Prime Java SDK.

Creating an onchain transaction

Creating an onchain transaction is accomplished via the Create Onchain Transaction endpoint. While this endpoint processes the initiation of a transaction, please note:
  • The transaction still requires signing through the standard Onchain wallet flows.
  • Consensus approval still applies if required by the portfolio’s transfer rules.
When specifying the chain ID, it is important to remember that it is a numeric code representing the blockchain network. For example, the chain ID for Base is 8453. Other network codes can be looked up at Chainlist. For how to build the raw_unsigned_txn value for EVM and Solana transactions, including contract calls, see Building the raw unsigned transaction. See below for an example request.
To learn more about this SDK, please visit the Prime Java SDK.

Building the raw unsigned transaction

The raw_unsigned_txn field takes a complete, unsigned transaction, serialized and hex-encoded. A leading 0x is optional. Prime signs the transaction with the wallet in the request path, so the transaction does not need a sender field or a signature. The examples below use Python and reproduce the EVM and Solana examples in the API reference. Install the Python packages used in the examples:

Dynamic nonce and gas (EVM)

By default, Prime sets the nonce and gas fees of EVM transactions before signing (evm_params.disable_dynamic_nonce and evm_params.disable_dynamic_gas both default to false). With these defaults, set the nonce and fee fields to 0 in the transaction you build. To control either value yourself, set it in the transaction and set the matching disable_dynamic_* option to true. To speed up or cancel a pending transaction, pass its ID in evm_params.replaced_transaction_id and leave dynamic nonce enabled.

EVM transactions

Prime expects EIP-1559 (type 2) transactions. Fields in an RLP-encoded transaction are positional, so a field you want Prime to set is encoded as 0 rather than omitted.
In RLP, the integer 0 is encoded as the single byte 0x80 (an empty string), not 0x00. The rlp package used below handles this for you. If you encode the transaction another way, write 0x80 for each zero-valued field.
evm_params is required for EVM wallets and must include chain_id. Set the chain ID in the transaction and in evm_params.chain_id, and make sure they match.

Encoding contract calls (EVM)

For a contract call, data is the 4-byte function selector followed by the ABI-encoded arguments. The selector is the first 4 bytes of the Keccak-256 hash of the canonical function signature, such as transfer(address,uint256). If you have the contract’s ABI, for example from the contract’s verified source on a block explorer, use web3.py to encode the call. The ABI entry validates the argument types for you.
If you only know the function signature, encode the selector and arguments directly. Write the signature with canonical types (uint256, not uint), no spaces, and no parameter names.
Struct arguments are encoded as tuples. List the struct’s field types in parentheses, and pass the value as a Python tuple in field order. For example, Uniswap V3 exactInputSingle:
Token decimals vary. USDC and USDT use 6 decimals, and most other ERC-20 tokens use 18. For proxy contracts, use the implementation contract’s ABI with the proxy address as to. To check your encoding, decode it with contract.decode_function_input(data) before submitting.

Solana transactions

Prime expects a versioned (v0) transaction with an empty signature slot for the Prime Onchain Wallet in the request path. In the common case, the Onchain Wallet is the fee payer and the only signer, as in the examples below. If the transaction requires other signers, collect their signatures before you submit it: Prime adds its signature to the first empty signature slot. Omit evm_params for Solana wallets. Requests that include it are rejected.
When Prime signs a transaction whose signature slots are all empty, it replaces the transaction’s blockhash with a recent one. You don’t need to fetch a blockhash yourself; any value works, such as the all-zero default:
If the transaction already includes another signer’s signature, Prime does not replace the blockhash, because changing it would invalidate that signature. Build the transaction with a recent blockhash, for example from Client(rpc_url).get_latest_blockhash().value.blockhash in solana-py.A blockhash expires after about 150 blocks (roughly one minute), and the transaction must be approved, signed, and broadcast before then. If the portfolio requires consensus approval, the transaction can expire before it is approved.
The instructions you pass determine what the transaction does. A native SOL transfer, with optional compute budget instructions that set a priority fee:
An SPL token transfer, such as USDC. The transfer goes to the recipient’s associated token account for the mint. The idempotent create instruction creates that account if it doesn’t exist yet and does nothing if it does, so you can always include it.
A call to a custom program. Take the account order, signer and writable flags, and argument layout from the program’s IDL. For programs built with Anchor, the instruction data starts with an 8-byte discriminator, followed by the Borsh-encoded arguments.

Common mistakes