Enclave MPC API Quick Start
This quick start guide will get you up and running with the Portal MPC API.
Last updated
This quick start guide will get you up and running with the Portal MPC API.
Last updated
The Enclave MPC API lives at mpc-client.portalhq.io
. This API allows you create, backup, and recover Portal MPC Wallets. It also allows you to sign messages and transactions for EVM and Solana chains.
The Portal MPC API is authenticated with a Client API Key or Client Session Token via a Bearer
token in the Authorization
header of your requests. You can get a test Client API Key from the Portal Dashboard in the Settings
-> Test Client API Keys
section. Simply click the New +
button.
In order to create a new wallet, you can use /v1/generate
route.
The response of this request will contain the shares of a Portal Wallet - a dictionary keyed by the elliptical curve associated with the share. The value of each key will be a dictionary containing the share
and id
of that curve's share.
SECP256K1
represents an EVM share and ED25519
represents a Solana share.
You've just generated a Portal Wallet!
Now let's let the backend know that we've successfully stored the response.
We'll do this by sending a PATCH
request updating the state of the signing shares of our Portal Wallet to indicate that we've successfully stored the shares.
In your production build, be sure to store the full response object in a secure location.
For this guide, just save the shares off to the side.
Pass in the id
values for each of the SECP256K1
and ED25519
objects.
This will return a 204 on success.
To see the addresses for the the different chains supported by your Portal Wallet send a request to the Get Client Details endpoint.
Check out the Get Client Details API reference to learn about the other values that are returned, but for this guide you can skip down to the metadata.namespaces
property to see the list of addresses associated with your Portal Wallet.
Example Response
The namespaces correlate to CAIP-2 blockchain IDs for unique chain-agnostic identification. So all EVM-based chains (Ethereum, Polygon, Optimism, Base, etc...) will use the eip155
address.
Go ahead and save the eip155
address and the solana
address off to the side.
If you have jq
installed you can use the following command to easily parse the values.
Your Portal Wallet is now ready for signing!
To sign and submit a transaction, we will use the /v1/assets/send
route. This endpoint simplifies the process for transferring "assets" - native tokens, ERC-20 tokens, and Solana SPL tokens - across all Portal supported chains. It takes as parameters:
share
- the share
string value for the specific curve you want to
chain
- the blockchain network (e.g. "ethereum", "sepolia", "solana", "solana-devnet", or a CAIP-2 chain ID like "eip155:11155111")
token
- the token contract address (for ERC20 tokens on EVM chains) or the mint address (for Solana SPL tokens). You can also use "USDC"
or "USDT"
for the respective tokens. For native token transfers, use the native token symbol like "ETH"
or simply "NATIVE"
.
to
- the address you want to send to
amount
- the human readable amount you want to send (e.g. "0.1" is 0.1 USDC)
rpcUrl
- the URL to be used for outbound RPC requests such as submitting to chain (you can default to the Portal RPC URL for this endpoint)
If you want to define the transaction or message to sign use the /v1/sign
route to sign any message!
If you try to transfer more funds that are available in your wallet you'll see the insufficient funds for gas * price + value
message in the error response:
Make sure you have enough Sepolia ETH and that you supplied the correct chain.
If the JSON request body is malformed you'll see the Can't parse the requests body
message in the error response.
Make sure your request body is properly formatted.
Let's use the Ethereum Sepolia testnet to send our first EVM transaction. Visit sepoliafaucet.io, or another testnet faucet, to get some testnet Sepolia ETH.
Once you've successfully collected some Sepolia ETH, you'll be able to view your balance on the blockchain explorer, in this case https://sepolia.etherscan.io/. Add your eip155
address to see your Sepolia ETH balance.
We are now ready to send an EVM transaction!
share
- use the string value associated with the share
property of the SECP256K1
object returned in the generate response
chain
- set the value to sepolia
which is a shorthand for Ethereums Sepolia testnet
token
- we'll use ETH
but we also could use NATIVE
to indicate we want to transfer the native ETH token on Sepolia
to
- we've added a test address to transfer funds to
amount
- we should have 0.01 Sepolia ETH, so we'll transfer 0.001 of it
rpcUrl
- the default Portal RPC URL
Example Response
On a successful submission you will receive a 200 and a similar response body:
You can search the transactionHash
on sepolia.etherscan.io to see the details on the blockchain explorer.
You've just signed and submitted your first EVM transaction with a Portal Wallet!
Let's use the Solana Devnet to send our first Solana transaction. Visit faucet.solana.com, or another faucet, to get some Solana Devnet SOL tokens.
Once you've successfully collected some Devnet SOL, you'll be able to view your balance on the blockchain explorer, in this case solscan.io/?cluster=devnet. Add your solana
address to see your Devnet SOL balance.
We are now ready to send a Solana transaction!
share
- use the string value associated with the share
property of the ED25519
object returned in the generate response
chain
- set the value to solana-devnet
which is a shorthand for Solana Devnet
token
- we'll use NATIVE
to indicate we want to transfer the native SOL token on Solana Devnet
to
- we've added a test address to transfer funds to
amount
- we'll transfer 0.001 of our Devnet SOL
Example Response
On a successful submission you will receive a 200 and a similar response body:
You can search the transactionHash
on solscan.io/?cluster=devnet to see the details on the blockchain explorer.
You've just signed and submitted your first Solana transaction with a Portal Wallet!