# Authentication Source: https://docs.p2p.org/docs/authentication Get your authentication token Staking Platform APIs use bearer JSON Web Token (JWT). Each client is assigned a unique authentication token for secure access to the service. Contact [support@p2p.org](mailto:support@p2p.org) with your request, and you'll receive your authentication token directly via email or direct message. Specify the received authentication token when interacting with our APIs. Pass the token in the Authorization header in the following format: ```text HTTP headers theme={null} Authorization: Bearer ``` # Cardano Transaction Signing Source: https://docs.p2p.org/docs/cardano-transaction-signing Sign and broadcast Cardano transactions built with the P2P.org Unified API. To sign and broadcast the transaction to the Cardano network, follow these steps: 1. Prepare unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) in Base64 encrypted format. 2. Sign the transaction using the following code: ```javascript JavaScript theme={null} import { Bip32PrivateKey, Transaction, TransactionHash, TransactionWitnessSet, Vkey, Vkeywitness, Vkeywitnesses, } from "@emurgo/cardano-serialization-lib-nodejs"; import { mnemonicToEntropy } from "bip39"; import { blake2b } from "blakejs"; const MNEMONIC = ""; const RAW_TX_HEX = ""; function deriveKey(mnemonic: string, role: number, index = 0): Bip32PrivateKey { const entropy = Buffer.from(mnemonicToEntropy(mnemonic), "hex"); const rootKey = Bip32PrivateKey.from_bip39_entropy(entropy, Buffer.from("")); return rootKey .derive(1852 | 0x80000000) // purpose .derive(1815 | 0x80000000) // coin type .derive(0 | 0x80000000) // account 0 .derive(role) // role: 0=payment, 2=stake .derive(index); // index } function signTransactionHex( unsignedHex: string, paymentKey: Bip32PrivateKey, stakeKey: Bip32PrivateKey ): string { const tx = Transaction.from_bytes(Buffer.from(unsignedHex, "hex")); const txHashBytes = blake2b(tx.body().to_bytes(), undefined, 32); const txHash = TransactionHash.from_bytes(txHashBytes); const witnesses = Vkeywitnesses.new(); // Payment key witness const rawPaymentKey = paymentKey.to_raw_key(); witnesses.add( Vkeywitness.new( Vkey.new(rawPaymentKey.to_public()), rawPaymentKey.sign(txHash.to_bytes()) ) ); // Stake key witness const rawStakeKey = stakeKey.to_raw_key(); witnesses.add( Vkeywitness.new( Vkey.new(rawStakeKey.to_public()), rawStakeKey.sign(txHash.to_bytes()) ) ); const witnessSet = TransactionWitnessSet.new(); witnessSet.set_vkeys(witnesses); const signedTx = Transaction.new(tx.body(), witnessSet, tx.auxiliary_data()); return Buffer.from(signedTx.to_bytes()).toString("hex"); } async function main() { if (!RAW_TX_HEX || RAW_TX_HEX.length < 10) { throw new Error("❌ RAW_TX_HEX is missing or invalid."); } const paymentKey = deriveKey(MNEMONIC, 0); // m/1852'/1815'/0'/0/0 const stakeKey = deriveKey(MNEMONIC, 2); // m/1852'/1815'/0'/2/0 const signedHex = signTransactionHex(RAW_TX_HEX, paymentKey, stakeKey); console.log("✅ Signed Cardano Tx (hex):"); console.log(signedHex); } main().catch(console.error); ``` Upon successful execution, the script prints the signed transaction in hexadecimal format, ready to be broadcasted: ```bash bash theme={null} ✅ Signed Cardano Tx (hex): ... ``` 3. Broadcast the transaction to the Cardano network by sending a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). # Contacts Source: https://docs.p2p.org/docs/contacts We're here to help! Experiencing issues or need help? Don't worry, our product team is here for you. We are committed to resolving any problems you might be facing as quickly and efficiently as possible. Email [support@p2p.org](mailto:support@p2p.org) and include your question to ensure that we can assist you effectively. # Delegator Source: https://docs.p2p.org/docs/data-delegator Staking Data API provides methods to retrieve essential information about delegators within the network. These endpoints offer insights into a delegator's current stake, rewards received, Annual Percentage Yield (APY), associated fees, and other information. ## Methods Unless stated otherwise, the `startAt`–`finishAt` range cannot exceed 31 days, and `finishNumber` cannot be lower than `startNumber`. The `addressType` values accepted by each network are listed in [Getting Started](/docs/getting-started-data-api#get-delegator-stake). ### Get Delegator Summary **Endpoint:** [GET /api/v1/\{network}/data/delegator/summary](/reference/data-delegator-summary) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to obtain the basic general information about a delegator for the period, such as a list of rewards earned by the delegator, the current stake, and the gross and net APY (`grossApy`, `netApy`) associated with the delegator. ### Get Delegator Stake **Endpoint:** [GET /api/v1/\{network}/data/delegator/stakes](/reference/data-delegator-stakes) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to monitor the current stake of a delegator. Regularly check the stake data to assess the delegator's commitment and participation in the network. `groupBy` selects the aggregation: `stakingPeriod` aggregates by epoch, `day` by calendar day, `all` over the whole requested period. `groupBy=day` cannot be combined with `startNumber` / `finishNumber`; use `startAt` / `finishAt` instead, otherwise the request returns `400`. `stake` is the total stake balance of the delegator. On Ethereum it includes ETH that is still in the deposit or activation queue. With `groupBy=day` on Ethereum, the response additionally contains the optional fields `activeStake` (already active on the Beacon Chain) and `inactiveStake` (still waiting to be activated), which together make up `stake`. Historical Ethereum data is available from 2024-01-01. ### Get Delegator Rewards **Endpoint:** [GET /api/v1/\{network}/data/delegator/rewards](/reference/data-delegator-rewards) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to track the rewards earned by the delegator. Monitor reward data to assess the delegator's performance and profitability. Use `rewardTypes` to filter by reward type and `skip=validator` to drop the per-validator breakdown. ### Get Delegator APY **Endpoint:** [GET /api/v1/\{network}/data/delegator/apy](/reference/data-delegator-apy) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to understand the APY associated with the delegator. The response contains `grossApy` (before the validator fee) and `netApy` (after the fee). Regularly check APY data for insights into the delegator's long-term performance. ### Get Total Delegator Rewards **Endpoint:** [GET /api/v1/\{network}/data/delegator/total-rewards](/reference/data-delegator-total-rewards) **Supported networks:** Ethereum. **Description:** Utilize this endpoint to track the total rewards earned by the delegator over its lifetime. ### Get Delegator APR **Endpoint:** [GET /api/v1/\{network}/data/delegator/apr](/reference/data-delegator-apr) **Supported networks:** Ethereum. **Description:** Utilize this endpoint to obtain the lifetime Annual Percentage Rate (APR) of the delegator, returned as `apr`. Only `address` is required. ### Get Delegator Rewards (SSV) **Endpoint:** [GET /api/v1/\{network}/data/delegator/ssv](/reference/data-delegator-ssv) **Supported networks:** Ethereum. **Description:** Utilize this endpoint to obtain the monthly SSV rewards for a delegator address. Each item covers one `month` and contains `distributedAmount`, `claimedAmount`, `predictedAmount`, the P2P `fee`, and `netAmount` (claimed minus fee). # Getting Started Source: https://docs.p2p.org/docs/defi-api-getting-started Simplify your work with decentralized assets with DeFi API from P2P.ORG. > [!NOTE] > > This article describes how the DeFi API process works in general. To see detailed guides for a specific protocol, refer to the [Protocols Supported](/docs/defi-api-protocols) section. The DeFi API supports the complete transaction lifecycle, from creation through execution. When a user initiates a deposit action, the API constructs the necessary transaction, awaits user signing, and submits it to the blockchain network. The API includes the major group of [transaction endpoints](/reference/get-transaction-schema), with the `transactions/steps/craft` method serving as the primary interface for transaction creation—handling approximately 95% of operations. The data part with endpoints for getting details on earnings, positions, and rewards is also provided. ## Action types Currently, each vault integration supports the following operations: * `approvePermit2`: Allow the P2P.ORG smart contract to manage tokens by obtaining approval. * `deposit`: Initiate a deposit transaction to delegate the assets. * `withdraw`: Withdraw the assets to the wallet. To start using the DeFi API, [get an authentication token](/docs/authentication). ## General flow 1. Get a schema with the step list. To retrieve a schema describing which transactions are required for a specified action, protocol, chain, and strategy, send a GET request to [/api/defi/v1/transactions/schema](/reference/get-transaction-schema). 2. Upon the schema retrieved, construct the required transactions. Depending on the action type and the request data, a schema may include up to 3 transactions. To initiate the constructing process, send a POST request to [/api/defi/v1/transactions/steps/craft](/reference/craft-transaction-step). Upon each request, a raw unsigned transaction is generated. 3. Sign each transaction using the [transaction-type-specific libraries](/docs/defi-api-signing-transaction). 4. Check the status of the constructed transaction by using the [/api/defi/v1/transactions/steps/result](/reference/get-step-result) endpoint. If the schema contains several transactions, for [intermediate transactions](/docs/defi-api-signing-transaction), you may use a [/api/defi/v1/transactions/steps/status](/reference/get-step-status) endpoint. 5. Broadcast the final transaction to the network by sending a POST request to [/api/defi/v1/transactions/broadcast](/reference/broadcast-transaction). # Overview Source: https://docs.p2p.org/docs/defi-api-overview The P2P.ORG DeFi API is a specialized solution designed for institutions, exchanges, and wallet providers seeking to integrate seamless staking functionality directly into their platforms. Building upon the proven success of the — a visual interface enabling users to deposit tokens across multiple protocols and vaults — this API offers the same robust capabilities in a flexible, native integration format. [Get an authentication token](/docs/authentication) to start using DeFi API. ## Key features * **Comprehensive Protocol Coverage**. Users can deposit various tokens across multiple supported protocols and vaults, all through a single integration point. * **Flexible Integration Options**. Direct integration for complete control over the transaction flow and P2P.ORG proxy contracts for simplified deployment. * **Enhanced Security**. The P2P.ORG DeFi API implements a three-module verification system. Every transaction undergoes dual verification—during creation and at signing—ensuring only authorized, P2P.ORG-generated transactions are processed, protecting users from malicious activities. ## Supported chains and networks See all [Protocols Supported](/docs/defi-api-protocols). Currently, integration with [Morpho vaults](https://app.morpho.org/) is supported. # Protocols Supported Source: https://docs.p2p.org/docs/defi-api-protocols The table below summarizes all protocols supported in the DeFi API and the `protocol` and `chain` parameters that are required for the crafting endpoint: | `protocol` | Networks | `chain` | | - | - | - | | [Morpho](/docs/morpho) | Ethereum | `mainnet`, `base` | You can also get the full list of all supported protocols and networks through the GET request to [/api/defi/v1/earning/protocols](/reference/get-protocols). The list of available strategies may vary dynamically. To see the most up-to-date list for each protocol, make an API request to [/api/defi/v1/earning/strategies](/reference/get-strategies). ## Environments We provide one endpoint for production environment: [edge.p2p.org](https://edge.p2p.org) Note that DeFi API is only supported on mainnet, no testnet is provided. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/defi-api-signing-transaction To complete any action using the DeFi API, sign the final unsigned transaction and broadcast it to the network. ## 1. Prepare unsigned transaction Obtain the unsigned transaction object either in the `encoded` or `json` format provided by the [Craft Transaction Step](/reference/craft-transaction-step) endpoint. ## 2. Sign transaction Since the DeFi API flow is determined by the individual schema depending on the action type, protocol, and strategy, construction of multiple transactions may be required. As a result, there are two types of unsigned transaction objects provided by the DeFi API — *intermediate* and *final*. * *Intermediate transactions* are typically required to grant permissions to smart contracts involved in the integration process. These objects need a signature, as they must be included in the payload of the final transaction, but there is no need to broadcast such transactions to the network. * *Final transactions*, on the other hand, require both signing and broadcasting. The steps at which these transactions are constructed have the word "final" in their name and are executed last according to the schema's order. Such objects must contain the data of all intermediate transactions in the payload. Check your transaction object type and sign it using the examples of code provided below. > [!WARNING] > > **Note that for intermediate and final types, different signing libraries are used.** > > It is possible to sign the final transaction with the code for the intermediate one, but this will lead to the validation error on attempting to broadcast such a transaction to the network. ### For intermediate transactions > NB: signing only, no broadcasting. Use any of the code examples for the `base` network below. ```javascript With private key theme={null} import { signTypedData, sign, serializeSignature, privateKeyToAccount, } from 'viem/accounts'; import { createWalletClient, custom } from 'viem'; import { base } from 'viem/chains'; // Example API response shape // response = { json: { domain, types, primaryType, message }, encoded: "0x..." } // ----------------------------------------------------------------------------- // 1. With private key — use response.json (typedData) // ----------------------------------------------------------------------------- async function signResponseWithPrivateKey(privateKey, response) { const privateKeyHex = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`; const account = privateKeyToAccount(privateKeyHex); const { json: typedData } = response; return signTypedData({ account, domain: typedData.domain, types: typedData.types, primaryType: typedData.primaryType, message: typedData.message, }); } // ----------------------------------------------------------------------------- // 2. With private key — use response.encoded (hash only) // ----------------------------------------------------------------------------- async function signResponseHashWithPrivateKey(privateKey, response) { const privateKeyHex = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`; const hashHex = response.encoded.startsWith('0x') ? response.encoded : `0x${response.encoded}`; const sig = await sign({ privateKey: privateKeyHex, hash: hashHex, }); return serializeSignature(sig); } ``` ```javascript Via provider theme={null} import { signTypedData, sign, serializeSignature, privateKeyToAccount, } from 'viem/accounts'; import { createWalletClient, custom } from 'viem'; import { base } from 'viem/chains'; // Example API response shape // response = { json: { domain, types, primaryType, message }, encoded: "0x..." } // ----------------------------------------------------------------------------- // 3. Via provider (frontend) — use response.json (typedData), preferred // ----------------------------------------------------------------------------- async function signResponseViaProvider(provider, response) { const walletClient = createWalletClient({ chain: base, transport: custom(provider), }); const [address] = await walletClient.getAddresses(); if (!address) throw new Error('Wallet not connected'); const { json: typedData } = response; return walletClient.signTypedData({ account: address, domain: typedData.domain, types: typedData.types, primaryType: typedData.primaryType, message: typedData.message, }); } // ----------------------------------------------------------------------------- // 4. Via provider (frontend) — use response.encoded (hash only), eth_sign // ----------------------------------------------------------------------------- async function signResponseHashViaProvider(provider, response, address) { const hashHex = response.encoded.startsWith('0x') ? response.encoded : `0x${response.encoded}`; if (hashHex.length !== 66) throw new Error('Hash must be 32 bytes (66 hex chars with 0x)'); return provider.request({ method: 'eth_sign', params: [address, hashHex], }); } ``` ### For final transactions > NB: contain the word "final" in the step name; require signing and broadcasting. Use any of the code examples for the `base` network below. ```javascript With private key theme={null} import { createWalletClient, custom, http, parseTransaction } from 'viem'; import { privateKeyToAccount, signTransaction } from 'viem/accounts'; import { base } from 'viem/chains'; // Example API response shape // response = { json: { domain, types, primaryType, message }, encoded: "0x..." } // ----------------------------------------------------------------------------- // 1. With private key — use response.encoded (raw hex), then sign // ----------------------------------------------------------------------------- async function signRawTransactionWithPrivateKey(privateKey, response, rpcUrl) { const privateKeyHex = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`; const account = privateKeyToAccount(privateKeyHex); const rawTxHex = response.encoded.startsWith('0x') ? response.encoded : `0x${response.encoded}`; const transaction = parseTransaction(rawTxHex); const walletClient = createWalletClient({ chain: base, account, transport: http(rpcUrl), }); const request = await walletClient.prepareTransactionRequest({ ...transaction, gas: transaction.gas, }); return walletClient.signTransaction(request); // signed hex "0x02..." } // ----------------------------------------------------------------------------- // 2. With private key — use response.json (transaction object), then sign // ----------------------------------------------------------------------------- async function signTransactionObjectWithPrivateKey(privateKey, response, rpcUrl) { const privateKeyHex = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`; const account = privateKeyToAccount(privateKeyHex); const txRequest = response.json; // { to, data, value, gas, nonce, chainId, maxFeePerGas, maxPriorityFeePerGas, type } const walletClient = createWalletClient({ chain: base, account, transport: http(rpcUrl), }); const prepared = await walletClient.prepareTransactionRequest(txRequest); return walletClient.signTransaction(prepared); } // ----------------------------------------------------------------------------- // 3. With private key — sign only (no RPC), from encoded, using viem/accounts // ----------------------------------------------------------------------------- async function signRawTransactionWithPrivateKeyNoRpc(privateKey, response) { const privateKeyHex = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`; const rawTxHex = response.encoded.startsWith('0x') ? response.encoded : `0x${response.encoded}`; const transaction = parseTransaction(rawTxHex); const signedHex = await signTransaction({ privateKey: privateKeyHex, transaction, }); return signedHex; } ``` ```javascript Via provider theme={null} import { createWalletClient, custom, http, parseTransaction } from 'viem'; import { privateKeyToAccount, signTransaction } from 'viem/accounts'; import { base } from 'viem/chains'; // Example API response shape // response = { json: { domain, types, primaryType, message }, encoded: "0x..." } // ----------------------------------------------------------------------------- // 4. Via provider (frontend) — use response.encoded (raw hex), wallet signs // ----------------------------------------------------------------------------- async function signRawTransactionViaProvider(provider, response) { const rawTxHex = response.encoded.startsWith('0x') ? response.encoded : `0x${response.encoded}`; const transaction = parseTransaction(rawTxHex); const walletClient = createWalletClient({ chain: base, transport: custom(provider), }); const [address] = await walletClient.getAddresses(); if (!address) throw new Error('Wallet not connected'); const request = await walletClient.prepareTransactionRequest({ ...transaction, gas: transaction.gas, account: address, }); return walletClient.signTransaction(request); } // ----------------------------------------------------------------------------- // 5. Via provider (frontend) — use response.json (transaction object) // ----------------------------------------------------------------------------- async function signTransactionObjectViaProvider(provider, response) { const walletClient = createWalletClient({ chain: base, transport: custom(provider), }); const [address] = await walletClient.getAddresses(); if (!address) throw new Error('Wallet not connected'); const request = await walletClient.prepareTransactionRequest({ ...response.json, account: address, }); return walletClient.signTransaction(request); } ``` ## 3. Broadcast signed final transaction > NB: required for final transaction type only. To submit the final transaction to the network, send a POST request to [/api/defi/v1/transactions/steps/broadcast](/reference/broadcast-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url 'https://edge.p2p.org/api/defi/v1/transactions/steps/broadcast' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "chain": "base", "protocol": "morpho", "strategy": "Steakhouse USDC", "signedPayload": "0x…" }' ``` * `signedTransaction` — signed final transaction in the hexadecimal format which needs to be broadcasted to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "transactionHash": "0x1234567890abcdef..." }, "meta": { "time": 0, "requestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6" } } ``` * `transactionHash` — hash of the final transaction. * `time` — request execution time in ms. * `requestId` — unique identifier of the request. # Direct staking v1-v3 Source: https://docs.p2p.org/docs/direct-staking ## P2P Direct Staking: Eth2 Depositor & Message Sender Flow > [!WARNING] > > **Action required for integrators with smart contract allowlists** > > The API now returns unsigned transactions targeting the [new contract](/docs/direct-staking#p2peth2depositor-v3). > > If your application validates the `to` address against a hardcoded list, you must add this address before your next transaction. Client‑side rejection of these transactions is the only breaking change; the previous P2pEth2Depositor remains usable on-chain, no migration required for existing integrations. ### Non-Custodial On-Chain Deposit (via P2pEth2Depositor) Diagram 1: Direct Deposit Flow for P2pEth2Depositor (v1) ```mermaid theme={null} sequenceDiagram autonumber participant Client (Validator Owner) participant P2pEth2Depositor participant BeaconDepositContract participant P2P Infra (Observer) Client->>P2pEth2Depositor: deposit(pubkey[], withdrawalCreds, signatures, roots)\nwith 32 ETH * N activate P2pEth2Depositor loop For each validator P2pEth2Depositor->>BeaconDepositContract: deposit(pubkey, withdrawalCreds, signature, root)\nwith 32 ETH end P2pEth2Depositor-->>Client: emit DepositEvent(msg.sender, count) deactivate P2pEth2Depositor P2P Infra (Observer)-->>P2P Infra (Observer): Listens for DepositEvent ``` ETH is atomically forwarded to the official Beacon chain deposit contract — no ETH is ever held or pooled. In P2P.org’s direct staking v1 flow, users stake ETH without ever giving custody of their funds to P2P. The key on-chain component is the **P2pEth2Depositor** smart contract, which atomically forwards the user’s ETH to Ethereum’s official deposit contract. The flow is as follows: 1. **User Initiates Deposit:** The user (validator owner) generates or obtains the required deposit data (validator BLS public key, withdrawal credential, signature, etc.) and sends a transaction calling `P2pEth2Depositor.deposit(...)` with this data. The call includes the exact ETH required (32 ETH per validator) for one or multiple validator deposits. The contract enforces that the caller sends the correct amount of ETH — it requires `msg.value` to equal 32 ETH \* number\_of\_validators and allows batching up to 100 validators in one transaction. (This batching is purely for gas efficiency; each validator still gets a distinct 32 ETH deposit.) **For v3 batcher deposits**: The API returns an unsigned transaction whose `to` address points to the new deposit contract (0x...). The user signs and broadcasts this transaction. The new contract atomically forwards ETH to the official `BeaconDepositContract` exactly like the legacy contract. The direct `P2pEth2Depositor` path remains functional for backward compatibility. 2. **Atomic Deposit to Beacon Chain:** Inside the `deposit(...)` function, P2pEth2Depositor immediately forwards the ETH to the official Eth2 DepositContract for each validator. It iterates over the provided list of validator pubkeys and calls `depositContract.deposit{value: 32 ETH}(pubkey, withdrawal_credential, signature, deposit_data_root)` for each one. This means the user’s ETH is transferred directly into the **Beacon Chain deposit contract** within the same transaction that the user sent, without any intermediate holding account. If any deposit in the batch fails (e.g., invalid data), the entire transaction reverts, ensuring no partial custody or leftover funds – it’s all-or-nothing and handled atomically on-chain. 3. **No P2P Custody or Pools:** The design explicitly prevents P2P or the proxy contract from holding the ETH. The P2pEth2Depositor contract does not accept free-floating ETH transfers at all – its fallback/receive function immediately reverts any direct ETH sent to it. This guarantees that users can only send ETH through the `deposit` function (which forwards it onward). In other words, P2P never aggregates user ETH in its own wallet or contract; the stake goes straight from the user’s address to the official deposit contract (under the user’s withdrawal credentials) in one step. 4. **Event Emission:** After successfully processing the deposits, P2pEth2Depositor emits a `DepositEvent` recording the sender’s address and the number of validators deposited. This on-chain event serves as a record that the deposit transaction for those validators was completed. (The event does not contain the validator pubkeys or other details, just a count, since P2P already knows which keys were included based on the transaction data.) **For v3 batcher deposits**, the new contract does not emit a custom `DepositEvent`; instead, P2P’s monitoring (MW) listens directly to the Beacon chain deposit contract for deposit logs. This means deposit detection is fully native. ### Validator Key Management & Withdrawal Credentials A core principle of this direct staking flow is that the user retains control of withdrawal rights, while validator operation is handled by P2P. In practice, this means **the user’s chosen withdrawal credential is used for the deposit, and P2P never controls the withdrawal of the staked ETH or rewards.** P2P’s system is non-custodial by ensuring the roles of the two key pairs are separated: * **Validator Keys (BLS Signing Keys):** These are the keys that actually run the validator (sign attestations, propose blocks, and sign the deposit and exit messages). In the v1 flow, the user delegates validator key management to P2P’s infrastructure. In many cases, P2P (and/or a Distributed Validator Technology like SSV) generates or holds the BLS validator private keys to operate the validators on behalf of the user. The user does not need to run the validator node; P2P handles all “live” validator duties. Importantly, these validator keys are also required to initiate a voluntary exit (they must sign the exit message when the user wants to stop validating). * **Withdrawal Credentials/Keys:** The withdrawal credential defines where validator withdrawals (refund of 32 ETH and earned rewards) will be paid out on the execution layer. In direct staking v1, the client (user) maintains custody of the withdrawal credential. Typically, the withdrawal credential is set to an **Ethereum address controlled by the user** (a 0x01 credential, hashed from the user’s ETH address). This means when withdrawals are enabled, the unlocked ETH will go directly to the user’s own wallet. P2P does **not** hold the withdrawal private key and cannot unilaterally withdraw or move the staked funds — this is what makes the setup *non-custodial*. (In some setups, the withdrawal credential could point to a smart contract that trustlessly splits fees, but it would still be a pre-set address that P2P cannot change or divert; P2P v1 generally had the user’s address as the withdrawal target to ensure P2P never controls the funds.) By structuring key ownership this way, the user’s capital is secure from P2P or any third-party misappropriation. P2P’s role is limited to validator operations, while the user’s role is to ultimately control the funds at withdrawal. This **“user holds withdrawal key, operator holds validator key”** model is explicitly highlighted by P2P: the client preserves custody of withdrawal credentials, delegating only the validator key management to P2P. The trade-off is that the user must trust P2P to manage the validator key honestly (e.g., not to double-sign or to properly sign an exit when asked), but P2P cannot steal or redirect the stake or rewards because it lacks the withdrawal key. ### On-Chain Signaling & Validator Exit via **P2pMessageSender** Diagram 2: Validator Exit via On-Chain Signal ```mermaid theme={null} sequenceDiagram autonumber participant Client (Validator Owner) participant P2pMessageSender participant P2P Backend participant Beacon Chain Client->>P2pMessageSender: send("exit validator X") activate P2pMessageSender P2pMessageSender-->>Client: emit Message(msg.sender, "exit validator X") deactivate P2pMessageSender P2P Backend->>P2P Backend: Listen for Message events P2P Backend->>P2P Backend: Verify msg.sender is authorized P2P Backend->>Beacon Chain: Broadcast VEM (Voluntary Exit Message) ``` Only messages from the real validator owner (msg.sender) are accepted. P2P backend handles validator exit using the BLS key. Direct staking v1 also provides a mechanism for the user to signal certain actions (especially to request a validator exit/withdrawal) in a secure, trust-minimized way. This is handled by the **P2pMessageSender** contract, which works in tandem with off-chain services: * **P2pMessageSender Contract:** It’s a simple on-chain messaging contract that anyone can call, but whose events are monitored by P2P. The contract has a function `send(string text)` that emits an event (e.g., `Message`) containing the caller’s address and the provided text message. The text can encode a specific instruction or identifier (for example, a message indicating “please exit validator X”). The key point is that whatever the message contains, it is cryptographically **tied to the sender’s Ethereum address** via the event. * **Off-Chain Listening and Verification:** P2P’s backend service continuously listens for `Message` events from the P2pMessageSender contract. When a user wants to initiate a validator exit (withdraw), they will trigger an on-chain message via this contract (either directly or through an integrated UI/API call). The P2P service, upon detecting a new message event, checks the `sender` field of the event against its records of validator ownership. **Only if the event’s`msg.sender` matches the address authorized for that validator (i.e., the original staker’s address or a designated controller address) will P2P honor the request**. This ensures authenticity — a malicious party can’t impersonate the validator owner by simply calling the contract, because P2P will ignore messages from addresses that don’t match the expected owner. (The P2P docs note that only the preset controller or withdrawal address can initiate an exit via the smart contract; if the sender doesn’t match, the exit won’t proceed.) * **VEM Broadcast (Validator Exit Message):** Once a valid exit request is confirmed (i.e., a `Message` event from the real owner is received with an instruction to exit), P2P will perform the off-chain steps to exit the validator. Specifically, P2P will take the validator’s BLS key (which it manages) and craft a **Voluntary Exit Message (VEM)**, which is a signed message to the Ethereum consensus layer indicating the validator should exit. P2P then broadcasts this VEM to the Beacon Chain network. Broadcasting the VEM initiates the validator’s voluntary exit from active duty. After the exit is processed on-chain and the exit epoch is reached, the validator’s balance (32 ETH plus any rewards) becomes withdrawable to the user’s withdrawal address. The entire exit process is thus triggered by the user’s on-chain signal and executed by P2P, with the smart contract event acting as the trigger point for a secure off-chain action. In summary, the direct staking v1 architecture uses on-chain contracts to keep the process trust-minimized: **P2pEth2Depositor** lets users deposit to the beacon chain directly (no custodial intermediate), and **P2pMessageSender** provides a verified communication channel for exits or other signals. The user maintains ultimate control of funds via the withdrawal credential, while P2P handles the technical heavy lifting of validator operations and exit broadcasting. This separation of concerns provides a non-custodial staking service — P2P cannot move the user’s ETH, only facilitate its staking and unstaking per the user’s requests. ## Smart contract deployments ### P2pEth2Depositor (v3) > Returned by the `/deposit` endpoint; forwards to Beacon DepositContract. * [Mainnet](https://etherscan.io/address/0xa6cf239220a8a9939d3207dfd8f26cd5e4f36ae6) `0xa6cf239220a8a9939d3207dfd8f26cd5e4f36ae6` * [Hoodi](https://hoodi.etherscan.io/address/0xda2934020efd473fac5cd73bdde440a719bf4c59) `0xda2934020efd473fac5cd73bdde440a719bf4c59` ### P2pEth2Depositor (v2) * [Mainnet](https://etherscan.io/address/0x8e76a33f1aFf7EB15DE832810506814aF4789536) `0x8e76a33f1aFf7EB15DE832810506814aF4789536` * [Hoodi](https://hoodi.etherscan.io/address/0x44Cd8e2c24d3E11F0838a8Ea942C2D0da5BeD6C0) `0x44Cd8e2c24d3E11F0838a8Ea942C2D0da5BeD6C0` [Github](http://github.com/p2p-org/eth-staking-fee-distributor-contracts/blob/v2-audited/contracts/p2pEth2Depositor/P2pEth2Depositor.sol) [Audit](https://github.com/mixbytes/audits_public/tree/master/P2P.org/ETH2%20Depositor%20%26%20ETH%20Staking%20Fee%20Distributor%20\(v.2\)) ### P2pEth2Depositor (v1)) > Direct on-chain deposits (v1), still accepted. * [Mainnet](https://etherscan.io/address/0x4ca21e4d3a86e7399698f88686f5596dbe74adeb) `0x4ca21e4d3a86e7399698f88686f5596dbe74adeb` * [Hoodi](https://hoodi.etherscan.io/address/0x375e183efA05fb2bb66Cd0e7C3a05D9942046612) `0x375e183efA05fb2bb66Cd0e7C3a05D9942046612` [Github](https://github.com/p2p-org/p2p-eth2-depositor/blob/main/src/P2pEth2Depositor.sol) [Audit](https://github.com/mixbytes/audits_public/tree/master/P2P.org/ETH2%20Depositor%20%26%20ETH%20Staking%20Fee%20Distributor%20\(v.1\)) # Energy Delegation Source: https://docs.p2p.org/docs/energy-delegation Delegate generated ENERGY to another TRON account without transferring ownership of the frozen TRX. Delegate generated `ENERGY` to another TRON account without transferring ownership of the underlying frozen TRX. ## What is Energy delegation? On TRON, every action that touches a smart contract (including TRC-20 transfers, e.g. USDT) consumes `ENERGY`. `ENERGY` is generated by freezing TRX via [`/staking/delegate`](/reference/tron-staking-delegate), the same mechanism used for `BANDWIDTH` and voting power. Energy delegation lets the account that froze the TRX (the **owner**) share the `ENERGY` it generates with a different account (the **receiver**), without moving the frozen TRX itself and without giving up ownership of it. The owner keeps the frozen balance, its voting rights, and can reclaim the delegated resource at any time after the lock period expires. This is the pattern used to cover gas costs for a large number of wallets from a single pool of frozen TRX — for example, an exchange or a custodian freezing TRX once and delegating `ENERGY` to hundreds of hot wallets so that each of them can pay for TRC-20 transfers without holding TRX of its own. > [!WARNING] > > Only `ENERGY` is supported for delegation in the current version. `BANDWIDTH` delegation is not available. ## The full flow Energy delegation sits between the freeze and unfreeze steps of the regular TRON staking flow: ``` freeze → delegate-resource → undelegate-resource → unfreeze → withdraw ``` Step Endpoint Description 1. Freeze `/staking/delegate` Freeze TRX and generate `ENERGY` on the owner account 2. Delegate resource `/staking/delegate-resource` Delegate generated `ENERGY` from the owner to a receiver account. 3. Undelegate resource `/staking/undelegate-resource` Reclaim previously delegated `ENERGY` back to the owner, once the delegation lock period has passed. 4. Unfreeze `/staking/undelegate` Unfreeze the owner's TRX 5. Withdraw `/staking/withdraw` Claim the unfrozen TRX back to the available balance Steps 1, 4, and 5 are the standard freeze/unfreeze/withdraw operations already described in [Getting Started](/docs/staking-tron) and [Withdrawal](/docs/withdrawal-tron). This guide focuses on steps 2 and 3, which sit in between. Note that the owner does not have to unfreeze immediately after undelegating. `ENERGY` can be delegated and reclaimed many times over the lifetime of a single frozen balance — unfreezing is only required once the owner wants the underlying TRX back. ## Signing model As with any other operation on TRON, `/staking/delegate-resource` and `/staking/undelegate-resource` only build and return an **unsigned** transaction — the API never holds or uses your private key. The client is responsible for signing every transaction in the flow (freeze, delegate-resource, undelegate-resource, unfreeze, withdraw) individually with the [P2P Signer SDK](/docs/signer-sdk-overview) and broadcasting it via [/transaction/send](/reference/tron-transaction-send), following the steps described in [Sign and Broadcast Transaction](/docs/signing-transaction-tron). The owner address that signs the delegate/undelegate-resource transaction must be the same address that froze the TRX (`delegatorAddress`) — the receiver never signs anything as part of this flow. ## 1. Create delegate-resource request To delegate generated `ENERGY` to a receiver account, send a POST request to [`/api/v1/tron/{network}/staking/delegate-resource`](/reference/tron-staking-delegate-resource). Example request (for `testnet-nile` network): ```shell theme={null} curl --request POST \ --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/delegate-resource' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 1000000, "resource": "ENERGY" }' ``` * `delegatorAddress` — owner account address, i.e. the account that froze the TRX and generated the `ENERGY`. * `amount` — amount of resource to delegate in SUN. Minimum amount is 1 TRX (1 000 000 SUN) * `resource` — resource type to delegate. Only `ENERGY` is supported in the current version, defaults to `ENERGY`. Optional. Example response: ```json theme={null} { "error": null, "result": { "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "receiverAddress": "TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r", "amount": 10000000, "resource": "ENERGY", "lockPeriod": 28800, "unsignedTransaction": { "visible": false, "txID": "b7c4a2f1e6d9083c...", "raw_data_hex": "0a...", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1", "receiver_address": "41700ca9ad5f162f9de000558ff04eef8f99dce7e8", "balance": 10000000, "resource": "ENERGY" }, "type_url": "type.googleapis.com/protocol.DelegateResourceContract" }, "type": "DelegateResourceContract" } ], "ref_block_bytes": "0e0c", "ref_block_hash": "7db974037137d39c", "expiration": 1750000200000, "timestamp": 1750000140000 } }, "unsignedTransactionSerialized": "eyJ0eElEIjoidHJ4SWQifQ==", "createdAt": "2025-06-03T12:00:00.000Z" } } ``` * `delegatorAddress` — owner account address. * `receiverAddress` — account address receiving the delegated resource. * `amount` — amount of resource delegated, in SUN. * `resource` — resource type delegated: `ENERGY`. * `lockPeriod` — 28800, i.e. blocks, ≈ 24 h at 3 s per block. * `unsignedTransaction` — original unsigned transaction object returned by tronWeb. * `unsignedTransactionSerialized` — unsigned serialized transaction in Base64 format, ready for signing. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ## Delegation lock TRON enforces a protocol-level lock on delegated resources: once `ENERGY` has been delegated to a receiver, it cannot be undelegated for **approximately 24 hours** from the moment the delegation transaction is confirmed. This is a network rule, and it applies per delegation — each new `/staking/delegate-resource` call starts its own 24-hour lock for the amount it delegates. Calling `/staking/undelegate-resource` before the lock period has elapsed will cause the transaction to fail on-chain. Plan any automated re-delegation or rebalancing logic around this window, and track the delegation's confirmation time so you know when it becomes eligible for undelegation. **The lock is amount-aware. **TRON keeps one lock per (owner, receiver) pair, so an older expired portion can coexist with a freshly locked one. Undelegating within the unlocked part succeeds; only a request reaching into the locked part is rejected. **The unlock time is machine-readable**. DelegationLockedException returns both the message and a structured field: ```json theme={null} "errors": [ { "property": "delegation", "constraints": { "unlocksAt": "2026-08-19T11:48:06.000Z" } } ] ``` Integrators should read `errors[0].constraints.unlocksAt` rather than parsing the message, and use it to schedule the retry instead of polling on a fixed 24-hour timer. ## 2. Create undelegate-resource request Once the lock period has passed, reclaim the delegated `ENERGY` back to the owner account by sending a POST request to [`/api/v1/tron/{network}/staking/undelegate-resource`](/reference/tron-staking-undelegate-resource). Example request (for `testnet-nile` network): ```shell theme={null} curl --request POST \ --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/undelegate-resource' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 1000000, "resource": "ENERGY" }' ``` * `delegatorAddress` — owner account address that originally delegated the resource. * `amount` — amount of resource to delegate in SUN. Minimum amount is 1 TRX (1 000 000 SUN) * `resource` — resource type to reclaim. Only `ENERGY` is supported, defaults to `ENERGY`. Optional. Example response: ```json theme={null} { "error": null, "result": { "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "receiverAddress": "TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r", "amount": 10000000, "resource": "ENERGY", "unsignedTransaction": { "visible": false, "txID": "d3f8b1a2c9e6740f...", "raw_data_hex": "0a...", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1", "receiver_address": "41700ca9ad5f162f9de000558ff04eef8f99dce7e8", "balance": 10000000, "resource": "ENERGY" }, "type_url": "type.googleapis.com/protocol.UnDelegateResourceContract" }, "type": "UnDelegateResourceContract" } ], "ref_block_bytes": "0e0c", "ref_block_hash": "7db974037137d39c", "expiration": 1750086600000, "timestamp": 1750086540000 } }, "unsignedTransactionSerialized": "eyJ0eElEIjoidHJ4SWQifQ==", "createdAt": "2025-06-03T12:00:00.000Z" } } ``` Field descriptions mirror the delegate-resource response above; the only difference is the underlying `UnDelegateResourceContract` type. ## Error codes `/staking/delegate-resource` and `/staking/undelegate-resource` can return the following `400 Bad request` errors in addition to the standard `401` and `429` responses. `/staking/delegate-resource` : | Code | Exception | Description | | - | - | - | | 125102 | `InvalidDelegatorAddressException` | Invalid delegator address provided. Please ensure the address is a valid TRON address format. | | 125123 | `InvalidReceiverException` | Invalid receiver address. The receiver must be a valid TRON address and must differ from the owner address. | | 125104 | `InvalidFreezeAmountException` | Freeze amount is below the minimum required threshold (1 TRX = 1,000,000 SUN). | | 125125 | `ResourceNotSupportedException` | Resource type is not supported. Only ENERGY delegation is available. | | 125124 | `ExceedsDelegatableMaxException` | Delegation amount exceeds the maximum delegatable resource for this account. Freeze more TRX or reduce the amount. | | 125121 | `DelegateResourceTransactionException` | Failed to create the resource delegation transaction. Verify the amount does not exceed the delegatable balance and that the account has frozen ENERGY. | `/staking/undelegate-resource` : | Code | Exception | Description | | - | - | - | | 125102 | `InvalidDelegatorAddressException` | Invalid delegator address provided. Please ensure the address is a valid TRON address format. | | 125123 | `InvalidReceiverException` | Invalid receiver address. The receiver must be a valid TRON address and must differ from the owner address. | | 125105 | `InvalidUnfreezeAmountException` | Unfreeze amount exceeds the available frozen balance or is invalid. Please verify the account's frozen amount. | | 125125 | `ResourceNotSupportedException` | Resource type is not supported. Only ENERGY delegation is available. | | 125126 | `NoActiveDelegationException` | No active ENERGY delegation found for this account. There is nothing to undelegate. | | 125127 | `ExceedsDelegatedAmountException` | Undelegation amount exceeds the currently delegated ENERGY balance. Please reduce the amount. | | 125128 | `DelegationLockedException` | Delegation is still locked and cannot be undelegated until the lock period expires. | | 125122 | `UndelegateResourceTransactionException` | Failed to create the resource undelegation transaction. Locked delegations can only be undelegated after the lock period expires. | ## Testing on the Nile testnet Before delegating on mainnet, validate the full flow on TRON's Nile testnet using the `testnet-nile` network identifier. Because of the delegation lock, a full round trip through steps will take about 24 hours to complete. 1. **Fund a Nile testnet account.** Use the [Nile faucet](https://nileex.io/join/getJoinPage) to receive test TRX on your account. 2. **Freeze TRX for **`ENERGY`**.** Send a POST request to `/api/v1/tron/testnet-nile/staking/delegate` with `resource: "ENERGY"`, sign, and broadcast the transaction, as described in [Getting Started](/docs/staking-tron). 3. **Delegate the resource.** Send a POST request to: ``` https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/delegate-resource ``` with your `delegatorAddress`, a `receiverAddress` you control (a second Nile testnet account), and the `amount` to delegate. 4. **Sign** transaction 5. **Broadcast** via POST `/tron/testnet-nile/transaction/send ` 6. **Verify the delegation.** The transaction confirms as DelegateResourceContract; getDelegatedResourceV2(owner, pool) shows the delegation with an expire\_time. 7. **Undelegate the resource. **Once the lock has expired, send a POST request to: ``` https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/undelegate-resource ``` with the same `delegatorAddress`/`receiverAddress` pair and `amount`, then sign and broadcast. Testnet transactions use the same request/response shapes as mainnet. Only the `network` path parameter and the `api-test.p2p.org` host differ, so code validated on Nile carries over to production without changes. # Ethereum Staking 101 Source: https://docs.p2p.org/docs/ethereum-staking-a-comprehensive-guide What Ethereum proof-of-stake staking involves: deposits, validators, rewards and penalties. Ethereum staking represents the process of participating in the validation of transactions on the Ethereum blockchain, which has transitioned to a Proof-of-Stake (PoS) consensus mechanism following [The Merge](https://ethereum.org/en/roadmap/merge/) update. This is a crucial element of the Ethereum ecosystem as it not only contributes to the security of the network but also allows participants to earn rewards for their contribution. Here’s what you need to know to start staking Ethereum. ## Understanding Ethereum Staking Ethereum's transition to PoS invited participants, dubbed validators, to stake ETH as a security deposit to validate transactions and create new blocks. This mechanism enhances network security and energy efficiency compared to the former Proof-of-Work (PoW) system. ### What is Staking? Staking involves locking up a certain amount of cryptocurrency (in this case, Ether) to participate in the functioning of a blockchain network. This participation includes validating transactions and maintaining network security. Stakers, in return, receive rewards for their contributions. [Ethereum Launchpad](https://launchpad.ethereum.org/) serves as the official starting point for individuals aiming to become validators on the Ethereum network. It's a user-friendly platform designed to guide users through the staking process, ensuring they meet the necessary requirements and understand the commitments involved. Launchpad educates prospective validators on the risks and responsibilities of staking, providing a streamlined path from initial interest to active participation. This includes detailed instructions on setting up validator software, contributing to making the Ethereum network more decentralized and secure. ### What is a Deposit? A deposit in the context of Ethereum staking refers to the act of locking up 32 ETH as a commitment to become a network validator. This deposit is a prerequisite for participating in transaction validation and block proposal processes in Ethereum 2.0's PoS consensus mechanism. ### What is a Validator? A validator in the Ethereum network is a participant who stakes 32 ETH to validate transactions, propose new blocks, and maintain the network's security within its Proof-of-Stake (PoS) mechanism. Validators are crucial for the integrity and continuity of the blockchain, being rewarded for their contributions and penalized for any actions that jeopardize the network's operation. They run node software, enabling them to take part in the consensus process, ensuring Ethereum remains decentralized and secure. The balance of rewards and penalties incentivizes validators to act in the network's best interest. Validators are at the core of Ethereum's PoS consensus mechanism. They are selected to propose new blocks and validate transactions. For their service, validators earn rewards, but they also face penalties and slashing for downtime or malicious actions. ## Creating a Deposit Creating a deposit for staking in Ethereum 2.0 is a critical step towards becoming a validator. This process involves several key actions and requires attention to detail to avoid any errors that could potentially lead to financial loss or other issues. Here's a more detailed breakdown: * **Amount of ETH to Stake**: A minimum of 32 ETH is required for staking as a single validator. This is a fixed threshold set by the Ethereum 2.0 protocol to ensure validators have a vested interest in the network's security. * **Validator's Public Key**: The public key is part of the validator's cryptographic key pair (public and private keys) used for signing and verifying transactions and messages within the network. It identifies the validator on the network and is crucial for the operation and security of your validator node. * **Withdrawal Credentials**: These credentials are necessary for withdrawing staked ETH and rewards after the validator exits or is no longer active. Withdrawal credentials protect your funds by ensuring that only the entity in possession of the corresponding private key can access them. * **Signature from the Validator's Private Key**: The deposit must be signed with the validator's private key. This signature is a cryptographic proof that the validator is indeed the one making the deposit. It secures the transaction against unauthorized actions. **Timing Considerations** * **Deposit Transmission Time**: After being submitted, the deposit typically appears on the Ethereum blockchain within a few minutes, depending on the current network congestion. However, the Beacon Chain's recognition of the deposit and the transition from "Pending" to "Processed" status may take several hours or more during periods of high demand. * **Activation Queue**: After the deposit has been processed, validators enter a queue for activation. The waiting time in this queue can vary significantly, from a few days to several weeks, depending on the number of validators awaiting activation. The Ethereum protocol dynamically manages the number of validators that can be activated in each epoch (approximately 6.4 minutes long) to ensure gradual and controlled growth of the validator set. **Important Considerations** Double-Check All Inputted Data: Before confirming the deposit, it is essential to verify all information meticulously. Errors in the deposit transaction, such as incorrect public keys or withdrawal credentials, cannot be reversed and might result in the permanent loss of ETH or affect your ability to withdraw funds in the future. **Initiating the Staking Transaction**: * To begin staking, the deposit, along with the necessary data points, must be sent to the Ethereum 2.0 deposit contract. This contract is responsible for registering validators and managing their deposits. * Ensure you have enough ETH not only for the deposit but also to cover transaction fees. These fees vary based on network congestion and can be significant during periods of high demand. ## Deposit Statuses Deposits can have various statuses, reflecting the stage of the staking process: * **Pending**: This status indicates that your deposit has been made to the Ethereum 2.0 contract, but it hasn't been processed yet. Your ETH is waiting to be recognized by the network and included in the Beacon Chain. * **Processed**: At this point, your deposit has been acknowledged by the Beacon Chain and is included in its registry. The deposit is now waiting for the validator to be activated. * **Active**: Congratulations, your deposit is now linked to an active validator on the Ethereum network. This means you are participating in the consensus process, proposing and attesting to blocks. * **Exited**: This status indicates that your validator has ceased its active duties. This can happen voluntarily if you decide to stop staking or involuntarily if your validator is slashed for malicious activities or severe downtime. To track the status of your deposit and validator, the following tools are invaluable: * [Etherescan](https://etherscan.io/): Use this for initial deposit tracking to confirm your ETH has been successfully sent to the staking contract. Etherscan provides transaction receipts, including success or failure status, gas used, and more. * [Beaconcha.in](https://beaconcha.in/): A specialized Beacon Chain explorer that allows you to monitor the status of your deposit and validator in real-time. Beaconcha.in offers insights into validator queues, activation, performance metrics, and potential penalties. ## Validator The process of validator activation in Ethereum 2.0 is a critical step for those who wish to participate in the network's PoS consensus mechanism. Let’s expand on the key phases and responsibilities involved in this process to provide a more detailed view. ### Becoming a Validator 1. **Preparation**: Accumulate at least 32 ETH and familiarize yourself with Ethereum's staking mechanisms. 2. **Technical Setup**: Visit [Ethereum Launchpad](https://launchpad.ethereum.org/), follow the setup guide for execution and consensus clients, and understand the responsibilities and risks involved. 3. **Staking**: Commit your ETH through the Launchpad, completing the necessary steps to activate your validator status. Becoming a validator is a commitment that contributes to the security and functionality of the Ethereum network, offering rewards but also entailing risks and responsibilities. Potential validators should thoroughly research and prepare to ensure they contribute positively to the network's health. ### Validator Activation Process **Initial Stage: Deposit and Pending Status** * **Making the Deposit**: To initiate the journey of becoming a validator, a stake of 32 ETH must be deposited into the official Ethereum 2.0 staking contract. This step is generally swift, with the deposit appearing on the Ethereum blockchain within a few minutes under normal conditions. However, this timing can be affected by the current state of network congestion, potentially leading to delays. * **Pending Status**: Following the deposit, the transaction is processed by the Ethereum network. During this phase, the deposited ETH is locked, awaiting further action. The validator's status is set to "pending" until the Ethereum network acknowledges and includes the deposit in the Beacon Chain. The amount of time your deposit remains in this status can significantly vary, largely depending on the network's current workload and the queue of pending deposits awaiting recognition by the Beacon Chain. ### During Activation **Queued for Activation**: * **Entering the Queue**: After the deposit is recognized, the validator enters a queue. This is due to the protocol's design to limit the number of validators activated in each epoch, which helps manage the network’s growth and maintain its security. * **Preparation and Monitoring**: Validators in the queue should ensure their node is correctly set up, secure, and fully synchronized with the Ethereum 2.0 blockchain. Continuous monitoring is essential during this stage to avoid any issues that might delay activation or cause the node to miss its activation turn. ### After Activation **Active Participation**: * **Beginning of Duties**: Upon activation, validators start their roles in the network's consensus mechanism. This includes proposing new blocks and attesting to blocks they believe should be added to the blockchain. * **Security and Performance**: An active validator contributes to the overall security and efficiency of the network. It's crucial for validators to maintain a high online uptime and participate honestly in consensus activities to avoid penalties, known as slashing, which can result from actions like double voting or being offline for extended periods. **Earning Rewards**: * **Rewards for Participation**: Validators receive rewards for their active participation, specifically for proposing and attesting to blocks. The amount of rewards earned can vary based on several factors, including the total number of active validators and the validator's own performance. * **Penalties and Slashing**: To incentivize continuous participation and honesty, the Ethereum 2.0 network implements penalty mechanisms. Minor penalties are applied for being offline (inactivity leak), while more severe penalties (slashing) are enforced for malicious activities against the network. **Maintaining Validator Status**: * **Continuous Operation**: Validators are expected to run their nodes continuously. Regular software updates, secure key management, and adherence to best security practices are necessary to maintain validator health and optimize reward earning potential. * **Monitoring Tools**: Utilizing tools like beaconcha.in or other Ethereum 2.0 staking dashboards can help validators monitor their performance, projected rewards, and network status. These tools provide valuable insights that can help in maintaining optimal validator operation. Becoming and serving as a validator on the Ethereum 2.0 network is a significant commitment that entails responsibility, technical know-how, and ongoing management. However, it also offers the opportunity to contribute to the network’s security and earn rewards for playing a crucial role in the Ethereum ecosystem's evolution. ## Rewards The rewards mechanism in Ethereum 2.0 is designed to incentivize validators to act in the best interest of the network. By actively participating in the consensus mechanism, validators help secure the network and, in return, receive rewards for their contributions. Here's a deeper dive into the types of activities rewarded and how they are calculated: ### Types of Validator Rewards * **Block Proposals**: Validators are randomly selected to propose new blocks to the Beacon Chain. When a proposed block is successfully validated by other validators and added to the blockchain, the proposer receives a reward. This process is critical for the continuation of the blockchain and ensures validators are motivated to propose blocks accurately and efficiently. * **Attestations**: Attestation is the process by which validators vote on the validity and correctness of a block. By attesting to a block, validators confirm that they have seen and verified the block as being correct. Validators are rewarded for these attestations, especially when they quickly attest to blocks that are successfully included in the chain. This mechanism helps the network reach consensus more swiftly and securely. * **Sync Committees**: Validators may be selected to serve in sync committees, which are responsible for helping light clients stay up-to-date with the state of the blockchain. Sync committees provide signatures that light clients can use to verify the blockchain's state without needing to process every block. Participation in these committees is rewarded, as it plays a vital role in maintaining the network's accessibility and efficiency. ### Reward Calculation and Distribution * **Epoch-Based Calculation**: Rewards are calculated at the end of each epoch, which is a fixed period of time in the Ethereum 2.0 network. An epoch consists of multiple slots, with each slot representing an opportunity for a block to be proposed. * **Automatic Addition to Validator’s Balance**: Once rewards are calculated, they are automatically added to the validator's balance within the Beacon Chain. This process is seamless and does not require any action from the validator. ### Compounding of Rewards * **Stake Increase**: As rewards are added to the validator's balance, their total stake in the network increases. This increased stake can lead to higher rewards over time, as the validator's proportionate share of the total staked ETH grows. * **Long-Term Earning Potential**: The compounding effect of rewards means that validators who continuously perform their duties well can see significant growth in their staked ETH over time. This serves as an additional incentive for validators to maintain operational excellence and contribute positively to the network's health. ### Considerations for Maximizing Rewards * **Uptime and Performance**: Validators must ensure their node remains online and operates efficiently to maximize their rewards. Downtime or poor performance can lead to missed opportunities for block proposals and attestations, directly impacting reward potential. * **Security and Compliance**: Adhering to best security practices and following protocol rules is essential. Slashing penalties for malicious actions or protocol violations can severely reduce a validator’s stake and rewards. ## Penalties While rewards incentivize validators to act in the best interest of the network, penalties are designed to discourage and penalize undesirable actions. There are primarily two types of penalties: **1. Inactivity Leaks** * **Mechanism**: Inactivity leaks are designed to gradually reduce the stakes of validators who fail to participate in consensus activities, effectively decreasing their influence over the network. This penalty applies network-wide during extended periods of non-finality, affecting all validators but impacting inactive ones the most. * **Purpose**: The primary goal is to prevent inactive validators from causing long-term harm to the network's health. By slowly reducing their stakes, the network encourages validators to maintain a high level of uptime and participation. * **Recovery**: Validators affected by inactivity leaks can halt the penalty by returning to active participation in consensus activities, demonstrating the system's design to be forgiving and encouraging validators to rectify their status. **2. Slashing** * **Severe Misbehavior**: Slashing penalties are reserved for actions deemed explicitly harmful to the network's security, such as double signing or similar slashable offenses. These penalties are more severe than inactivity leaks, reflecting the seriousness of the actions. * **Proposer Slashing**: This type of slashing targets validators who propose two or more conflicting blocks for the same slot, an action that can lead to network instability or forks. * **Attester Slashing**: Validators who attest to contradictory block versions for the same epoch are subject to attester slashing. This behavior disrupts the consensus process and threatens network finality. * **Consequences**: Slashed validators suffer immediate and substantial stake reductions, part of which is burned and part distributed as rewards to whistleblowers who detected and reported the offense. Additionally, slashed validators are removed from the validator set, losing their ability to participate in consensus and earn rewards. ## Conclusion Ethereum staking is not only a way to earn rewards but also a method to contribute to the security and efficiency of the network. By becoming a validator, you play a direct role in the future of Ethereum. ## References * Ethereum Launchpad: [https://launchpad.ethereum.org/](https://launchpad.ethereum.org/) * Official FAQ: [https://launchpad.ethereum.org/en/faq](https://launchpad.ethereum.org/en/faq) * Validator Specification: [https://github.com/ethereum/consensus-specs/blob/master/specs/phase0/validator.md#becoming-a-validator](https://github.com/ethereum/consensus-specs/blob/master/specs/phase0/validator.md#becoming-a-validator) # FAQ Source: https://docs.p2p.org/docs/faq The main staking details from the P2P Validator can be found . ## What is Staking Cryptocurrency staking is the process of holding coins/tokens (stake) to earn rights to participate in the validation of transaction blocks, and in doing so, Validators are rewarded. ## What is DVT Staking API DVT Staking API is an innovative product designed specifically for institutions and intermediaries, enabling them to leverage the advantages of Distributed Validator Technology (DVT). Our API simplifies the process of integrating with the SSV protocol, automating the staking process for enhanced efficiency and ease. ## What is DVT Distributed Validator Technology (DVT), in the majority of PoS (proof-of-stake) systems, assigns each validator a single staking node. However, Distributed Validator Technology allows for the splitting of responsibilities and risks associated with a single validator node across multiple participants. The primary goals of DVT are to increase the security, decentralization, and resilience of the network by ensuring that no single point of failure exists. ## What are the advantages of using DVT **Enhanced Security and Fault Tolerance:** DVT's distributed nature means that your staking operations are not dependent on a single node operator. This significantly reduces the risk of system failures, security breaches, and the impact of potential attacks, as responsibilities and tasks are shared across multiple providers. **Diversification and Reduced Risk:** By spreading your staking across various operators and geographical locations, DVT minimizes the risks associated with relying on a single validator or location. This diversification ensures more stable and reliable staking outcomes. **Cost Efficiency:** DVT allows for more efficient management of staking operations. By distributing tasks across various nodes, operational costs can be optimized, translating into better cost-efficiency for the clients. **High Performance and Reliability:** With nodes distributed globally and managed by top-performing operators, DVT systems typically exhibit higher uptime and performance consistency, contributing to potentially greater staking rewards. ## What are the risks of using DVT **Technology Risks:** As with any technology reliant on software and online connectivity, there is always the risk of software bugs, vulnerabilities, or unforeseen technical issues that could affect the system's stability. **Market Risks:** A key consideration is the volatility of the SSV token price. Since users top-up the cluster balance with SSV tokens, a price decrease can lead to operators increasing their fee in SSV tokens to maintain their margins. This necessitates users to pay more and constantly monitor their balance to avoid liquidation risks. ## What is SSV Secret Shared Validator (SSV) is a technology that allows for the secure and decentralized operation of validator nodes in proof-of-stake (PoS) blockchain networks. ## What is EigenLayer EigenLayer is a protocol built on top of Ethereum designed to enhance the economic utility of staked ETH by allowing users to leverage their existing Ethereum stakes to secure additional protocols and applications without requiring additional collateral. ## What is AVS Actively Validated Services (AVS) refer to any system that necessitates its own distributed validation semantics for verification. This includes sidechains, data availability layers, new virtual machines, keeper networks, oracle networks, bridges, threshold cryptography schemes, and trusted execution environments. AVS is integrated into EigenLayer, essentially serving as node operators. # Get Started Source: https://docs.p2p.org/docs/get-started Start integrating P2P.org's staking capabilities into your platform in minutes. This guide will help you set up your environment and make your first API call. ## Quick Setup 1. **Get API Access** To get started with our APIs, you'll need to obtain authentication credentials. Visit our [Authentication Guide](/docs/authentication) for detailed instructions. 2. **Choose Your Environment** Production API endpoint: ``` https://api.p2p.org ``` Test environment endpoint: ``` https://api-test.p2p.org ``` 3. **Make Your First API Call** Try creating your first stake transaction using the Unified API (no funds required): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'accept: application/json' \ --header 'authorization: Bearer 8aAEXXJsogPZzpAKk1uedM7TYxPvGrBi' \ --header 'content-type: application/json' \ --data ' { "chain": "polkadot", "network": "westend", "stakerAddress": "5FU44bZkd8iza8Sw8xS9QeRamsj9MpcBiwvLBReVDLBmd25q", "amount": 1 } ' ``` This will return an unsigned transaction that you can review without committing any funds. ## Integration Steps ### 1. Authentication Setup * Follow our [Authentication Guide](/docs/authentication) to get your API token * Use JWT authentication for all API calls * Include token in Authorization header ### 2. Choose Your Product * [**Unified API**](/docs/unified-api-overview): Start here for multi-chain integration * [**Staking API**](/docs/staking-overview): Direct staking operations * [**Restaking API**](/docs/restaking-overview): Enhanced yield opportunities * [**DVT Staking API**](/docs/overview-dvt-solutions): Distributed validation * [**Data API**](/docs/overview): Analytics and monitoring ### 3. Test Your Integration * Use test networks for initial development * Validate responses and error handling * Monitor rate limits and usage ### 4. Go Live * Switch to production endpoints * Configure network-specific parameters * Set up monitoring and alerts ## Code Examples Looking for implementation examples? Check out our [Code Recipes](https://docs.p2p.org/recipes) for ready-to-use code samples and common integration patterns. Need help? Our [team](/docs/contacts) is available to assist with your integration. # Getting Started Source: https://docs.p2p.org/docs/getting-started-aptos Stake on Aptos programmatically with the P2P.org Staking API. Staking in the Aptos network using the Staking API consists of several main steps: 1. Create a staking request. 2. Sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create staking request** Send a POST request to [/api/v1/aptos/\{network}/staking/delegated/add](/reference/aptos-staking-delegated-add). Example request (for `mainnet` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "amount": 1100000000, "delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a", "gas": { "unitPrice": 100, "maxGasLimit": 100, } } ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ amount: 1100000000, delegatorAddress: "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a", gas: { unitPrice: 100, maxGasLimit: 100, }, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "amount": 1100000000, "delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a", "gas": { "unitPrice": 100, "maxGasLimit": 100, }, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "amount": 1100000000, "delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a", "gas": map[string]interface{}{ "unitPrice": 100, "maxGasLimit": 100, }, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/aptos/mainnet/staking/delegated/add", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `amount` — amount of tokens to stake in Octas. The minimum stake amount is 11 APT (1 APT = 10⁸ Octas). * `delegatorAddress` — delegator (A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.) stash account address which keeps tokens. * `gas` — optional; computational effort required to execute the transaction, measured in gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) units. * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction. * `maxGasLimit` — maximum gas limit for the transaction. Example response: ```json theme={null} { "result": { "amount": 1100000000, "delegatorAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a", "unsignedTransaction": "0xa571a5bc9b1bfd5fe58e6e09a5be251a3299985494d022959ce206f1f23f752e21000000000000000200000000000000000000000000000000000000000000000000000000000000010f64656c65676174696f6e5f706f6f6c096164645f7374616b650002207a2ddb6af66beb0d9987c6c9010cb9053454f067e16775a8ecf19961195c3d28080100000000000000400d0300000000006400000000000000e5742068000000000200", "createdAt": "2023-08-24T08:14:50.455Z" }, "error": null } ``` * `amount` — amount of tokens to stake in Octas. * `delegatorAddress` — delegator account address which keeps tokens. * `unsignedTransaction` — unsigned transaction in hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. **2. Sign and send transaction** Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-aptos) the signed transaction to the Aptos network. By broadcasting this transaction, you're adding the tokens to P2P.ORG delegation pool. To check the transaction status, send a GET request to [/api/v1/aptos/\{network}/transaction/status/\{transactionHash}](/reference/aptos-transaction-status). Example request (for `mainnet` network): ```bash curl theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/aptos/mainnet/transaction/status/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `transactionHash` — hash of the transaction. Example response: ```json theme={null} { "result": { "createdAt": "2025-06-24T08:14:50.455Z", "gas": { "unitPrice": 100, "maxGasLimit": 100, "used": 100 }, "senderAddress": "0xd890b1115b39c8d182aeac6cae313cc713cd93922135f8a5893c34fce4e0f32a", "sequenceNumber": 42, "status": "success", "transactionHash": "0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641" }, "error": {} } ``` * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `gas` — computational effort required to execute the transaction, measured in gas units. * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction. * `maxGasLimit` — maximum gas limit for the transaction. * `used` — amount of gas spent for the transaction. * `senderAddress` — transaction sender address. * `sequenceNumber` — number of transactions that have been submitted and committed on-chain from the sender account. * `status` — transaction status: `pending`, `success` or `failed`. * `transactionHash` — hash of the transaction. # Getting Started Source: https://docs.p2p.org/docs/getting-started-celestia Stake on Celestia programmatically with the P2P.org Staking API. Staking in Celestia using the Staking API consists of several main steps: 1. Create a staking request. 2. Sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create staking transaction** Send a POST request to [/api/v1/celestia/\{network}/staking/stake](/reference/create-celestia-stake-transaction). Example request (for `celestia-mainnet-beta` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/staking/stake \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "celestia1yknsyf9ws4ugtv3r9g43kwqkne4zmrupae4xb2", "memo": "This is your memo message", "amount": 0.00420 }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/staking/stake", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "celestia1yknsyf9ws4ugtv3r9g43kwqkne4zmrupae4xb2", memo: "This is your memo message", amount: 0.00420, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/staking/stake", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "celestia1yknsyf9ws4ugtv3r9g43kwqkne4zmrupae4xb2", "memo": "This is your memo message", "amount": 0.00420, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "celestia1yknsyf9ws4ugtv3r9g43kwqkne4zmrupae4xb2", "memo": "This is your memo message", "amount": 0.00420, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/staking/stake", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — delegator (A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.) stash account address which keeps tokens. * `memo` — arbitrary text data to add to the transactions. * `amount` — amount of tokens to stake in TIA. Example response: ```json theme={null} { "error": null, "result": { "amount": 0.0042, "currency": "tia", "validatorAddress": "celestiavaloper1r4kqtye4dzacmrwnh6f057p50pdjm8g59tlhhg", "stashAccountAddress": "celestia1yknsyf9ws4ugtv3r9g43kwqkne4zmrupae4xb2", "rewardDestinationAddress": "celestia1yknsyf9ws4ugtv3r9g43kwqkne4zmrupae4xb2", "transactionData": { "messages": [ { "typeUrl": "/cosmos.staking.v1beta1.MsgDelegate", "value": { "delegatorAddress": "celestia1yknsyf9ws4ugtv3r9g43kwqkne4zmrupae4xb2", "validatorAddress": "celestiavaloper1r4kqtye4dzacmrwnh6f057p50pdjm8g59tlhhg", "amount": { "denom": "utia", "amount": "4200" } } } ], "fee": { "amount": [ { "amount": "5953", "denom": "utia" } ], "gas": "238098" }, "memo": "The message", "encodedBody": "0a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d657373616765", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801182312130a0d0a057561746f6d1204353935331092c40e" }, "createdAt": "2024-02-12T11:21:40.810Z" } } ``` * `amount` — amount of tokens to stake. * `currency` — currency of tokens: * `tia` — T (A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.)IA, Celestia native staking token. * `utia` — 1 TIA = 10⁶ uTIA, * `mtia` — 1 TIA = 10³ mTIA. * `validatorAddress` — validator (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.) address to which tokens are delegated. * `stashAccountAddress` — delegator stash account address which keeps tokens. * `rewardDestinationAddress` — reward destination account address. * `createdAt` — timestamp of the transac (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.)tion in the ISO 8601 format. `transactionData` is the list of data fields to be used to construct the staking transactions: * `messages`: * `typeUrl` — Celestia network operation type. * `delegatorAddress` — delegator address. * `validatorAddress` — validator address. * `amount` — amount of tokens to stake. * `currency` — currency of tokens. * `fee` — fee charged for the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `tia`, `utia`, or `mtia`. * `gas` — amount of gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. **2. Sign and send transaction** Use `transactionData` to [sign and send](/docs/signing-transaction-celestia) the signed transaction to the Celestia network. To check the transaction status, send a GET request to [/api/v1/celestia/\{network}/transaction/status/\{transactionHash}](/reference/get-celestia-transaction-status). Example request (for `celestia-mainnet-beta` network): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `transactionHash` — hash of the transaction. Example response: ```json theme={null} { "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } } ``` * `status` — transaction status: `success`, `failed`. * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in TIA charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit that the transaction initiator was willing to consume for the transaction. * `transactionHash` — hash of the transaction. # Getting Started Source: https://docs.p2p.org/docs/getting-started-data-api Staking Data API provides methods to retrieve essential information about network, about validators and delegators within the network. To start using Staking Data API, [get an authentication token](/docs/authentication). > The section provides the examples of how to interact with the API for Ethereum data. ## Response format Every response is a JSON envelope with `result` and `error`. On success, `result` holds the payload and `error` is empty. On failure, `result` is `null` and `error` contains `code`, `message`, `name`, and `type`. Error responses also include `requestId` (the value of the `x-request-id` header) and `timestamp`. Quote `requestId` when contacting support so the request can be found in the server logs. ```json Error response theme={null} { "error": { "code": 100101, "message": "The data provided is not valid. Please check the request parameters and try again.", "name": "ValidationException", "type": "client" }, "result": null, "requestId": "90c16e9e-6e99-4651-a033-60290356df2f", "timestamp": "2026-05-20T22:29:03.126Z" } ``` Paginated endpoints accept `limit` (from 1 to 1000, default 50) and `offset` (default 0). Endpoints that accept `startAt` and `finishAt` reject a range longer than 31 days, and `finishNumber` must not be lower than `startNumber`. Not every endpoint is available on every network; see the **Supported networks** line for each method on the [Network](/docs/network), [Validator](/docs/validator), and [Delegator](/docs/data-delegator) pages. ## Using curl commands Request examples are provided using [cURL](https://curl.se/). To demonstrate the API usage scenarios, the examples cover: * retrieving the last staking period, * fetching active stakes for validators, * checking validator states, * obtaining rewards by type. ### Get Last Staking Period To retrieve the last staking period, send a GET request to [/api/v1/\{network}/data/network/last-staking-period](/reference/data-network-last-staking-period). Example request: ```bash curl theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/ethereum/data/network/last-staking-period \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/ethereum/data/network/last-staking-period", { headers: { "authorization": "Bearer ", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/ethereum/data/network/last-staking-period", headers={ "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/ethereum/data/network/last-staking-period", nil) req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` Example response: ```json theme={null} { "result": { "period": 244333, "updatedAt": "2023-08-24T08:23:18.830Z" }, "error": {} } ``` * `period` — last staking period. * `updatedAt` — timestamp of the last update to the queue. ### Get Delegator Stake To fetch the stake of a delegator for each validator, send a GET request to [/api/v1/\{network}/data/delegator/stakes](/reference/data-delegator-stakes). Note that there is a list of additional query params. Example request: ```bash curl theme={null} curl --request GET \ --url 'https://api.p2p.org/api/v1/ethereum/data/delegator/stakes?startNumber=298991&finishNumber=298991&limit=1000&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/ethereum/data/delegator/stakes?startNumber=298991&finishNumber=298991&limit=1000&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit", { headers: { "authorization": "Bearer ", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/ethereum/data/delegator/stakes?startNumber=298991&finishNumber=298991&limit=1000&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit", headers={ "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/ethereum/data/delegator/stakes?startNumber=298991&finishNumber=298991&limit=1000&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit", nil) req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `startNumber` — start number of the staking period. * `finishNumber` — finish number of the staking period. Cannot be lower than `startNumber`. * `limit` — number of resources that a single response page contains. * `address` — delegator address in the required network. * `addressType` — delegator address type in the required network. If omitted, the default for the network is used: * `deposit` — Ethereum (default). * `withdrawal` — Ethereum. * `delegator` — Solana (default), Sui, Cardano, Celestia. * `stake_account` — Solana. * `nominator` — Polkadot (default), Kusama (default), TON. * `nominator_reward_account` — Polkadot, Kusama. Passing an `addressType` that the network does not support returns `400`. * `validatorAddress` — validator address in the required network for this delegator. * `groupBy` — group the output data: `stakingPeriod`, `day`, or `all`. `day` cannot be combined with `startNumber` / `finishNumber`; use `startAt` / `finishAt` instead, otherwise the request returns `400`. * `skip` — set to `validator` to exclude the breakdown by validator from the report. Example response: ```json theme={null} { "result": { "limit": 50, "offset": 0, "list": [ { "stakingPeriod": 298991, "stakingPeriodStart": "2023-11-01T06:43:17.000Z", "stakingPeriodEnd": "2020-11-01T07:12:27.000Z", "stake": 1.82282, "validator": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17" } ] }, "error": {} } ``` * `limit` — number of resources that a single response page contains. * `offset` — number of resources to exclude from the beginning of a response. * `list`: * `stakingPeriod` — number of the staking period. * `stakingPeriodStart` — timestamp of the staking period start in the ISO 8601 format. * `stakingPeriodEnd` — timestamp of the staking period finish in the ISO 8601 format. * `stake` — total stake balance of the delegator. On Ethereum this includes ETH that is still in the deposit or activation queue. * `activeStake` — optional; Ethereum only, returned only with `groupBy=day`. The part of `stake` that is already active on the Beacon Chain. * `inactiveStake` — optional; Ethereum only, returned only with `groupBy=day`. The part of `stake` that is still waiting to be activated. * `validator` — validator address. ### Get Validator State and Statuses To retrieve validator state, send a GET request to [/api/v1/\{network}/data/validator/state](/reference/data-validator-state). Example request: ```bash curl theme={null} curl --request GET \ --url 'https://api.p2p.org/api/v1/ethereum/data/validator/state?address=0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/ethereum/data/validator/state?address=0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", { headers: { "authorization": "Bearer ", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/ethereum/data/validator/state?address=0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", headers={ "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/ethereum/data/validator/state?address=0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", nil) req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `address` — validator address in the required network. For the Ethereum network, it is a public validator key. Example response: ```json theme={null} { "result": { "state": "string", "activatedAt": "string", "activatedStakingPeriodNum": 0 }, "error": {} } ``` * `state` — validator state. * `activatedAt` — timestamp of the validator activated date in the ISO 8601 format. * `activatedStakingPeriodNum` — timestamp of the validator activated staking period. You can also retrieve the information about validator statuses by sending a GET request to [/api/v1/\{network}/data/validator/statuses](/reference/data-validator-statuses) . Example request: ```bash curl theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/ethereum/data/validator/statuses \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/ethereum/data/validator/statuses", { headers: { "authorization": "Bearer ", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/ethereum/data/validator/statuses", headers={ "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/ethereum/data/validator/statuses", nil) req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` Example response: ```json theme={null} { "result": { "total": 3, "by_status": [ { "pending_initialized": 0, "pending_queued": 0, "active_ongoing": 2, "active_slashed": 0, "exited_unslashed": 0, "exited_slashed": 0, "withdrawal_possible": 1, "withdrawal_done": 0 } ] }, "error": {} } ``` * `total` — total count of validators. * `by_status`: * `pending_initialized` — number of validators which are initialized but not yet in the queue for activation. * `pending_queued` — number of validators that entered a queue for activation. * `active_ongoing` — number of validators that were activated and currently participate in attesting and proposing blocks. * `active_slashed` — number of validators that were slashed due to misbehaviors. * `exited_unslashed` — number of validators that have exited the network without being slashed and are no longer acting as validators. * `exited_slashed` — number of validators that have exited the network after being slashed and are no longer acting as validators. * `withdrawal_possible` — number of validators having a non-zero balance. * `withdrawal_done` — number of validators completed the withdrawal process. ### Get Delegator Rewards To fetch a list of delegators rewards by type, send a GET request to [/api/v1/\{network}/data/delegator/rewards](/reference/data-delegator-rewards). Note that there is a list of additional query params, e.g., grouping the data by date. Example request: ```bash curl theme={null} curl --request GET \ --url 'https://api.p2p.org/api/v1/ethereum/data/delegator/rewards?startAt=2024-07-01T00%3A00%3A00&finishAt=2024-07-23T00%3A00%3A00&limit=100&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit&groupBy=day' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/ethereum/data/delegator/rewards?startAt=2024-07-01T00%3A00%3A00&finishAt=2024-07-23T00%3A00%3A00&limit=100&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit&groupBy=day", { headers: { "authorization": "Bearer ", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/ethereum/data/delegator/rewards?startAt=2024-07-01T00%3A00%3A00&finishAt=2024-07-23T00%3A00%3A00&limit=100&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit&groupBy=day", headers={ "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/ethereum/data/delegator/rewards?startAt=2024-07-01T00%3A00%3A00&finishAt=2024-07-23T00%3A00%3A00&limit=100&address=0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb&addressType=deposit&groupBy=day", nil) req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `startAt` — timestamp of the report data period start in the ISO 8601 format. If not specified, the default value is the one month ago. * `finishAt` — timestamp of the report data period finish in the ISO 8601 format. If not specified, the default value is the current date. * `limit` — number of resources that a single response page contains. * `address` — delegator address in the required network. * `addressType` — delegator address type in the required network. If omitted, the default for the network is used: * `deposit` — Ethereum (default). * `withdrawal` — Ethereum. * `delegator` — Solana (default), Sui, Cardano, Celestia. * `stake_account` — Solana. * `nominator` — Polkadot (default), Kusama (default), TON. * `nominator_reward_account` — Polkadot, Kusama. Passing an `addressType` that the network does not support returns `400`. * `validatorAddress` — validator address in the required network for this delegator. * `groupBy` — group the output data: * `stakingPeriod` — aggregate the results by epoch. * `day` — aggregate the results by days. * `all` — aggregate the results over the entire period. * `skip` — set to `validator` to exclude the breakdown by validator from the report. * `rewardTypes` — filter rewards by type. Pass a single value or repeat the key (`?rewardTypes=consensus&rewardTypes=execution`). Some networks exclude certain reward types by default; pass `rewardTypes=all` to return every type. Example response: ```json theme={null} { "result": { "limit": 50, "offset": 0, "list": [ { "stakingPeriod": 298991, "stakingPeriodStart": "2023-11-01T06:43:17.000Z", "stakingPeriodEnd": "2020-11-01T07:12:27.000Z", "rewards": [ { "type": "consensus", "amount": 0.63722, "currency": "ETH", "recipient": "string" } ] } ] }, "error": {} } ``` * `limit` — number of resources that a single response page contains. * `offset` — number of resources to exclude from the beginning of a response. * `list`: * `stakingPeriod` — number of the staking period. * `stakingPeriodStart` — timestamp of the staking period start in the ISO 8601 format. * `stakingPeriodEnd` — timestamp of the staking period finish in the ISO 8601 format. * `rewards`: * `type` — rewards type: `consensus` or `execution`. * `amount` — amount of tokens in the stake. * `currency` — currency of the tokens. * `recipient` — rewards recipient address. ## Using Python code This section demonstrates how to use Python with the Staking Data API. The examples for Ethereum data cover: * fetching the delegator daily rewards, * retrieving the summary for a delegator and validator. ### Get Delegator Rewards To fetch the daily rewards for a delegator, use the following code with the API endpoint [/api/v1/\{network}/data/delegator/rewards](/reference/data-delegator-rewards): ```python Python theme={null} import requests import datetime import pickle # API endpoint. API_URL = 'https://api.p2p.org/api/v1/ethereum/data/delegator/rewards' # Include your Bearer token for authentication and specify the delegator address. ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN' DELEGATOR_ADDRESS = 'DELEGATOR_ADDRESS' def fetch_rewards_for_date(session, date, address): """Fetch rewards for a specific date.""" params = { 'startAt': date.strftime('%Y-%m-%dT00:00:00') ,# Start time in the ISO 8601 format for each day. 'finishAt': (date + datetime.timedelta(days=1)).strftime('%Y-%m-%dT00:00:00'), # Finish time in the ISO 8601 format for the next day. 'limit': 1000, # Number of resources per page. 'offset': 0, # Number of resources to exclude from the beginning; the default value is 0. 'address': address, # Delegator address in the Ethereum network. 'addressType': 'deposit', # Delegator address type in the required network. For Ethereum it can be `deposit` or `withdrawal`. 'skip': 'validator', # Excludes breakdown by validator from the data report. To include validator, specify the empty value. 'groupBy': 'stakingPeriod' # Group the results by `stakingPeriod`, `day` or `all` (the entire period). } rewards = [] while True: try: response = session.get(API_URL, params=params) response.raise_for_status() result = response.json() new_rows = result.get('result', {}).get('list', []) if new_rows: rewards.extend(new_rows) params['offset'] += 1000 else: break except requests.RequestException as e: print(f"An error occurred: {e}") break return rewards def main(): # Setup session session = requests.Session() session.headers.update({'Authorization': f'Bearer {ACCESS_TOKEN}'}) # Define date range start_date = datetime.date(year=2024, month=1, day=1) end_date = datetime.date.today() date_range = (start_date + datetime.timedelta(days=d) for d in range((end_date - start_date).days + 1)) all_rewards = [] # Fetch rewards for each date for date in date_range: print(f"Fetching rewards for {date}") daily_rewards = fetch_rewards_for_date(session, date, DELEGATOR_ADDRESS) all_rewards.extend(daily_rewards) # Save rewards to file with open('dump.pkl', 'wb') as file: pickle.dump(all_rewards, file) # Calculate total amount total_amount = sum(reward['amount'] for epoch in all_rewards for reward in epoch.get('rewards', [])) print(f"Total Amount: {total_amount}") if __name__ == '__main__': main() ``` This script gathers daily rewards data from a start date to the current date, saves the data to a file, and calculates the total rewards amount. ### Get Delegator Summary To fetch the lifetime stake, rewards, and APY for a delegator, use the following code with the API endpoint [/api/v1/\{network}/data/delegator/summary](/reference/data-delegator-summary): ```python Python theme={null} import requests # API endpoint. url = "https://api.p2p.org/api/v1/{network}/data/delegator/summary" # Include your Bearer token for authentication. headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } # Specify the following parameters: params = { "address": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb", # Delegator address. "addressType": "deposit", # Delegator address type in the required network. For Ethereum it can be `deposit` or `withdrawal`. "network": "ethereum", # Network name. "startAt": "2024-04-17T15:00:00.000Z", # Report data start time in the ISO 8601 format. "finishAt": "2024-04-19T15:00:00.000Z", # Report data finish time in the ISO 8601 format. "groupBy": "all", # Aggregate the results by `stakingPeriod` or `day`. To aggregate the results for the entire period, set `all`. "skip": "validator" # Exclude breakdown by validator from the report. To include validators in the output, remove the parameter or pass an empty value. } try: # Make the request. response = requests.get(url.format(network=params["network"]), headers=headers, params=params) # Check the response status. response.raise_for_status() # Parse the JSON response. data = response.json() # Check if the response contains data. if data and "result" in data: print("Delegator Summary:") print("Gross APY:", data["result"]["list"][0]["grossApy"]) print("Net APY:", data["result"]["list"][0]["netApy"]) print("Stake:", data["result"]["list"][0]["stake"], data["result"]["list"][0]["currency"]) print("Rewards:") for reward in data["result"]["list"][0]["rewards"]: print("Type:", reward["type"]) print("Amount:", reward["amount"], reward["currency"]) print("---") else: print("Empty response received.") except requests.exceptions.HTTPError as http_err: print(f"HTTP error occurred: {http_err}") except requests.exceptions.RequestException as req_err: print(f"Request exception occurred: {req_err}") except ValueError as val_err: print(f"Value error occurred: {val_err}") except Exception as err: print(f"Other error occurred: {err}") ``` Example output (with breaking down the result by validators): ```bash theme={null} Gross APY: 0.0312 Net APY: 0.0287 Stake: 1411 ETH Rewards: Type: consensus Amount: 5.195236601009028 ETH --- Type: execution Amount: 1.188704036616951 ETH --- ``` * `Gross APY` — delegator annual percentage yield (APY) before the validator fee (`grossApy`). * `Net APY` — delegator APY after the validator fee (`netApy`). * `Stake` — total stake balance of the delegator. * `Rewards`: * `Type` — rewards type: `consensus` or `execution`. * `Amount` — amount of tokens in the stake. ### Get Validator Summary To retrieve the validator summary, use the following code with the API endpoint [/api/v1/\{network}/data/validator/summary](/reference/data-validator-summary): ```python Python theme={null} import requests # API endpoint. url = "https://api.p2p.org/api/v1/{network}/data/validator/summary" # Include your Bearer token for authentication. headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } # Specify the following parameters: params = { "address": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", # Validator address in the required network. For the Ethereum network, it is a public validator key. "network": "ethereum", # Network name. "startAt": "2024-04-17T15:00:00.000Z", # Report data start time in the ISO 8601 format. "finishAt": "2024-04-19T15:00:00.000Z", # Report data finish time in the ISO 8601 format. "limit": 50, # Number of resources that a single response page contains. "offset": 0 # Number of resources to exclude from the beginning of a response. } try: # Make the request. response = requests.get(url.format(network=params["network"]), headers=headers, params=params) # Check the response status. response.raise_for_status() # Parse the JSON response. data = response.json() # Check if the response contains data. if data and "result" in data: validator_summary = data["result"] # Print the validator summary information. print("Validator Summary:") print("---") # Iterate over each item in the list. for item in validator_summary["list"]: print("Staking Period:", item["stakingPeriod"]) print("Start:", item["stakingPeriodStart"]) print("End:", item["stakingPeriodEnd"]) print("APY:", item["apy"]) print("Stake:", item["stake"], "ETH") # Print the rewards information. print("Rewards:") for reward in item["rewards"]: print("Amount:", reward["amount"], reward["currency"]) print("---") else: print("Empty response received.") except requests.exceptions.HTTPError as http_err: print(f"HTTP error occurred: {http_err}") except requests.exceptions.RequestException as req_err: print(f"Request exception occurred: {req_err}") except ValueError as val_err: print(f"Value error occurred: {val_err}") except Exception as err: print(f"Other error occurred: {err}") ``` Example output (without breaking down the results by validators): ```bash theme={null} Validator Summary: --- Staking Period: 277903 Start: 2024-04-19 14:59:35 End: 2024-04-19 15:05:59 APY: 0.024850512 Stake: 32.01709 ETH Rewards: Amount: 9.683e-06 ETH --- Staking Period: 277902 Start: 2024-04-19 14:53:11 End: 2024-04-19 14:59:35 APY: 0.024770953 Stake: 32.01708 ETH Rewards: Amount: 9.652e-06 ETH --- ``` * `Staking Period` — number of the staking period. * `Start` and `End` — timestamp of the staking period start and finish in the ISO 8601 format. * `APY` — validator annual percentage yield (APY). * `Stake` — total stake balance of the validator. * `Rewards`: * `Amount` — amount of tokens in the stake. # Getting started Source: https://docs.p2p.org/docs/getting-started-ssv-31 Prerequisites and setup for staking on the SSV network with the SSV 3.1 flow. To start staking on the SSV network using our SSV 3.1, there are a few essential **prerequisites** to ensure a smooth and efficient setup: * **Minimum Stake Requirement**: You will need a minimum of 32 ETH for each staking validator you wish to run. * **API Key Request**: [Get an authentication token](/docs/authentication) to start using DVT Staking API. We created an API endpoint to return the transaction data required to interact with our proxy smart contract. We also provide convenient request examples using [cURL](https://curl.se/) to guide you through the process. While the use of the API method is not mandatory for the smart contract interaction, we recommend it for a faster integration. > [!WARNING] > > **Please note** > > On May 7, 2025, the major Ethereum network upgrade was carried out that brought many benefits for clients who use ETH or SSV validators. **P2P.ORG recommends** upgrading to the `0x02` withdrawal credentials to enhance your functionality. It can be done in two ways: > > * By [consolidating multiple existing validators](/docs/validator-consolidation) into a single one > * By [creating a new `0x02`-enabled validator](/docs/new-validator-creation) via simplified 3.1 smart contract flow > > For more details, see [Pectra Upgrade overview](/docs/pectra-overview). > > However, upgrading to the new address format is not necessary, all existing endpoints remain supported. You can follow the `0x01` creation flow below, if you need fine-grained control over validator count, effective balance per validator, or you intend to manually broadcast deposit transactions. ## Staking via [SSV Proxy Smart Contract](/docs/unlimited-unified-api#p2porg-dvt-staking-architecture-overview-1) and API 1. Create a serialized transaction for depositing the stake amount to the SSV proxy smart contract by sending a GET request to [/api/v1/eth/staking/ssv/p2p/deposit](/reference/p2p-transaction-deposit). Example request: ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposit \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "amount": 32, "amountPerValidator": "32000000000", "withdrawalCredentialsType": "0x01", "withdrawalAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposit", { method: "POST", headers: { "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ "amount": 32, "amountPerValidator": "32000000000", "withdrawalCredentialsType": "0x01", "withdrawalAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17" }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposit", headers={ "authorization": "Bearer ", "content-type": "application/json", }, json={ "amount": 32, "amountPerValidator": "32000000000", "withdrawalCredentialsType": "0x01", "withdrawalAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17" }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "amount": 32, "amountPerValidator": "32000000000", "withdrawalCredentialsType": "0x01", "withdrawalAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposit", bytes.NewBuffer(body)) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `amount` — amount of ETH to deposit. The value must be in multiples of 32 ETH. * `amountPerValidator` — amount of tokens to stake in Gwei per validator. Note that if the amount is more than 32 ETH (1 ETH = 10⁹ Gwei), the `withdrawalCredentialsType` parameter defaults to `0x02`. * `withdrawalCredentialsType` — withdrawal credentials preferred format: `0x01` or `0x02`. * `withdrawalAddress` — withdrawal address for the validators. * `feeRecipientAddress` — Eth1 address that receives the fee recipient rewards. Example response: ```json theme={null} { "error": null, "result": { "serializeTx": "0x02f902cf0580021e830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030b4b5f251eac53f34eb1da2b6659d35db303e408c4c830156cf090441564474f356abd023a0e679aa97cefeed850abb27000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000009c7d4b4595402ed44167c74f9f7c7720ab5528e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060a307b2e1661bcc38d482a69603713baf332ad36adf837392e9f20a96b77a03ca415a46261fc62b8f5d4aa69a0d70e2cf0d23e3396bd387cfde18d392a2c7ba822d3f8a60d075366625dcb3c88cd59ebc8f7ab1fc312c6b8b625a57bf7e1b6e6f000000000000000000000000000000000000000000000000000000000000000178ae581ccc8bdf1fde00cff35b2278e1c10a9ed2fc18632373dac118a03cfacdc0", "to": "0x681a1b3441c6BFb12f91651EFD9F02c83c070293", "gasLimit": "0.0000000000001", "data": "0x4f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030b4b5f251eac53f34eb1da2b6659d35db303e408c4c830156cf090441564474f356abd023a0e679aa97cefeed850abb27000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000009c7d4b4595402ed44167c74f9f7c7720ab5528e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060a307b2e1661bcc38d482a69603713baf332ad36adf837392e9f20a96b77a03ca415a46261fc62b8f5d4aa69a0d70e2cf0d23e3396bd387cfde18d392a2c7ba822d3f8a60d075366625dcb3c88cd59ebc8f7ab1fc312c6b8b625a57bf7e1b6e6f000000000000000000000000000000000000000000000000000000000000000178ae581ccc8bdf1fde00cff35b2278e1c10a9ed2fc18632373dac118a03cfacd", "value": "32.0", "chainId": 1, "type": 2, "maxFeePerGas": "0.00000000000000003", "maxPriorityFeePerGas": "2", "marker": "8bb5a5d4-145c-4a22-b792-3fd98565bdd0" } } ``` * `serializeTx` — serialized unsigned transaction. * `to` — recipient address for this transaction. * `gasLimit` — maximum gas limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. * `marker` — additional identifier of the deposit transaction. You can use it to search the deposits with [Get List Deposits](/reference/p2p-transaction-deposit-list) endpoint. 2. Use `serializeTx` from the previous step to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. By broadcasting this transaction, you are depositing the requested stake amount in the Ethereum deposit smart contract by using the SSV proxy smart contract. Also, the smart contract will register the newly created validators on the SSV protocol. After your deposit is successful, your validator will enter the activation queue and soon start performing the validator tasks. You can check the status of your validator on the [SSV network explorer](https://goerli.explorer.ssv.network/validators). 3. Check the list of validators created via your authentication token and their status by sending a GET request to [/api/v1/eth/staking/ssv/p2p/deposits](/reference/p2p-transaction-deposit). Example request: ```bash curl theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposits?limit=50&offset=0&type=withdrawalAddress&withdrawalAddress=0xe3bb3cc1fd44fced699e5eae6fbbc643a0fbcca0 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposits?limit=50&offset=0&type=withdrawalAddress&withdrawalAddress=0xe3bb3cc1fd44fced699e5eae6fbbc643a0fbcca0", { headers: { "authorization": "Bearer ", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposits?limit=50&offset=0&type=withdrawalAddress&withdrawalAddress=0xe3bb3cc1fd44fced699e5eae6fbbc643a0fbcca0", headers={ "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposits?limit=50&offset=0&type=withdrawalAddress&withdrawalAddress=0xe3bb3cc1fd44fced699e5eae6fbbc643a0fbcca0", nil) req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `limit` — number of resources that a single response page contains. * `offset` — number of resources to exclude from a response. * `type` — type of filter: * `withdrawalAddress` — withdrawal address for the validators. * `transactionHash` — hash of the deposit transaction. * `depositIds` — list of the deposit IDs. * `markers` — additional identifier of the deposit transaction. Example response: ```json theme={null} { "error": null, "result": { "list": [ { "deposit": { "depositId": "", "marker": "faee00fc-f282-43eb-a15f-27d2ed97479e", "transactionHash": "", "senderAddress": "", "withdrawalAddress": "0xe3bb3cc1fd44fced699e5eae6fbbc643a0fbcca0", "feeRecipientAddress": "", "totalAmount": "", "unprocessedAmount": "18273" }, "validator": { "pubkey": "0xcd5ff4fbeafeb6bcdc5dde3ba41d88638eb7b14e52ee3beaf0d32ae3abb303ff8814258ecaa49c5ed0bd7dd48bb0ca502ac89c0bcd36dc7b01a00b8db1e4adec", "status": "unknown", "amount": "1991", "withdrawalCredentials": "...", "signature": "...", "depositMessageRoot": "...", "depositDataRoot": "...", "forkVersion": "10000910", "depositCliVersion": "2.7.0", "eth2NetworkName": "hoodi" } }, ], "limit": 50, "offset": 0, "totalCount": 17, "totalAmount": "18273", "unprocessedAmount": "18273", "markers": [ { "marker": "faee00fc-f282-43eb-a15f-27d2ed97479e", "processStatus": "confirmed", "address": ",,,", "amount": "400", "amountPerValidator": "40000000000", "feeRecipientAddress": "..." } ] } } ``` * `deposit`: * `depositId` — unique identifier for the deposit initiated by the user. * `marker`— unique identifier of the deposit transaction * `transactionHash` — hash of the transaction associated with the user's validator deposit. * `senderAddress` — address used to interact with the SSV proxy smart contract and transfer the requested stake amount. * `withdrawalAddress` — withdrawal address for the validators. * `feeRecipientAddress` — the address that receives the fee recipient rewards. * `totalAmount` — total amount currently staked for the specified deposit ID. * `unprocessedAmount` — amount associated with validators that are not yet activated for the specified deposit ID * `validator`: * `pubkey` — validator public key. * `status` — current status of the validator * `amount` — amount of ETH, denominated in gwei, that is being deposited. * `limit` — number of resources that a single response page contains. * `offset` — number of resources to exclude from a response. * `totalCount` — total number of validators relevant to the current request, based on applied filters. * `totalAmount` — total staked amount for the current request. * `unprocessedAmount` — cumulative staked amount across all validators that are not yet activated for the current request. * `markers` — Unique identifiers generated after creating a deposit request, tracking transactions and deposited funds. # Incremental Staking (Top-ups) Source: https://docs.p2p.org/docs/incremental-staking-tops-up Pectra Upgrade brought to the Ethereum staking many new features, such as increasing of the validator maximum effective balance in particular. This now makes it possible to , as well as and , up to a total of 2048 ETH. Contributing to the validator's total stake is especially convenient, as the general top-up flow supports an amount starting from 1 ETH, whilst to create a new validator, at least 32 ETH are required. To increase the stake of your validator: 1. Create an increment request. 2. Check the status of the request. 3. Sign and broadcast the transaction. Request examples are provided using [cURL](https://curl.se/). > [!TIP] > > The flow is supported for both Ethereum and SSV validators via the same endpoint. ## 1. Create increment request > The flow applies only to active validators using the `0x02` type of withdrawal credentials. 1. Prepare `id` that is an arbitrary UUID. Generate it in one of the following ways: * [Online UUID Generator](https://www.uuidgenerator.net/) * [uuid npm package](https://www.npmjs.com/package/uuid) 2. Send a POST request to [/api/v1/eth/staking/direct/increment-request/create](/reference/eth-increment-request-create). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/direct/increment-request/create \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "id": "f293e499-9188-4e01-8e7c-621038967b06", "pubkeys": [ "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39" ], "amountPerValidator": "10000000000", "withdrawalAddress": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb" }' ``` * `id` — arbitrary UUID. You can later use that UUID to check the status of the top-up operation. * `pubkeys` — list of validators' public keys. * `amountPerValidator` — amount of tokens to stake in Gwei per validator. * `withdrawalAddress` — withdrawal address for the validators. Example response: ```json JSON theme={null} { "error": null, "result": true } ``` ## 2. Check request status Check the status of the top-up operation by sending a GET request to [/api/v1/eth/staking/direct/increment-request/status/\{id}](/reference/eth-increment-request-status). Example request: ```bash bash theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/direct/increment-request/status/f293e499-9188-4e01-8e7c-621038967b06 \ --header 'accept: application/json' --header 'Authorization: Bearer ' ``` Example response: ```json JSON theme={null} { "error": null, "result": { "id": "f293e499-9188-4e01-8e7c-621038967b06", "status": "ready", "withdrawalAddress": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb", "amountPerValidator": "1000000000", "pubkeys": [ "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39" ], "depositData": [], "incrementTxs": [ { "serializeTx": "0x02f901d983088bb0808404521e85847d276925839896809400000000219ab540356cbb839cbe05303d7705fa880de0b6b3a7640000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120bd3d5b43a2f35b2c8ab809dcdaf619ab1a068d944e02359e5b6cd1eb5c69daea0000000000000000000000000000000000000000000000000000000000000030a3ee378399d9eb0aa126594965866e8785033005709e2816c3969963d99cdce11ee6b0ff3c6410aca6b1cb2e820b28420000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200200000000000000000000005419e9924ecd177418639cdce74cc3929c1472e80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0", "to": "0x00000000219ab540356cBB839Cbe05303d7705Fa", "gasLimit": "10000000", "data": "0x22895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120bd3d5b43a2f35b2c8ab809dcdaf619ab1a068d944e02359e5b6cd1eb5c69daea0000000000000000000000000000000000000000000000000000000000000030a3ee378399d9eb0aa126594965866e8785033005709e2816c3969963d99cdce11ee6b0ff3c6410aca6b1cb2e820b28420000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200200000000000000000000005419e9924ecd177418639cdce74cc3929c1472e80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "value": "1000000000000000000", "chainId": 560048, "type": 2, "maxFeePerGas": "2099734821", "maxPriorityFeePerGas": "72490629" } ], "createdAt": "2023-08-24T08:14:50.455Z" } } ``` * `id` — arbitrary UUID of the top-up request. * `status` — current status of the top-up request: * `init` — request is created. * `processing` — request is in progress. * `ready` — backend has the deposit data for the top-up request. * `cancel` — something went wrong, and the deposit data was not created. * `withdrawalAddress` — withdrawal address for the validators. * `pubkeys` — list of validators' public keys. * `amountPerValidator` — amount of tokens to stake in Gwei per validator. * `depositData` for each validator: * `pubkey` — validator public key. * `signature` — validator signature. * `depositDataRoot` — SHA-256 hash of the SSZ-encoded `depositData` object. Used as a protection against malformed input. * `withdrawalCredentials`— withdrawal address credentials, passed in the expected format by the Ethereum deposit smart contract. * `amount` — amount of ETH, denominated in Gwei, that is being deposited. * `depositMessageRoot` — cryptographic hash of the Merkle tree's root, ensuring the integrity and authenticity of the deposit data. * `forkVersion` — version of the network fork that the deposit is intended for. It helps in aligning the deposit with a specific version of the protocol. * `eth2NetworkName` — name of the Ethereum 2.0 network where the deposit is made. * `depositCliVersion` — version of the deposit command-line interface (CLI) tool that was used to generate the deposit data. * `incrementTxs` — list of serialized transaction payloads to increment the validator stake. * `serializeTx` — serialized unsigned transaction. * `to` — recipient address for this transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ## 3. Sign and broadcast transaction Prepare `serializeTx` from the previous step to [sign](/docs/signing-transaction-eth) and broadcast the signed transaction to the Ethereum network. After the transaction is processed in the chain's queue, the validator's stake will be topped up. # Initial Staking Source: https://docs.p2p.org/docs/initial-staking Create 0x02 validators through the simplified smart contract flow introduced with the Pectra upgrade. For setting up validators, P2P.ORG has introduced a new **simplified smart contract flow** — validators created this way receive the `0x02` type of withdrawal credentials. Compared to the previous `0x01` type, this brings the following benefits: * Flexible effective balance from 32 ETH up to 2048 ETH * New staking options such as [incremental top-ups](/docs/incremental-staking-top-up) and auto compounding * Simplified flow with fewer steps and reduced manual deposit data handling All changes are supported for both Ethereum and SSV staking APIs. To upgrade to the `0x02` credentials type, you can either [consolidate multiple existing validators](/docs/validator-consolidation) into a single one or set up a new `0x02`-enabled validator by following the steps below: 1. Prepare a proxy staking transaction. 2. Sign and broadcast the transaction. Request examples are provided using [cURL](https://curl.se/). > [!TIP] > > **Upgrade is just an option** > > For clients currently using the `0x01` validator setup, all existing endpoints remain supported. If you need to create a new validator via the previous `0x01` flow, refer to the guides for the [Ethereum](/docs/staking-ethereum) or [SSV](/docs/overview-dvt-solutions) networks respectively. > > Upgrading to the `0x02` type of withdrawal credentials is not necessary, but only recommended for enhanced functionality. ## 1. Prepare staking proxy transaction > This flow is supported for Ethereum Direct staking only and applies exclusively to validators using `0x02` type of withdrawal credentials. Send a GET request to [/api/v1/eth/staking/direct/p2p/deposit](/reference/p2p-transaction-direct-deposit) with the following query parameters specified: `amount`, `withdrawalAddress`, `controllerAddress` and `feeRecipientAddress`. By calling this endpoint, you are receiving a transaction fully constructed by Ethereum Smart Contract 3.1 which is ready for signing and broadcasting. Example request: ```bash bash theme={null} curl --request GET \ --url "https://api-test.p2p.org/api/v1/eth/staking/direct/p2p/deposit?amount=32&withdrawalAddress=0x8eB2277e54A2A7db9b7c0D9FA9B78dcB35f74866&controllerAddress=0x8eB2277e54A2A7db9b7c0D9FA9B78dcB35f74866&feeRecipientAddress=0x3202B5B0602274197CcB22B8c02CEC9539990c7c" \ --header 'Authorization: Bearer ' ``` * `amount` — total amount of ETH to deposit. Note that the maximum effective balance is 2048 ETH, so it is recommended specifying no more than 1920 ETH in order to save the opportunity to auto-compound the received rewards. * `amountPerValidator` — amount of tokens to stake in Gwei per validator. * `withdrawalAddress` — withdrawal address for the validators. * `controllerAddress` — controller address (On Ethereum, we introduced the controller address entity to provide greater flexibility and maintain high-level security during the withdrawal flow. When the user requests the validator withdrawal, only authorized addresses can initiate this request by calling our withdrawal smart contract. The authorized addresses are the withdrawal address and the controller address. Since many users prefer not to use the withdrawal address to interact with smart contracts, a second authorized address can be specified as controller address in the new staking request.) for the validators. * `feeRecipientAddress` — address that receives priority fees. Example response: ```json JSON theme={null} { "error": null, "result": { "serializeTx": "0x02f9025701808312c36c850727b59762839896809423be839a14cec3d6d716d904f09368bbf9c750eb8903782dace9d9000000b90224a49b131b0200000000000000000000008eb2277e54a2a7db9b7c0d9fa9b78dcb35f74866000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000003fcd8d9acac042095dfba53f4c40c74d19e2e9d9000000000000000000000000000000000000000000000000000000000000251c0000000000000000000000003202b5b0602274197ccb22b8c02cec9539990c7c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000e86b78000ed3b7b820ac6a39b46602356daee0602180fefa69a94774c3209a9f5ad1df42aa2c426b1494a39afc4ee79a528dca95807f5a1b518c8fb0a4df1be92b8a8b6e5f4fccf35f3975f9cf64aa92f4896f2553a5ba9fb0b13cabb25f21a2881f027d9703bfa57f45a514fff7bcc1b8020c2a3ab0581cfbb748dfe612a14acef40bc61de068cf3117e8227ab1315e0302f97e17d5b8948aa8071645b27ad74f669783d363fbc7e9dd58c01e535aff418b2fdbff56a55212e25efbc6b963bb048d98ecc1d03020f890bbf7518fd2463afb82ffdf452863268bdae4eae18d6108dce9ef803669f466000000000000000000000000000000000000000000000000c0", "to": "0x23BE839a14cEc3D6D716D904f09368Bbf9c750eb", "gasLimit": "10000000", "data": "0xa49b131b0200000000000000000000008eb2277e54a2a7db9b7c0d9fa9b78dcb35f74866000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000003fcd8d9acac042095dfba53f4c40c74d19e2e9d9000000000000000000000000000000000000000000000000000000000000251c0000000000000000000000003202b5b0602274197ccb22b8c02cec9539990c7c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000e86b78000ed3b7b820ac6a39b46602356daee0602180fefa69a94774c3209a9f5ad1df42aa2c426b1494a39afc4ee79a528dca95807f5a1b518c8fb0a4df1be92b8a8b6e5f4fccf35f3975f9cf64aa92f4896f2553a5ba9fb0b13cabb25f21a2881f027d9703bfa57f45a514fff7bcc1b8020c2a3ab0581cfbb748dfe612a14acef40bc61de068cf3117e8227ab1315e0302f97e17d5b8948aa8071645b27ad74f669783d363fbc7e9dd58c01e535aff418b2fdbff56a55212e25efbc6b963bb048d98ecc1d03020f890bbf7518fd2463afb82ffdf452863268bdae4eae18d6108dce9ef803669f466000000000000000000000000000000000000000000000000", "value": "64000000000000000000", "chainId": 1, "type": 2, "maxFeePerGas": "30730983266", "maxPriorityFeePerGas": "1229676", "marker": "8bb5a5d4-145c-4a22-b792-3fd98565bdd0" } } ``` * `serializeTx` — serialized unsigned transaction. * `to` — recipient address for this transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. * `marker` — additional identifier of the deposit transaction. You can use it to search the deposits with [Get List Deposits](/reference/p2p-transaction-deposit-list) endpoint. ## 2. Sign and broadcast transaction Prepare `serializeTx` from the previous step and use the example code below to sign and broadcast the transaction to the Ethereum network: ```bash bash theme={null} require("dotenv").config(); const ethers = require("ethers"); async function signAndBroadcast() { console.log("Started"); // Enter the serialized transaction const rawTransaction = process.env.RAW_TRANSACTION; // Enter the private key of the address used to transfer the stake amount const privateKey = process.env.PRIVATE_KEY; // Enter the selected RPC URL const rpcURL = process.env.RPC_URL; // Initialize the provider using the RPC URL const provider = new ethers.providers.JsonRpcProvider(rpcURL); // Initialize a new Wallet instance const wallet = new ethers.Wallet(privateKey, provider); // Parse the raw transaction const tx = ethers.utils.parseTransaction(rawTransaction); tx.nonce = await provider.getTransactionCount(wallet.address); // Enter the max fee per gas and prirorty fee tx.maxFeePerGas = ethers.utils.parseUnits( process.env.MAX_FEE_PER_GAS_IN_GWEI, "gwei" ); tx.maxPriorityFeePerGas = ethers.utils.parseUnits( process.env.MAX_PRIORITY_FEE_IN_GWEI, "gwei" ); // Sign the transaction const signedTransaction = await wallet.signTransaction(tx); // Send the signed transaction const transactionResponse = await provider.sendTransaction(signedTransaction); return transactionResponse; } signAndBroadcast() .then((transactionResponse) => { console.log( "Transaction broadcasted, transaction hash:", transactionResponse.hash ); }) .catch((error) => { console.error("Error:", error); }) .finally(() => { console.log("Finished"); }); ``` After the transaction is processed in the chain's queue, the new validator with `0x02` type of withdrawal credentials will be set up. ## 3. Get list of deposits Check the list of validators created via your authentication token and their status by sending a GET request to [/api/v1/eth/staking/direct/p2p/deposits](/reference/p2p-transaction-direct-deposit-list). Example request: ```bash bash theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/ssv/p2p/deposits?limit=50&offset=0&type=withdrawalAddress&withdrawalAddress=0xe3bb3cc1fd44fced699e5eae6fbbc643a0fbcca0 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` * `limit` — number of resources that a single response page contains. * `offset` — number of resources to exclude from a response. * `type` — type of filter: * `withdrawalAddress` — withdrawal address for the validators. * `transactionHash` — hash of the deposit transaction. * `depositIds` — list of the deposit IDs. * `markers` — additional identifier of the deposit transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "list": [ { "deposit": { "depositId": "", "marker": "faee00fc-f282-43eb-a15f-27d2ed97479e", "transactionHash": "", "senderAddress": "", "withdrawalAddress": "0xe3bb3cc1fd44fced699e5eae6fbbc643a0fbcca0", "feeRecipientAddress": "", "totalAmount": "", "unprocessedAmount": "18273" }, "validator": { "pubkey": "0xcd5ff4fbeafeb6bcdc5dde3ba41d88638eb7b14e52ee3beaf0d32ae3abb303ff8814258ecaa49c5ed0bd7dd48bb0ca502ac89c0bcd36dc7b01a00b8db1e4adec", "status": "unknown", "amount": "1991", "withdrawalCredentials": "...", "signature": "...", "depositMessageRoot": "...", "depositDataRoot": "...", "forkVersion": "10000910", "depositCliVersion": "2.7.0", "eth2NetworkName": "hoodi" } }, ], "limit": 50, "offset": 0, "totalCount": 17, "totalAmount": "18273", "unprocessedAmount": "18273", "markers": [ { "marker": "faee00fc-f282-43eb-a15f-27d2ed97479e", "processStatus": "confirmed", "address": ",,,", "amount": "400", "amountPerValidator": "40000000000", "feeRecipientAddress": "..." } ] } } ``` * `deposit`: * `depositId` — unique identifier for the deposit initiated by the user. * `marker`— unique identifier of the deposit transaction * `transactionHash` — hash of the transaction associated with the user's validator deposit. * `senderAddress` — address used to interact with the SSV proxy smart contract and transfer the requested stake amount. * `withdrawalAddress` — withdrawal address for the validators. * `feeRecipientAddress` — the address that receives the fee recipient rewards. * `totalAmount` — total amount currently staked for the specified deposit ID. * `unprocessedAmount` — amount associated with validators that are not yet activated for the specified deposit ID * `validator`: * `pubkey` — validator public key. * `status` — current status of the validator * `amount` — amount of ETH, denominated in gwei, that is being deposited. * `limit` — number of resources that a single response page contains. * `offset` — number of resources to exclude from a response. * `totalCount` — total number of validators relevant to the current request, based on applied filters. * `totalAmount` — total staked amount for the current request. * `unprocessedAmount` — cumulative staked amount across all validators that are not yet activated for the current request. * `markers` — Unique identifiers generated after creating a deposit request, tracking transactions and deposited funds. # Aggregated Docs for LLMs Source: https://docs.p2p.org/docs/llms Reference the entire P2P.ORG API documentation in your AI tool ## Add P2P.ORG Docs to Your LLM Adding P2P.ORG docs to your LLM lets you interact with our docs and get the most accurate answers to your questions. Access the outline of the docs, including links to all markdown pages, here: * [https://docs.p2p.org/llms.txt](https://docs.p2p.org/llms.txt). To access the full content of these pages, you can also access this aggregated markdown file containing the whole documentation: 1. Go to [p2p\_aggregated\_docs.md](https://github.com/AndreGZommerfelds/p2p-docs-aggregator/blob/main/p2p_aggregated_docs.md) 2. Attach the file to your LLM, or reference it directly in the AI tool ## Example Using Cursor [Cursor](https://www.cursor.com/) is an AI code editor that makes it easy to write code while integrating with P2P.ORG APIs. Here is how to setup Cursor to build with our documentation. This will let you interact with our docs directly and get the most accurate answers to your questions. 1. Go to Cursor Settings > Features > Docs and click "+ Add new doc" 2. Paste [this URL](https://raw.githubusercontent.com/AndreGZommerfelds/p2p-docs-aggregator/refs/heads/main/p2p_aggregated_docs.md) 3. Change the name to P2P, and leave everything else the same. 4. Wait until the docs have been fully indexed. You can check the progress in the Cursor Settings. 5. Now you can reference the P2P docs in your prompt using `@P2P` # Using MCP to Read API Docs Source: https://docs.p2p.org/docs/mcp Read the P2P.ORG API documentation using our MCP server The P2P.ORG Model Context Protocol (MCP) server connects AI-powered coding tools like Cursor or Claude Code to P2P.ORG’s API documentation, giving LLMs context for the entire API documentation. This enables developers to easily explore APIs, clarify technical questions, and streamline integrations with confidence. ## Exploring the Model Context Protocol (MCP) MCP is an open-source standard that enables AI systems to securely engage with external services and data. By leveraging the P2P.ORG MCP server, AI tools can provide context-aware support that simplifies integration and enhances development efficiency. Key benefits include: * Providing rich context to AI systems for accurate interaction with P2P.ORG’s platform. * Simplifying the process of clarifying and answering technical questions about APIs and features. * Facilitating smoother and faster integration with P2P.ORG’s ecosystem through tailored support. **Note**: The P2P.ORG MCP server currently supports only read and search functionalities. Direct API execution is not yet available. ## Configuring the P2P.ORG MCP Server To connect your AI tools to P2P.ORG’s resources, direct your AI tools to the MCP server at * `https://docs.p2p.org/mcp` P2P.ORG hosts a remote MCP server at this URL. Configure your AI development tools to connect to this server: > [tab] Cursor > > **Add to `~/.cursor/mcp.json`:** > > ```json theme={null} > { > "mcpServers": { > "p2p-staking": { > "url": "https://docs.p2p.org/mcp" > } > } > } > ``` > [tab] Windsurf > > **Add to `~/.codeium/windsurf/mcp_config.json`:** > > ```json theme={null} > { > "mcpServers": { > "p2p-staking": { > "url": "https://docs.p2p.org/mcp" > } > } > } > ``` > [tab] Claude Desktop > > **Add to `claude_desktop_config.json`:** > > ```json theme={null} > { > "mcpServers": { > "p2p-staking": { > "url": "https://docs.p2p.org/mcp" > } > } > } > ``` ### Testing Your P2P.ORG MCP Setup Once configured, you can test your MCP server connection: 1. **Open your AI editor** (Cursor, Windsurf, etc.) 2. **Start a new chat** with the AI assistant 3. **Ask about P2P.ORG** - try questions like: * "How do I \[common use case]?" * "Show me an example of \[API functionality]" * "Create a \[integration type] using P2P.ORG" The AI should now have access to your P2P.ORG account data and documentation through the MCP server. ## Alternative: Using Context7 MCP Context7 MCP setup: Alternatively, you can reference our API documentation directly using the Context7 MCP: * See setup instructions here: [https://github.com/upstash/context7](https://github.com/upstash/context7) * Reference our documentation: [Context7 - P2P.ORG API Documentation Hub](https://context7.com/context7/p2p) ### Testing Your Context7 MCP Setup Once you have set up Context7 MCP, you can ask your LLM to use it to check the P2P.ORG documentation. Here are some prompt examples: * `Please read the P2P.ORG API documentation with context7 MCP and prepare for any questions I might have.` * `Please read the P2P.ORG API documentation with context7 MCP and tell me what are the two different ways to integrate with SSV. Make a concise table overview.` * `Please read the P2P.ORG API documentation with context7 MCP and tell me how many networks are supported in the Unified API. Make a concise table overview.` *** AI tools can make mistakes, so double-check the answer, and in case of doubt contact us: [Contacts](/docs/contacts). # Morpho Source: https://docs.p2p.org/docs/morpho Morpho, a non-custodial lending protocol, available through the P2P.org DeFi API. Morpho is a decentralized, non-custodial lending protocol that operates on Ethereum and other EVM-compatible networks. The protocol consists of two primary components: * Morpho Markets providing collateral and borrowable asset pairs, * Morpho Vaults providing managed yield strategies that allocate deposits across multiple markets. The P2P.ORG DeFi API supports Morpho on the Ethereum mainnet and Base network. Some strategies (e.g., Steakhouse Financial) are available on both networks. To retrieve the complete list of available Morpho strategies, send a GET request to the dedicated P2P.ORG [/api/defi/v1/earning/strategies](/reference/get-strategies) endpoint. ## Integration prerequisites Morpho operates through a proxy-based model. Each user creates their own proxy contract, which subsequently facilitates revenue sharing between parties. Since a new P2P Morpho proxy is deployed deterministically at deposit time, the smart contract receiving the deposit does not exist on-chain before the first deposit. Accordingly, the pre-calculated address must be whitelisted in advance. If your platform uses whitelists restricting which contracts users can deposit to, follow the steps below to ensure successful integration. > [!WARNING] > > A custom identifier linked to your merchant account is required. [Get an authentication token](/docs/authentication) to start using DeFi API. ### 1. Whitelist required addresses Before any USDT or USDC deposit can be made, three addresses must be whitelisted in your system: | # | Name | Address | | - | - | - | | 1 | P2pMorphoProxyFactory | `0x3FE77F22a81c787B2E8dBF366F963f772E799568` | | 2 | USDT Token (ERC-20) | `0xdAC17F958D2ee523a2206206994597C13D831ec7` | | 3 | Permit2 | `0x000000000022D473030F116dDEE9F6B43aC78BA3` | > **Note for USDC:** For the USDC token address, follow the same whitelisting pattern (`0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`) *** ### 2. Whitelist future proxy address The proxy address is derived deterministically from your depositor wallet address — it does not exist on-chain until the first deposit is made. To get your pre-calculated proxy address, call the `predictP2pLendingProxyAddress` read function on the P2pMorphoProxyFactory contract directly on Etherscan: 1. Go to the contract's **Read Contract** tab on Etherscan: [0x3FE77F22a81c787B2E8dBF366F963f772E799568 – Read Contract](https://etherscan.io/address/0x3fe77f22a81c787b2e8dbf366f963f772e799568#readContract). 2. Find the `predictP2pLendingProxyAddress` function. 3. Enter the following parameters: * `_clientAddress`: your depositor wallet address. * `_clientBasisPoints`: `9000`. 4. Click **Query**. The returned address is your future proxy address. Whitelist the returned proxy address **before** attempting the deposit. *** ### 3. Configure transaction authorization policy (TAP) This step is required to allow USDT → Permit2 approvals through your system. Without it, the approval transaction will be blocked at the policy layer. > **Note:** The steps below describe the flow for Fireblocks. The actual UI for your integration may use slightly different naming or layout, but the overall process and intent remain the same. 1. Refer to the **Fireblocks Console → Settings → Governance → Transaction Authorization Policy** section. 2. Go to the **"Approve"** section (not "Transfers"). 3. Add a new rule: | Field | Value | | - | - | | **Asset** | USDT (ERC-20 on Ethereum) | | **Action** | Approve | | **Spender / Contract** | `0x000000000022d473030f116ddee9f6b43ac78ba3` (Permit2) | | **From Wallet(s)** | Your staking wallet address | | **Amount** | `Unlimited` — or set a limit | | **dApp URL (optional)** | `https://widget.p2p.org` — add to tightly restrict scope | 4. Add another rule with USDC (ERC-20 on Ethereum) as the asset, keeping all other fields the same. 5. Save the policy before proceeding. *** ### 4. Check deposit > **Note:** The steps below describe the general deposit flow via the P2P widget. Exact button labels and screen layout for your system may vary — follow the same overall process as described. With all whitelisting and TAP configuration complete: 1. Open the P2P.ORG widget at [**https://widget.p2p.org**](https://widget.p2p.org/). 2. Connect via Fireblocks. 3. Select **USDT** (or **USDC**) on **Ethereum**. 4. Initiate the deposit. The approval and deposit transactions should now route through Fireblocks without being blocked. # Deposit Source: https://docs.p2p.org/docs/morpho-staking > [!NOTE] > > This is a detailed tutorial on how to make a deposit to one of the Morpho's vaults through the DeFi API. To learn more about the flow in general, refer to the [Getting Started](/docs/defi-api-getting-started) section. As an example of using the DeFi API with the Morpho integration, let us consider making the deposit to the Steakhouse USDC vault on the Base network. The process is the following: 1. Get the schema with the step list for obtaining approval. 2. Create the permission request for the permit2 smart contract. 3. Get the schema with the step list for initiating the deposit. 4. Create the permission request for the Morpho bundler. 5. Create the permission request for the P2P.ORG proxy contract. 6. Prepare the final deposit transaction. 7. Broadcast the deposit transaction to the Base network. Before starting, ensure you have met the [prerequisites for successful integration](/docs/morpho-staking). Request examples are provided using [cURL](https://curl.se/) > [!WARNING] > > **This is an example for the Steakhouse USDC vault. Note that for other vaults, the number of steps may vary.** > > This tutorial covers the most complex flow involving construction of three transactions to make a deposit. For the majority of strategies, one transaction is sufficient. ## 1. Get schema for approval Before depositing assets into the vault, first grant permissions to the smart contracts involved in the integration to manage tokens. To check the action schema and retrieve a list of steps required for approval, send a GET request to [/api/defi/v1/transactions/schema](/reference/get-transaction-schema). Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/schema?action=approvePermit2&chain=base&protocol=morpho&strategy=Steakhouse%20USDC' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' --header 'x-client-hash: ' ``` * `action` — operation type; in this case `approvePermit2`. * `chain` — blockchain network, e.g., `base`. * `protocol`— integration name, e.g., `morpho`. * `strategy` — vault name, e.g., `Steakhouse USDC`. * `x-client-hash` — unique identifier of the user or merchant participating in the integration; obtained with the [authentication token](/docs/authentication). Example response: ```json JSON theme={null} { "error": null, "result": { "action": "approvePermit2", "steps": [ { "index": 0, "name": "finalPermit2AllowanceTransaction", "description": "Approve token for Permit2 (ERC20 approve to max uint256 for PERMIT2 spender)", "inputs": [ { "key": "asset", "type": "string", "description": "Asset symbol (e.g., USDC, USDT)", "required": true }, { "key": "amount", "type": "string", "description": "Optional allowance amount in token smallest unit. If omitted, max uint256 is used.", "required": false } ], "outputs": [ { "key": "json", "type": "object", "description": "Built approve transaction data (to, data, value, chainId)" }, { "key": "encoded", "type": "string", "description": "Built approve transaction as encoded serialized transaction" } ], "groupId": 0, "canExecuteInParallel": false, "isUnsignedTransaction": true } ], "stepGroups": [ [ 0 ] ] }, "meta": { "time": 34, "requestId": "e94c3511-5efe-4c3d-aa0f-38d427c3afa0" } } ``` * `action` — operation type; in this case `approvePermit2`. * `steps` — schema with the list of steps describing which transactions you have to construct using the [Craft Transaction Step](/reference/craft-transaction-step) endpoint. * `index` — step number in the execution order. * `name` — transaction type corresponding to the `stepName` request parameter of the [Craft Transaction Step](/reference/craft-transaction-step) endpoint. * `description` — detailed information on the step purpose. * `inputs` — list of request parameters required to construct a transaction, e.g., wallet address, amount of tokens, etc. It may include transactions that require a signature as well. * `key` — parameter name. * `type` — parameter object format. * `description` — detailed information on the parameter. * `required` — boolean flag indicating if this parameter is necessary for the request. * `outputs` — list of fields expected in the transaction response. * `key` — raw transaction payload ready for signing, either `encoded` or `json` (optional). * `type` — transaction payload format. * `description` — detailed information on the payload contents. * `groupID` — identifier of the group to which this step belongs. * `canExecuteInParallel` — boolean flag indicating if it is possible to perform this step asynchronously. By executing in parallel, you can initiate the construction of multiple transactions at the same time. * `true` — step can be performed asynchronously. * `false` — step can only be performed synchronously. * `isUnsignedTransaction` — boolean flag indicating if the result of the step is a transaction that must be signed and broadcasted. * `stepGroups` — groups of steps that can be executed in parallel; currently is not operational. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — unique identifier of the request. > [!TIP] > > **Approval action summary** > > In this schema, the `steps` response array includes one step called `finalPermit2AllowanceTransaction`. > > It means that to approve token management, you have to prepare only one transaction and then sign and broadcast it. ## 2. Create permission request for permit2 contract 1. To allow Morpho's [Permit2 contract](https://docs.uniswap.org/contracts/permit2/overview) to perform any operations with the specified amount of tokens, send a POST request to [/api/defi/v1/transactions/steps/craft](/reference/craft-transaction-step). Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/steps/craft' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "chain": "base", "action": "approvePermit2", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x0000000000000000000000000000000000000001", "options": { "executionMode": "sync" }, "stepName": "finalPermit2AllowanceTransaction", "payload": { "asset": "USDC", "amount": "10000" } } ' ``` * `action` — operation type. * `chain` — blockchain network. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `options.executeMode` — DeFi API processing mode. The recommended value for each step can be found in the schema's `canExecuteInParallel` field. * `sync` — synchronous; default for some networks so that the blockchain does not reverse the block in which the transaction is included. In this mode, before continuing with other steps, the user has to wait until the API operation is fully completed and the transaction is returned. * `async` — asynchronous. In this mode, after sending the request, the user can continue with other steps according to the schema and periodically check the request status with the [Get Step Crafting Status](/reference/get-step-status) endpoint. * `stepName` — name of the transaction to construct. In this case, it is `finalPermit2AllowanceTransaction`. * `payload` — transaction data: * `amount` — amount of tokens the permit2 contract is allowed to interact with. You can specify any amount, but not less than the deposit amount. * `asset` — token denomination, e.g., `USDC`. Example response: ```json JSON theme={null} { "error": null, "result": { "operationId": "mock-operation-id-permit2-abc123", "chain": "base", "action": "approvePermit2", "status": "READY_FOR_SIGN", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x0000000000000000000000000000000000000001", "stepList": [ { "index": 0, "type": "transaction", "name": "finalPermit2AllowanceTransaction", "description": "Approve token for Permit2 (ERC20 approve to max uint256 for PERMIT2 spender)", "payload": "****", "verifierMeta": { "signature": "0x0000000000000000000000000000000000000000000000000000000000000000" } } ], "payload": "****", "verifierMeta": { "signature": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "createdAt": "2026-02-13T12:00:00.000Z", "updatedAt": "2026-02-13T12:00:00.000Z" }, "meta": { "time": 100, "requestId": "mock-request-id-permit2-xyz789" } } ``` * `operationId` — unique identifier of the transaction. * `chain` — blockchain network. * `action` — operation type. * `status` — current transaction status: `AWAITING_CRAFT`, `IN_PROGRESS`, `READY_FOR_SIGN` or `DONE`. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `stepList` — list of fields with the step results obtained according to the schema: * `index` — step number in the execution order. * `type` — object format. * `name` — name of the transaction to construct. In this case, it is `finalPermit2AllowanceTransaction`. * `description` — detailed information on the step purpose. * `payload` — raw transaction object ready for signing represented in two formats: `encoded` and `json` (optional). * `verifierMeta` — data object received from P2P.ORG's verifier module. * `signature` — signature provided by the verifier module, which confirms that the transaction was crafted and then cryptographically verified by P2P.ORG. * `payload` — final transaction payload represented either in `encoded` or `json` (optional) format. * `verifierMeta` — final transaction data object received from the verifier module. * `createdAt` — timestamp of the transaction creation in the ISO 8601 format. * `updatedAt` — timestamp of the transaction update in the ISO 8601 format. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — unique identifier of the request. 2. [Sign](/docs/defi-api-signing-transaction#for-final-transactions) the raw `json` or `encoded` object in the `result.payload` field. 3. [Broadcast](/docs/defi-api-signing-transaction#3-broadcast-signed-final-transaction) it to the network by sending a POST request to [/api/defi/v1/transactions/steps/broadcast](/reference/broadcast-transaction). By broadcasting this transaction, you're granting permission to the permit2 smart contract to interact with the specified amount of tokens at your wallet address. ## 3. Get schema for deposit The deposit action may require a various number of steps depending on the target chain and vault. To retrieve a list of steps for the preferred strategy, send a GET request to [/api/defi/v1/transactions/schema](/reference/get-transaction-schema). Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/schema?action=deposit&chain=base&protocol=morpho&strategy=Steakhouse%20USDC' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` * `action` — operation type; in this case `deposit`. * `chain` — blockchain network. * `protocol`— integration name. * `strategy` — vault name. * `x-client-hash` — unique identifier of the user or merchant participating in the integration; obtained with the authentication token. Example response: ```json JSON theme={null} { "error": null, "result": { "action": "deposit", "steps": [ { "index": 0, "name": "permit2SingleDetailsForMorpho", "description": "Prepare Permit2 SingleDetails for Morpho bundler", "inputs": [ { "key": "amount", "type": "string", "description": "Deposit amount in token smallest unit", "required": true }, { "key": "asset", "type": "string", "description": "Asset symbol (e.g., USDC, USDT)", "required": true } ], "outputs": [ { "key": "json", "type": "object", "description": "Permit2 SingleDetails data (amountInTokens, spenderAddress, sigDeadline, nonce, chainId, tokenContractAddress)" }, { "key": "encoded", "type": "string", "description": "Built Permit2 SingleDetails for Morpho bundler as hashed typed data" } ], "groupId": 0, "canExecuteInParallel": false }, { "index": 1, "name": "permit2SingleDetailsForP2pProxy", "description": "Prepare Permit2 SingleDetails for P2P Proxy", "inputs": [ { "key": "amount", "type": "string", "description": "Deposit amount in token smallest unit", "required": true }, { "key": "asset", "type": "string", "description": "Asset symbol (e.g., USDC, USDT)", "required": true }, { "key": "operationId", "type": "string", "description": "Encrypted transaction ID (operationId) from previous step (step 0)", "required": true } ], "outputs": [ { "key": "json", "type": "object", "description": "Permit2 SingleDetails data (amountInTokens, spenderAddress, sigDeadline, nonce, chainId, tokenContractAddress)" }, { "key": "encoded", "type": "string", "description": "Built Permit2 SingleDetails for P2P Proxy as hashed typed data" } ], "groupId": 0, "canExecuteInParallel": false }, { "index": 2, "name": "finalDepositTransaction", "description": "Create final deposit transaction", "inputs": [ { "key": "amount", "type": "string", "description": "Deposit amount in token smallest unit", "required": true }, { "key": "asset", "type": "string", "description": "Asset symbol (e.g., USDC, USDT)", "required": true }, { "key": "permit2SignatureForMorpho", "type": "string", "description": "Signed Permit2 SingleDetails for Morpho bundler (from step 0)", "required": true, "requiresSignature": true, "signatureSource": { "stepIndex": 0, "stepName": "permit2SingleDetailsForMorpho", "outputKey": "encoded" } }, { "key": "permit2SignatureForP2pProxy", "type": "string", "description": "Signed Permit2 SingleDetails for P2P Proxy (from step 1)", "required": true, "requiresSignature": true, "signatureSource": { "stepIndex": 1, "stepName": "permit2SingleDetailsForP2pProxy", "outputKey": "encoded" } }, { "key": "operationId", "type": "string", "description": "Encrypted transaction ID (operationId) from previous step (step 0)", "required": true } ], "outputs": [ { "key": "json", "type": "object", "description": "Built deposit transaction data (to, data, value, chainId)" }, { "key": "encoded", "type": "string", "description": "Built deposit transaction as encoded function data" } ], "inputReferences": [ { "stepIndex": 0, "outputKey": "encoded" }, { "stepIndex": 1, "outputKey": "encoded" }, { "stepIndex": 0, "outputKey": "operationId" } ], "groupId": 1, "canExecuteInParallel": false } ], "stepGroups": [ [ 0, 1 ], [ 2 ] ] }, "meta": { "time": 13, "requestId": "6b1c6203-e455-4093-ab3e-271127be16a5" } } ``` * `action` — operation type. * `steps` — schema with the list of steps describing which transactions you have to construct using the [Craft Transaction Step](/reference/craft-transaction-step) endpoint. * `index` — step number in the execution order. * `name` — transaction type corresponding to the `stepName` request parameter of the [Craft Transaction Step](/reference/craft-transaction-step) endpoint. * `description` — detailed information on the step purpose. * `inputs` — list of request parameters required to construct a transaction, e.g., wallet address, amount of tokens, etc. It may include transactions that require a signature as well. * `key` — parameter name. * `type` — parameter object format. * `description` — detailed information on the parameter. * `required` — boolean flag indicating if this parameter is necessary for the request. * `requiresSignature` — boolean flag indicating if the parameter is a transaction itself that must be signed. * `signatureSource` — detailed information on the step at which the transaction requiring a signature was received: * `stepIndex` — step number. * `stepName` — transaction type. * `outputKey` — resulting object format. * `outputs` — list of fields expected in the transaction response for the specific step. * `key` — raw transaction payload ready for signing. * `type` — object format, which is either `encoded` or `json` (optional). * `description` — detailed information on the payload contents. * `groupID` — identifier of the group to which this step belongs. * `canExecuteInParallel` — boolean flag indicating if it is possible to perform this step asynchronously. By executing in parallel, you can initiate the construction of multiple transactions at the same time. * `true` — step can be performed asynchronously. * `false` — step can only be performed synchronously. * `inputReferences` — references to `key` from previous steps, either from the request or response. * `stepIndex` — step number. * `outputKey` — name of the specific `key` parameter from the step output. * `stepGroups` — groups of steps that can be executed in parallel; currently is not operational. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — unique identifier of the request. > [!TIP] > > **Deposit action summary** > > In this schema, the `steps` response array includes three steps ordered from 0 to 2. It means that the process of depositing assets to a vault requires three actions: > > 1. Allow transferring funds from the user wallet to the P2P proxy contract address. > 2. Allow transferring funds from the P2P proxy contract address to the vault address. > 3. Combine the two previous transactions to obtain the raw deposit transaction. > > For each step, a signature is required. The third and final transaction must have the payloads of the previous two. To complete the deposit action, broadcast the final transaction to the network. > > Accordingly, these transactions can be constructed only consequently, since the value of the `canExecuteInParallel` parameter is `false`. ## 4. Create permission request for the vault 1. Construct the first intermediate `permit2SingleDetailsForMorpho` transaction according to the schema. To allow the Morpho bundler to withdraw assets from the P2P proxy address to the vault address, send a POST request to [/api/defi/v1/transactions/steps/craft](/reference/craft-transaction-step). Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/steps/craft' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "chain": "base", "action": "deposit", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x991c468AbcE2b4DD627a6210C145373EbABdd186", "options": { "executionMode": "sync" }, "stepName": "permit2SingleDetailsForMorpho", "payload": { "amount": "10000", "asset": "USDC" } }' ``` * `chain` — blockchain network. * `action` — operation type. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `options.executeMode` — DeFi API processing mode. The recommended value for each step can be found in the schema's `canExecuteInParallel` field. * `stepName` — step name corresponding to the `name` response parameter of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. In this case, it is `permit2SingleDetailsForMorpho`. * `payload` — transaction data: * `amount` — amount of tokens to deposit. * `asset` — token denomination, e.g., `USDC`. Example response: ```json JSON theme={null} { "error": null, "result": { "operationId": "iR4WV/aWs1Ll+SiOObmZdONXggOufzS5kEYdyxmZMWd8gb6Iu9KILvUWCbatR75x", "chain": "base", "action": "deposit", "status": "IN_PROGRESS", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x991c468AbcE2b4DD627a6210C145373EbABdd186", "stepList": [ { "index": 0, "type": "signature_data", "name": "permit2SingleDetailsForMorpho", "description": "Prepare Permit2 SingleDetails for Morpho bundler", "payload": { "json": { "domain": { "name": "Permit2", "chainId": 8453, "verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3" }, "types": { "PermitDetails": [ { "name": "token", "type": "address" }, { "name": "amount", "type": "uint160" }, { "name": "expiration", "type": "uint48" }, { "name": "nonce", "type": "uint48" } ], "PermitSingle": [ { "name": "details", "type": "PermitDetails" }, { "name": "spender", "type": "address" }, { "name": "sigDeadline", "type": "uint256" } ] }, "primaryType": "PermitSingle", "message": { "details": { "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amount": "10000", "expiration": "281474976710655", "nonce": 0 }, "spender": "0x23055618898e202386e6c13955a58D3C68200BFB", "sigDeadline": "1767173669" } }, "encoded": "0x8675b0c734ce70a49ffcef60f6cbffd3c747091ccf99c783c0fdbec686b29c11" }, "verifierMeta": { "signature": "0x1942c3fdf677c44a333f121e9105d3930a9aac60f393094dba29c9aaa1e230cb" }, "outputKeys": [ "json", "encoded" ] }, null, null ], "payload": null, "verifierMeta": null, "createdAt": "2025-12-24T09:34:29.324Z", "updatedAt": "2025-12-24T09:49:53.551Z" }, "meta": { "time": 3212, "requestId": "25ae64b3-44d0-4bfe-b583-78717ba5581b" } } ``` * `operationId` — unique identifier of the transaction; required for the next steps. * `chain` — blockchain network. * `action` — operation type. * `status` — current transaction status: `AWAITING_CRAFT`, `IN_PROGRESS`, `READY_FOR_SIGN` or `DONE`. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `stepList` — list of fields with the step results obtained according to the schema. > For schemes with multiple steps: if a step has not been performed yet, the field will have `null`. In this example, the response contains data for the step 0 only. * `index` — step number in the execution order. * `type` — object format. * `name` — step name corresponding to the `name` response field of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. * `description` — detailed information on the step purpose. * `payload` — raw transaction object ready for signing represented in two formats: `encoded` and `json` (optional). * `verifierMeta` — data object received from P2P.ORG's verifier module. * `signature` — signature provided by the verifier module, which confirms that the transaction was crafted and then cryptographically verified by P2P.ORG. * `payload` — final transaction object. `null` until there are schema steps yet to be performed. * `verifierMeta` — final transaction data object received from the verifier module. `null` until there are schema steps yet to be performed. * `createdAt` — timestamp of the transaction creation in the ISO 8601 format. * `updatedAt` — timestamp of the transaction update in the ISO 8601 format. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — unique identifier of the request. 2. [Sign](/docs/defi-api-signing-transaction#for-intermediate-transaction) the intermediate `json` or `encoded` transaction object from the step 0 `payload` field. ## 5. Create permission request for P2P.ORG smart contract 1. Construct the second `permit2SingleDetailsForP2pProxy` intermediate transaction according to the schema. To allow a P2P proxy contract to withdraw assets from your wallet address, send a POST request to [/api/defi/v1/transactions/steps/craft](/reference/craft-transaction-step). Mind specifying the correct `stepName` according to the scheme's step order as well as the `operationID` of the previous transaction. Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/steps/craft' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "chain": "base", "action": "deposit", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x991c468AbcE2b4DD627a6210C145373EbABdd186", "options": { "executionMode": "sync" }, "stepName": "permit2SingleDetailsForP2pProxy", "payload": { "amount": "10000", "asset": "USDC", "operationId": "iR4WV/aWs1Ll+SiOObmZdONXggOufzS5kEYdyxmZMWd8gb6Iu9KILvUWCbatR75x" } }' ``` * `chain` — blockchain network. * `action` — operation type. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `options.executeMode` — DeFi API request processing mode. The recommended value for each step can be found in the schema's `canExecuteInParallel` field. * `stepName` — step name corresponding to the `name` response parameter of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. In this case, it is `permit2SingleDetailsForP2pProxy`. * `payload` — transaction data: * `amount` — amount of tokens to deposit. * `asset` — token denomination, e.g., `USDC`. * `operationId` — unique identifier of the `permit2SingleDetailsForMorpho` transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "operationId": "iR4WV/aWs1Ll+SiOObmZdONXggOufzS5kEYdyxmZMWd8gb6Iu9KILvUWCbatR75x", "chain": "base", "action": "deposit", "status": "IN_PROGRESS", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x991c468AbcE2b4DD627a6210C145373EbABdd186", "stepList": [ { "index": 0, "type": "signature_data", "name": "permit2SingleDetailsForMorpho", "description": "Prepare Permit2 SingleDetails for Morpho bundler", "payload": { "json": { "domain": { "name": "Permit2", "chainId": 8453, "verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3" }, "types": { "PermitDetails": [ { "name": "token", "type": "address" }, { "name": "amount", "type": "uint160" }, { "name": "expiration", "type": "uint48" }, { "name": "nonce", "type": "uint48" } ], "PermitSingle": [ { "name": "details", "type": "PermitDetails" }, { "name": "spender", "type": "address" }, { "name": "sigDeadline", "type": "uint256" } ] }, "primaryType": "PermitSingle", "message": { "details": { "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amount": "10000", "expiration": "281474976710655", "nonce": 0 }, "spender": "0x23055618898e202386e6c13955a58D3C68200BFB", "sigDeadline": "1767173669" } }, "encoded": "0x8675b0c734ce70a49ffcef60f6cbffd3c747091ccf99c783c0fdbec686b29c11" }, "verifierMeta": { "signature": "0x1942c3fdf677c44a333f121e9105d3930a9aac60f393094dba29c9aaa1e230cb" }, "outputKeys": [ "json", "encoded" ] }, { "index": 1, "type": "signature_data", "name": "permit2SingleDetailsForP2pProxy", "description": "Prepare Permit2 SingleDetails for P2P Proxy", "payload": { "json": { "domain": { "name": "Permit2", "chainId": 8453, "verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3" }, "types": { "PermitDetails": [ { "name": "token", "type": "address" }, { "name": "amount", "type": "uint160" }, { "name": "expiration", "type": "uint48" }, { "name": "nonce", "type": "uint48" } ], "PermitSingle": [ { "name": "details", "type": "PermitDetails" }, { "name": "spender", "type": "address" }, { "name": "sigDeadline", "type": "uint256" } ] }, "primaryType": "PermitSingle", "message": { "details": { "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amount": "10000", "expiration": "281474976710655", "nonce": 0 }, "spender": "0x9A01117B3AAB083C93cdd67F9ab4359cB21FE94E", "sigDeadline": "1767173669" } }, "encoded": "0xcb57b7905a95cdeea99e1ad7c2a95f079aefe1eb951c4c7b6c14bc72c7aae6c5" }, "verifierMeta": { "signature": "0x1d07766debe8ff9f44d04023ded4e2d1ff750109e3975a6f54ac1697db28d8de" }, "outputKeys": [ "json", "encoded" ] }, null ], "payload": null, "verifierMeta": null, "createdAt": "2025-12-24T09:34:29.324Z", "updatedAt": "2025-12-24T09:49:53.551Z" }, "meta": { "time": 3212, "requestId": "25ae64b3-44d0-4bfe-b583-78717ba5581b" } } ``` * `operationId` — unique identifier of the `permit2SingleDetailsForMorpho` transaction. * `chain` — blockchain network. * `action` — operation type. * `status` — current transaction status: `AWAITING_CRAFT`, `IN_PROGRESS`, `READY_FOR_SIGN` or `DONE`. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `stepList` — list of fields with the step results obtained according to the schema. > For schemes with multiple steps: if a step has not been performed yet, the field will have `null`. In this example, the response contains data for steps 0 and 1. * `index` — step number in the execution order. * `type` — parameter object format. * `name` — step name corresponding to the `name` response field of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. * `description` — detailed information on the step purpose. * `payload` — raw transaction object ready for signing represented in two formats: `encoded` and `json` (optional). * `verifierMeta` — data object received from P2P.ORG's verifier module. * `signature` — signature provided by the verifier module, which confirms that the transaction was crafted and then cryptographically verified by P2P.ORG. * `payload` — final transaction object. `null` until there are schema steps yet to be performed. * `verifierMeta` — final transaction data object received from the verifier module. `null` until there are schema steps yet to be performed. * `createdAt` — timestamp of the transaction creation in the ISO 8601 format. * `updatedAt` — timestamp of the transaction update in the ISO 8601 format. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — request identifier; used as a correlating ID in logs. 2. [Sign](/docs/defi-api-signing-transaction#for-intermediate-transaction) the intermediate `json` or `encoded` transaction object from the step 1 `payload` field. ## 6. Prepare final deposit transaction Construct the third `finalDepositTransaction` transaction according to the schema. To prepare the final deposit transaction, send a POST request to [/api/defi/v1/transactions/steps/craft](/reference/craft-transaction-step). Mind specifying the correct `stepName` according to the scheme's step order and the `operationID` from the step 0. Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/steps/craft' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "chain": "base", "action": "deposit", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x991c468AbcE2b4DD627a6210C145373EbABdd186", "options": { "executionMode": "sync" }, "stepName": "finalDepositTransaction", "payload": { "amount": "10000", "asset": "USDC", "operationId": "iR4WV/aWs1Ll+SiOObmZdONXggOufzS5kEYdyxmZMWd8gb6Iu9KILvUWCbatR75x", "permit2SignatureForMorpho": "0x831ad90a76e7f88fda3d35d454ecc6482c456cd180d1243d60b53286e5a41400239b17261d50bd79f301e177a5243ebee57a24728039b03d7cc76cb3b101068f1c", "permit2SignatureForP2pProxy": "0xf4de5fcf3866909788c28a69cfad101a602c77f81da47ad4c8e32d28a93703452944eb65d6a13a2522ec4de30e42bdfb44e983dd3d7b25fa27d60dbf1a377f181b" } }' ``` * `chain` — blockchain network. * `action` — operation type. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `options.executeMode` — DeFi API request processing mode. The recommended value for each step can be found in the schema's `canExecuteInParallel` field. * `stepName` — step name corresponding to the `name` response parameter of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. In this case, it is `finalDepositTransaction`. * `payload` — transaction data: * `amount` — amount of tokens to deposit. * `asset` — token denomination, e.g., `USDC`. * `operationId` — unique identifier of the `permit2SingleDetailsForMorpho` transaction. * `permit2SignatureForMorpho` — signed transaction obtained at step 0. * `permit2SignatureForP2pProxy` — signed transaction obtained at step 1. Example response: ```json JSON theme={null} { "error": null, "result": { "operationId": "iR4WV/aWs1Ll+SiOObmZdONXggOufzS5kEYdyxmZMWd8gb6Iu9KILvUWCbatR75x", "chain": "base", "action": "deposit", "status": "READY_FOR_SIGN", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x991c468AbcE2b4DD627a6210C145373EbABdd186", "stepList": [ { "index": 0, "type": "signature_data", "name": "permit2SingleDetailsForMorpho", "description": "Prepare Permit2 SingleDetails for Morpho bundler", "payload": { "json": { "domain": { "name": "Permit2", "chainId": 8453, "verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3" }, "types": { "PermitDetails": [ { "name": "token", "type": "address" }, { "name": "amount", "type": "uint160" }, { "name": "expiration", "type": "uint48" }, { "name": "nonce", "type": "uint48" } ], "PermitSingle": [ { "name": "details", "type": "PermitDetails" }, { "name": "spender", "type": "address" }, { "name": "sigDeadline", "type": "uint256" } ] }, "primaryType": "PermitSingle", "message": { "details": { "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amount": "10000", "expiration": "281474976710655", "nonce": 0 }, "spender": "0x23055618898e202386e6c13955a58D3C68200BFB", "sigDeadline": "1767173669" } }, "encoded": "0x8675b0c734ce70a49ffcef60f6cbffd3c747091ccf99c783c0fdbec686b29c11" }, "verifierMeta": { "signature": "0x1942c3fdf677c44a333f121e9105d3930a9aac60f393094dba29c9aaa1e230cb" }, "outputKeys": [ "json", "encoded" ] }, { "index": 1, "type": "signature_data", "name": "permit2SingleDetailsForP2pProxy", "description": "Prepare Permit2 SingleDetails for P2P Proxy", "payload": { "json": { "domain": { "name": "Permit2", "chainId": 8453, "verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3" }, "types": { "PermitDetails": [ { "name": "token", "type": "address" }, { "name": "amount", "type": "uint160" }, { "name": "expiration", "type": "uint48" }, { "name": "nonce", "type": "uint48" } ], "PermitSingle": [ { "name": "details", "type": "PermitDetails" }, { "name": "spender", "type": "address" }, { "name": "sigDeadline", "type": "uint256" } ] }, "primaryType": "PermitSingle", "message": { "details": { "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "amount": "10000", "expiration": "281474976710655", "nonce": 0 }, "spender": "0x9A01117B3AAB083C93cdd67F9ab4359cB21FE94E", "sigDeadline": "1767173669" } }, "encoded": "0xcb57b7905a95cdeea99e1ad7c2a95f079aefe1eb951c4c7b6c14bc72c7aae6c5" }, "verifierMeta": { "signature": "0x1d07766debe8ff9f44d04023ded4e2d1ff750109e3975a6f54ac1697db28d8de" }, "outputKeys": [ "json", "encoded" ] }, { "index": 2, "type": "transaction", "name": "finalDepositTransaction", "description": "Create final deposit transaction", "payload": { "json": { "domain": { "name": "Morpho", "chainId": 8453, "verifyingContract": "0x23055618898e202386e6c13955a58D3C68200BFB" }, "types": { "Deposit": [ { "name": "bundlerAddress", "type": "address" }, { "name": "multicallData", "type": "bytes" }, { "name": "p2pProxyPermitSingle", "type": "bytes" }, { "name": "permit2SignatureForP2pProxy", "type": "bytes" }, { "name": "feeInBasisPoints", "type": "uint256" }, { "name": "feeSignatureDeadline", "type": "uint256" }, { "name": "feeSignature", "type": "bytes" } ] }, "primaryType": "Deposit", "message": { "bundlerAddress": "0x23055618898e202386e6c13955a58D3C68200BFB", "multicallData": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000184af504202000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023055618898e202386e6c13955a58d3c68200bfb000000000000000000000000000000000000000000000000000000006954ee25000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000041831ad90a76e7f88fda3d35d454ecc6482c456cd180d1243d60b53286e5a41400239b17261d50bd79f301e177a5243ebee57a24728039b03d7cc76cb3b101068f1c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004454c53ef0000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000846ef5eeae000000000000000000000000beef010f9cb27031ad51e3333f9af9c6b122818300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000020f8ebb4ebb46f0000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e00000000000000000000000000000000000000000000000000000000", "p2pProxyPermitSingle": "0x000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e000000000000000000000000000000000000000000000000000000006954ee25", "permit2SignatureForP2pProxy": "0xf4de5fcf3866909788c28a69cfad101a602c77f81da47ad4c8e32d28a93703452944eb65d6a13a2522ec4de30e42bdfb44e983dd3d7b25fa27d60dbf1a377f181b", "feeInBasisPoints": "10000", "feeSignatureDeadline": "1767173669", "feeSignature": "0x0f6bbd829715c699631306b3526a7b54de1a20a1ae8f98e80b0800012887c6c1762226b7999f019399f7b68f70cdafb9779bfa23bda3348f66d0da76f6befc7c1b" } }, "encoded": "0xa6c26af400000000000000000000000023055618898e202386e6c13955a58d3c68200bfb0000000000000000000000000000000000000000000000000000000000000180000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e000000000000000000000000000000000000000000000000000000006954ee2500000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000006954ee2500000000000000000000000000000000000000000000000000000000000005e000000000000000000000000000000000000000000000000000000000000003a4ac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000184af504202000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023055618898e202386e6c13955a58d3c68200bfb000000000000000000000000000000000000000000000000000000006954ee25000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000041831ad90a76e7f88fda3d35d454ecc6482c456cd180d1243d60b53286e5a41400239b17261d50bd79f301e177a5243ebee57a24728039b03d7cc76cb3b101068f1c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004454c53ef0000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000846ef5eeae000000000000000000000000beef010f9cb27031ad51e3333f9af9c6b122818300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000020f8ebb4ebb46f0000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041f4de5fcf3866909788c28a69cfad101a602c77f81da47ad4c8e32d28a93703452944eb65d6a13a2522ec4de30e42bdfb44e983dd3d7b25fa27d60dbf1a377f181b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000410f6bbd829715c699631306b3526a7b54de1a20a1ae8f98e80b0800012887c6c1762226b7999f019399f7b68f70cdafb9779bfa23bda3348f66d0da76f6befc7c1b00000000000000000000000000000000000000000000000000000000000000" }, "verifierMeta": { "signature": "0x7ef4832cc53ca9f909eee4a56ced5314de5ec23ff5074ba4b7a95932ab7252d5" }, "inputReferences": [ { "stepIndex": 0, "outputKey": "encoded" }, { "stepIndex": 1, "outputKey": "encoded" }, { "stepIndex": 0, "outputKey": "operationId" } ], "outputKeys": [ "json", "encoded" ] } ], "payload": { "json": { "domain": { "name": "Morpho", "chainId": 8453, "verifyingContract": "0x23055618898e202386e6c13955a58D3C68200BFB" }, "types": { "Deposit": [ { "name": "bundlerAddress", "type": "address" }, { "name": "multicallData", "type": "bytes" }, { "name": "p2pProxyPermitSingle", "type": "bytes" }, { "name": "permit2SignatureForP2pProxy", "type": "bytes" }, { "name": "feeInBasisPoints", "type": "uint256" }, { "name": "feeSignatureDeadline", "type": "uint256" }, { "name": "feeSignature", "type": "bytes" } ] }, "primaryType": "Deposit", "message": { "bundlerAddress": "0x23055618898e202386e6c13955a58D3C68200BFB", "multicallData": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000184af504202000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023055618898e202386e6c13955a58d3c68200bfb000000000000000000000000000000000000000000000000000000006954ee25000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000041831ad90a76e7f88fda3d35d454ecc6482c456cd180d1243d60b53286e5a41400239b17261d50bd79f301e177a5243ebee57a24728039b03d7cc76cb3b101068f1c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004454c53ef0000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000846ef5eeae000000000000000000000000beef010f9cb27031ad51e3333f9af9c6b122818300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000020f8ebb4ebb46f0000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e00000000000000000000000000000000000000000000000000000000", "p2pProxyPermitSingle": "0x000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e000000000000000000000000000000000000000000000000000000006954ee25", "permit2SignatureForP2pProxy": "0xf4de5fcf3866909788c28a69cfad101a602c77f81da47ad4c8e32d28a93703452944eb65d6a13a2522ec4de30e42bdfb44e983dd3d7b25fa27d60dbf1a377f181b", "feeInBasisPoints": "10000", "feeSignatureDeadline": "1767173669", "feeSignature": "0x0f6bbd829715c699631306b3526a7b54de1a20a1ae8f98e80b0800012887c6c1762226b7999f019399f7b68f70cdafb9779bfa23bda3348f66d0da76f6befc7c1b" } }, "encoded": "0xa6c26af400000000000000000000000023055618898e202386e6c13955a58d3c68200bfb0000000000000000000000000000000000000000000000000000000000000180000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e000000000000000000000000000000000000000000000000000000006954ee2500000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000006954ee2500000000000000000000000000000000000000000000000000000000000005e000000000000000000000000000000000000000000000000000000000000003a4ac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000184af504202000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000ffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023055618898e202386e6c13955a58d3c68200bfb000000000000000000000000000000000000000000000000000000006954ee25000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000041831ad90a76e7f88fda3d35d454ecc6482c456cd180d1243d60b53286e5a41400239b17261d50bd79f301e177a5243ebee57a24728039b03d7cc76cb3b101068f1c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004454c53ef0000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000846ef5eeae000000000000000000000000beef010f9cb27031ad51e3333f9af9c6b122818300000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000020f8ebb4ebb46f0000000000000000000000009a01117b3aab083c93cdd67f9ab4359cb21fe94e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041f4de5fcf3866909788c28a69cfad101a602c77f81da47ad4c8e32d28a93703452944eb65d6a13a2522ec4de30e42bdfb44e983dd3d7b25fa27d60dbf1a377f181b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000410f6bbd829715c699631306b3526a7b54de1a20a1ae8f98e80b0800012887c6c1762226b7999f019399f7b68f70cdafb9779bfa23bda3348f66d0da76f6befc7c1b00000000000000000000000000000000000000000000000000000000000000" }, "verifierMeta": { "signature": "0x7ef4832cc53ca9f909eee4a56ced5314de5ec23ff5074ba4b7a95932ab7252d5" }, "createdAt": "2025-12-24T09:34:29.324Z", "updatedAt": "2025-12-24T09:49:53.551Z" }, "meta": { "time": 3212, "requestId": "25ae64b3-44d0-4bfe-b583-78717ba5581b" } } ``` * `operationId` — unique identifier of the `permit2SingleDetailsForMorpho` transaction. * `chain` — blockchain network. * `action` — operation type. * `status` — current transaction status: `AWAITING_CRAFT`, `IN_PROGRESS`, `READY_FOR_SIGN` or `DONE`. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `stepList` — list of fields with the step results obtained according to the schema. * `index` — step number in the execution order. * `type` — parameter object format. * `name` — step name corresponding to the `name` response field of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. * `description` — detailed information on the step purpose. * `payload` — raw transaction object ready for signing represented in two formats: `encoded` and `json` (optional). * `verifierMeta` — data object received from P2P.ORG's verifier module. * `signature` — signature provided by the verifier module, which confirms that the transaction was crafted and then cryptographically verified by P2P.ORG. * `payload` — final deposit transaction payload represented either in `encoded` an optional `json` format. * `verifierMeta` — final transaction data object received from the verifier module. * `createdAt` — timestamp of the transaction creation in the ISO 8601 format. * `updatedAt` — timestamp of the transaction update in the ISO 8601 format. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — request identifier; used as a correlating ID in logs. ## 7. Sign and broadcast final deposit transaction The final deposit transaction now contains all the `payload` objects from the previous intermediate transactions. 1. [Sign](/docs/defi-api-signing-transaction#for-final-transactions) the `json` or `encoded` transaction object from the `result.payload` field. 2. [Broadcast](/docs/defi-api-signing-transaction#3-broadcast-signed-final-transaction) it to the network by sending a POST request to [/api/defi/v1/transactions/steps/broadcast](/reference/broadcast-transaction). By broadcasting this transaction, you're making the deposit to the Steakhouse USDC vault on the Base blockchain. # Withdrawal Source: https://docs.p2p.org/docs/morpho-withdrawal Withdraw from a Morpho vault using the P2P.org DeFi API. To initiate a withdrawal from a Morpho's vault using the DeFi API, follow these steps: 1. Retrieve the schema with the step list to check which transactions are required. 2. Prepare the withdrawal transaction. 3. Sign and broadcast the withdrawal transaction to the network. Both partial and full withdrawal are possible. Request examples are provided using [cURL](https://curl.se/). ## 1. Get schema To retrieve a list of steps required to perform a withdrawal, send a GET request to [/api/defi/v1/transactions/schema](/reference/get-transaction-schema). Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/schema?action=withdraw&chain=base&protocol=morpho&strategy=Steakhouse%20USDC' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` * `action` — operation type; in this case `withdraw`. * `chain` — blockchain network, e.g., `base`. * `protocol`— integration name, e.g., `morpho`. * `strategy` — vault name, e.g., `Steakhouse USDC`. * `x-client-hash` — unique identifier of the user or merchant participating in the integration; obtained with the [authentication token](/docs/authentication). Example response: ```json JSON theme={null} { "error": null, "result": { "action": "withdraw", "steps": [ { "index": 0, "name": "finalWithdrawTransaction", "description": "Create final withdraw transaction", "inputs": [ { "key": "amount", "type": "string", "description": "Withdraw amount in token smallest unit", "required": true }, { "key": "asset", "type": "string", "description": "Asset symbol (e.g., USDC, USDT)", "required": true }, { "key": "proxyAddress", "type": "string", "description": "P2P Proxy address", "required": true } ], "outputs": [ { "key": "json", "type": "object", "description": "Built withdraw transaction data (to, data, value, chainId)" }, { "key": "encoded", "type": "string", "description": "Built withdraw transaction as encoded function data" } ], "groupId": 0, "canExecuteInParallel": false, "isUnsignedTransaction": true } ], "stepGroups": [ [ 0 ] ] }, "meta": { "time": 18, "requestId": "5406b88f-b94d-4027-97cd-29af077cbef1" } } ``` * `action` — operation type. * `steps` — schema with the list of steps describing which transactions you have to construct using the [Craft Transaction Step](/reference/craft-transaction-step) endpoint. * `index` — step number in the execution order. * `name` — transaction type corresponding to the `stepName` request parameter of the [Craft Transaction Step](/reference/craft-transaction-step) endpoint. * `description` — detailed information on the step purpose. * `inputs` — list of request parameters required to construct a transaction, e.g., wallet address, amount of tokens, etc. It can include the transactions that require a signature as well. * `key` — parameter name. * `type` — parameter object format. * `description` — detailed information on the parameter. * `required` — boolean flag indicating if this parameter is necessary for the request. * `outputs` — list of fields expected in the transaction response. * `key` — raw transaction payload ready for signing which is `encoded` or an optional`json`. * `type` — transaction payload format. * `description` — detailed information on the payload contents. * `groupID` — identifier of the group to which this step belongs. * `canExecuteInParallel` — boolean flag indicating if it is possible to perform this step asynchronously. By executing in parallel, you can initiate the construction of multiple transactions at the same time. * `true` — step can be performed asynchronously. * `false` — step can only be performed synchronously. * `isUnsignedTransaction` — boolean flag indicating if the result of the step is a transaction that must be signed and broadcasted. * `stepGroups` — groups of steps that can be executed in parallel; currently is not operational. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — unique identifier of the request. > [!TIP] > > **Summary** > > In this schema example, the `steps` response array includes one step called `finalWithdrawTransaction`. > > It means that to withdraw funds from the vault, you have to prepare only one transaction and then sign and broadcast it. ## 2. Prepare withdrawal transaction To withdraw funds from the vault, send a POST request to [/api/defi/v1/transactions/steps/craft](/reference/craft-transaction-step). Example request (for `base` chain and `Steakhouse USDC` strategy): ```bash bash theme={null} curl --request GET \ --url GET 'https://edge.p2p.org/api/defi/v1/transactions/steps/craft' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "chain": "base", "action": "withdraw", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x0000000000000000000000000000000000000001", "options": { "executionMode": "sync" }, "stepName": "finalWithdrawTransaction", "payload": { "amount": "100000", "asset": "USDC", "proxyAddress": "0x0000000000000000000000000000000000000001" } }' ``` * `chain` — blockchain network. * `action` — operation type. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `options.executeMode` — DeFi API request processing mode. The recommended value can be found in the schema's `canExecuteInParallel` field. * `sync` — synchronous; default for some networks so that the blockchain does not reverse the block in which the transaction is included. In this mode, before continuing with other steps, you have to wait until the API operation is fully completed and the transaction is returned. * `async` — asynchronous. In this mode, after sending the request, you can continue with other steps according to the schema and periodically check the request status with the [Get Step Crafting Status](/reference/get-step-status) endpoint. * `stepName` — step name corresponding to the `name` response field of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. In this case, it is `finalWithdrawTransaction`. * `payload` — transaction data: * `amount` — amount of tokens to withdraw. * `asset` — token denomination, e.g., `USDC`. * `proxyAddress` — P2P.ORG proxy address used to perform the deposit. To retrieve this address, send a GET response to the [Get User Positions](/reference/get-user-positions) endpoint. Example response: ```json JSON theme={null} { "error": null, "result": { "operationId": "mock-operation-id-abc123", "chain": "base", "action": "withdraw", "status": "READY_FOR_SIGN", "protocol": "morpho", "strategy": "Steakhouse USDC", "userAddress": "0x0000000000000000000000000000000000000001", "stepList": [ { "index": 0, "type": "transaction", "name": "finalWithdrawTransaction", "description": "Create final withdraw transaction", "payload": { "json": { "chainId": 8453, "to": "0x0000000000000000000000000000000000000002", "nonce": 0, "value": "0", "data": "0xdeadbeef", "maxFeePerGas": "1000000000", "maxPriorityFeePerGas": "100000000", "gas": "300000", "type": "eip1559" }, "encoded": "0x02f8..." }, "verifierMeta": { "signature": "0x0000000000000000000000000000000000000000000000000000000000000000" } } ], "payload": { "json": { "chainId": 8453, "to": "0x0000000000000000000000000000000000000002", "nonce": 0, "value": "0", "data": "0xdeadbeef", "maxFeePerGas": "1000000000", "maxPriorityFeePerGas": "100000000", "gas": "300000", "type": "eip1559" }, "encoded": "0x02f8..." }, "verifierMeta": { "signature": "0x0000000000000000000000000000000000000000000000000000000000000000" }, "createdAt": "2026-02-13T12:00:00.000Z", "updatedAt": "2026-02-13T12:00:00.000Z" }, "meta": { "time": 100, "requestId": "mock-request-id-xyz789" } } ``` * `operationId` — unique identifier of the transaction. * `chain` — blockchain network. * `action` — operation type. * `status` — current transaction status: `AWAITING_CRAFT`, `IN_PROGRESS`, `READY_FOR_SIGN` or `DONE`. * `protocol`— integration name. * `strategy` — vault name. * `userAddress` — user wallet address. * `stepList` — list of fields with the step results obtained according to the schema: * `index` — step number in the execution order. * `type` — field object format. * `name` — step name corresponding to the `name` response field of the [Get Transaction Step Schema](/reference/get-transaction-schema) endpoint. * `description` — detailed information on the step purpose. * `payload` — raw transaction object ready for signing represented in two formats: `encoded` and `json` (optional). * `verifierMeta` — data object received from P2P.ORG's verifier module. * `signature` — signature provided by the verifier module, which confirms that the transaction was crafted and then cryptographically verified by P2P.ORG. * `payload` — final transaction payload represented either in `encoded` or `json` (optional) format. * `verifierMeta` — final transaction data object received from the verifier module. * `createdAt` — timestamp of the transaction creation in the ISO 8601 format. * `updatedAt` — timestamp of the transaction update in the ISO 8601 format. * `meta` — API request attributes: * `time` — request execution time in ms. * `requestId` — unique identifier of the request. ## 3. Sign and broadcast transaction 1. [Sign](/docs/defi-api-signing-transaction#for-final-transactions) the final `json` or `encoded` transaction object from the `result.payload` field. 2. [Broadcast](/docs/defi-api-signing-transaction#3-broadcast-signed-final-transaction) it to the network by sending a POST request to [/api/defi/v1/transactions/steps/broadcast](/reference/broadcast-transaction). # Near Transaction Signing Source: https://docs.p2p.org/docs/near-signing-transaction Sign and broadcast Near transactions built with the P2P.org Unified API. To sign and broadcast the transaction to the Near network, follow these steps: 1. Prepare unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) in Base64 encrypted format. 2. Sign the transaction using the following code: ```javascript theme={null} import { KeyPair, Signer } from "near-api-js"; import { signTransaction, Transaction } from "near-api-js/lib/transaction"; import * as sha256 from "js-sha256"; import { KeyPairString, PublicKey } from "near-api-js/lib/utils"; // Private key (ensure this is securely stored) const PRIVATE_KEY = "ed25519:YOUR_PRIVATE_KEY_HERE"; // Unsigned transaction in hexadecimal format const RAW_TX_HEX = "YOUR_UNSIGNED_TRANSACTION_HEX"; // Create a signer instance using the private key function createSigner(privateKey: string): Signer { const keyPair = KeyPair.fromString(privateKey as KeyPairString); return { async getPublicKey() { return keyPair.getPublicKey(); }, async signMessage(message: Uint8Array) { const hash = new Uint8Array(sha256.sha256.array(message)); const signature = keyPair.sign(hash); return { signature: signature.signature, publicKey: keyPair.getPublicKey(), }; }, createKey(accountId: string, networkId?: string): Promise {}, }; } // Function to sign the transaction async function signTransactionWithSigner( tx: Transaction, signer: Signer ): Promise { const [, signedTx] = await signTransaction(tx, signer); const signedTxSerialized = signedTx.encode(); return Buffer.from(signedTxSerialized).toString("hex"); } // Process the transaction signing async function processTransaction() { if (!RAW_TX_HEX) { throw new Error("❌ Error: RAW_TX_HEX is empty. Insert your transaction!"); } // Create signer with private key const signer = createSigner(PRIVATE_KEY); // Decode transaction from hex format const tx = Transaction.decode(Buffer.from(RAW_TX_HEX, "hex")); // Sign the transaction const signedTxHex = await signTransactionWithSigner(tx, signer); console.log("✅ Signed Transaction (Hex):", signedTxHex); } // Execute signing process processTransaction().catch(console.error); ``` Upon successful execution, the script prints the signed transaction in the hexadecimal format, ready to be broadcasted: ```bash theme={null} ✅ Signed Transaction (Hex): 0x... ``` 3. Broadcast the transaction to the Near network by sending a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). # Network Source: https://docs.p2p.org/docs/network Staking Data API provides methods for retrieving various data related to the network. This section describes the available network methods along with descriptions and recommendations for their usage. ## Methods ### Get Supply Data **Endpoint:** [GET /api/v1/\{network}/data/network/supply-data](/reference/data-network-supply-data) **Supported networks:** Ethereum. **Description:** Retrieve network supply data, offering insights into the overall supply dynamics of the network. Utilize this endpoint to collect information on the network's supply and analyze the data to improve your comprehension of the network's economic state. ### Get Last Staking Period **Endpoint:** [GET /api/v1/\{network}/data/network/last-staking-period](/reference/data-network-last-staking-period) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, Celestia. **Description:** Retrieve information about the last staking period (epoch, era etc.) on the network. Utilize this endpoint to retrieve historical data on the network's staking periods and analyze the information to discern trends or alterations in staking behavior. ### Get Network APY **Endpoint:** [GET /api/v1/\{network}/data/network/apy](/reference/data-network-apy) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, Celestia. **Description:** Retrieve the Annual Percentage Yield (APY) for the network based on the specified staking period (epoch, era etc.). Utilize this endpoint to compute and track the APY for various staking periods, and grasp the fluctuations in network APY over time to facilitate well-informed staking decisions. ### Get Network APR **Endpoint:** [GET /api/v1/\{network}/data/network/apr](/reference/data-network-apr) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, Celestia. **Description:** Retrieve the Annual Percentage Rate (APR) for the network based on the specified staking period (epoch, era, etc.). Utilize this endpoint to compute and track the APR for various staking periods, and grasp the fluctuations in network APR over time to facilitate well-informed staking decisions. ### Get Validators Count **Endpoint:** [GET /api/v1/\{network}/data/network/validators-count](/reference/data-network-validator-count) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, Celestia. **Description:** Retrieve the count of validators on the network for the specified staking period (epoch, era etc.). Utilize this endpoint to oversee the count of participating validators in the network and assess validator count data for evaluations of network health. ### Get Delegators Count **Endpoint:** [GET /api/v1/\{network}/data/network/delegators-count](/reference/data-network-delegators-count) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, Celestia. **Description:** Retrieve the count of delegators on the network for the specified staking period (epoch, era etc.). Utilize this endpoint to evaluate the involvement of delegators in staking and analyze the data on delegators count to comprehend trends in user participation. ### Get Network Stake **Endpoint:** [GET /api/v1/\{network}/data/network/stake](/reference/data-network-stake) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, Celestia. **Description:** Retrieve information about the network's total stake for the specified staking period (epoch, era etc.). Utilize this endpoint to obtain data on the overall staking amount in the network. ### Get Network Rewards **Endpoint:** [GET /api/v1/\{network}/data/network/rewards](/reference/data-network-rewards) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, Celestia. **Description:** Retrieve information about the network's rewards for the specified staking period (epoch, era etc.). Use this endpoint to retrieve data on rewards distributed across various staking periods, and analyze the reward data to comprehend the economic incentives within the network. ### Get Exit Queue **Endpoint:** [GET /api/v1/\{network}/data/network/exit-queue](/reference/data-network-exit-queue) **Supported networks:** Ethereum. **Description:** This method allows you to retrieve information in days about the network exit queue. The exit queue contains validators who have requested to exit the network, and they must wait for a certain period before safely exit. Utilize this endpoint to track validators within the exit queue and comprehend the waiting duration necessary for validators to safely exit. ### Get Staking Queue **Endpoint:** [GET /api/v1/\{network}/data/network/staking-queue](/reference/data-network-staking-queue) **Supported networks:** Ethereum. **Description:** Retrieve information about the network staking queue in days, which provides insights into the current staking activities on the network. Use this endpoint to evaluate staking activities and analyze the staking queue data to gain insights into the current state of network staking. ### Get Block Rewards **Endpoint:** [GET /api/v1/\{network}/data/network/block/rewards](/reference/data-network-block-rewards) **Supported networks:** Solana. **Description:** Retrieve Solana block rewards (block production fees, voting rewards, and staking rewards) by block date. Optional query parameters: * `address` — return only rewards paid to this recipient address. * `rewardType` — return only rewards of one type: `Fee`, `Voting`, `Staking`, or `DeactivatedStake`. If omitted, rewards of every type are returned. Each record contains `stakingPeriodNumber`, `blockDate`, `blockDateTime`, `recipient`, `rewardType`, `amount`, and `processingDateTime` (when the record was loaded into the data warehouse). # Chains Supported Source: https://docs.p2p.org/docs/networks-supported Check the list of chains supported P2P.org provides comprehensive staking and data services across multiple blockchain networks. This page provides an overview of network support across our different API products. ## Unified API & Staking API Support | Chains | Unified API | Staking API | | - | - | - | | Aptos | ✅ | ✅ | | Cardano | ✅ | ❌ | | Celestia | ✅ | ✅ | | Cosmos (ATOM) | ✅ | ✅ | | Ethereum | ✅ | ✅ | | Hyperliquid | ✅ | ✅ | | Kusama | ✅ | ✅ | | Monad | ✅ | ✅ | | Near | ✅ | ❌ | | Polkadot | ✅ | ✅ | | Polygon (mainnet only) | ✅ | ✅ | | Sei | ✅ | ✅ | | Solana | ✅ | ✅ | | Sui | ✅ | ✅ | | Story Protocol | ✅ | ❌ | | Tezos | ✅ | ❌ | | TON | ✅ | ✅ | | TRON | ✅ | ✅ | ## Data API Support Our Data API provides comprehensive analytics across multiple networks with varying data scope and latency. For complete Data API coverage, visit our [Data API Chains Support](/docs/networks-supported-data-api) page. ## Additional API Products ### Restaking API Maximize yield through restaking capabilities. Currently supports EigenLayer on Ethereum. For more details, visit our [Restaking Overview](/docs/restaking-overview). ### DVT Staking API Distributed Validator Technology (DVT) for yield opportunities with enhanced security and reliability. Currently supports Ethereum through the SSV protocol. Learn more in our [DVT Solutions Overview](/docs/overview-dvt-solutions). ### Pooled Staking API Offer Ethereum staking to your users without the traditional 32 ETH minimum. For more details, visit our [Pooled Staking Overview](/docs/pooled-staking-overview). Need help? Our [team](/docs/contacts) is available to assist with your integration. # Chains Supported Source: https://docs.p2p.org/docs/networks-supported-data-api Check the list of chains supported | Chains | Network | Data scope | Time Aggregations | Historical Depth | Latency | | - | - | - | - | - | - | | Ethereum | Mainnet | Network, Validator, Delegator | Epoch, Daily | No Limit | 2-4 hours | | Cardano | Mainnet | Validator, Delegator (only P2P) | Daily | 3 months | 1 day | | Celestia | Mainnet | Network, Validator, Delegator | Daily | 3 months | 6 hours | | Kusama | Mainnet | Network, Validator, Delegator | Era, Daily | 3 months | 2 hours | | Polkadot | Mainnet | Network, Validator, Delegator (only P2P) | Era, Daily | 3 months | 2 hours | | Solana | Mainnet | Network, Validator, Delegator | Epoch | Up to epoch #132 | 24 hours | | TON | Mainnet | Delegator (only P2P) | Epoch, Daily | 3 months | 2 hours | | Sui | Mainnet | Network, Validator, Delegator | Epoch, Daily | 3 months | 2 hours | Not every endpoint is available on every chain. Each method page lists the supported networks per endpoint: [Network](/docs/network), [Validator](/docs/validator), [Delegator](/docs/data-delegator). # Chains Supported Source: https://docs.p2p.org/docs/networks-supported-staking-api Check the list of chains supported The table below summarizes all networks supported in the Staking API and the `network` parameter that may be required for the staking endpoints: | Protocol | `network` - mainnet | `network` - testnet | | - | - | - | | [Aptos](/docs/overview-aptos) | `mainnet` | `testnet` | | [Celestia](/docs/overview-celestia) | `celestia-mainnet-beta` | `celestia-mocha-testnet` | | [Cosmos (ATOM)](/docs/overview-cosmos) | `cosmoshub-4` | - | | [Ethereum](/docs/overview-eth) | use `api.p2p.org` base URL | use `api-test.p2p.org` base URL (Hoodi) | | [Hyperliquid](/docs/overview-hyperliquid) | `mainnet` | `testnet` | | [Kusama](/docs/overview-polkadot) | - | `kusama` | | [Monad](/docs/overview-monad) | `mainnet` | `testnet` | | [Polkadot](/docs/overview-polkadot) | `mainnet` | `westend` (Westend) | | [Polygon](/docs/overview-polygon) | use `api.p2p.org` base URL | use `api-test.p2p.org` base URL (Hoodi) | | [Sei](/docs/overview-sei) | `pacific-1` | `atlantic-2` | | [Solana](/docs/overview-solana) | `mainnet-beta` | `testnet` (Testnet) | | [Sui](/docs/overview-sui) | `mainnet` | `testnet` | | [Story Protocol](/docs/overview-story) | `mainnet` | `aeneid` | | [TON](/docs/overview-ton) | `mainnet` (TON Whales) | `testnet` (TON Whales) | | [TRON](/docs/overview-tron) | `mainnet` | `testnet-nile` | ## Testing and production environments We provide two distinct endpoints for testing and production environments: * Production: \<[https://api.p2p.org](https://api.p2p.org)> * Testing: \<[https://api-test.p2p.org](https://api-test.p2p.org)> # Overview Source: https://docs.p2p.org/docs/overview Our Staking Data API service is specifically designed to provide comprehensive data information regarding your staking activities, allowing you to stay up-to-date with the status of your assets. ## Features * **Coverage:** Currently, we support five networks in the Staking Data API — Ethereum, Kusama, Polkadot, Solana, Sui. Additionally, we operate in more than 20 networks, continually adding data for all networks we support. Moreover, we have universal EVM and Cosmos SDK indexers and can promptly integrate any new networks. * **Cross-Network Integration:** Our architecture is built with flexibility in mind. Our API allows you to streamline all your networks through a unified single data integration, saving considerable resource time. * **Data Latency:** Our data latency ranges from 30 minutes to 1 day depending on the network. We continuously boost our data latency and focus on achieving near real-time data by using streaming infrastructure. * **Speed and Volume:** We can provide a millisecond response for any data in the Staking Data API with a 200 RPS load. * **Quality:** As we internally use all the data for accounting and analytical purposes, we conduct thousands of data quality tests. Additionally, we have a disaster recovery architecture for the Staking Data API and most of the data pipelines. * **Customization:** We can promptly implement new API methods and customize existing ones to meet your specific requests. # Overview for AI Tools ✨ Source: https://docs.p2p.org/docs/overview-ai Using AI tools to consume P2P.ORG's API documentation P2P.ORG provides multiple ways to consume our documentation with AI tools to help you build applications faster. [Overview for AI Tools](https://www.youtube.com/embed/r_eQEBk1hGk) ## AI Tools Built into the Docs ### Search with AI Use the search bar in our documentation and press `Enter` to ask AI about anything in our docs. ### Ask AI Button On any documentation page, click `Ask AI` to send that page's content directly to popular AI chats like ChatGPT. ## External AI Tool Integration ### Model Context Protocol (MCP) Connect AI development tools directly to our live API and documentation through MCP. Provides real-time data and interactive API capabilities. * **P2P.ORG MCP setup**: Continue to [Using MCP to Read API Docs](/docs/mcp) * Currently, the MCP server only supports reading/searching the API documentation, not executing any APIs. * **Context7 MCP setup**: Alternatively, you can reference our API documentation directly using the Context7 MCP: * See setup instructions here: [https://github.com/upstash/context7](https://github.com/upstash/context7) * Reference our documentation: [Context7 - P2P.ORG API Documentation Hub](https://context7.com/context7/p2p). ### Aggregated Documentation File Reference or download our complete documentation as a single markdown file and attach it to any AI tool. Works universally with ChatGPT, Claude, and any AI assistant that accepts file attachments. * **Aggregated docs**: Continue to [Aggregated Docs for AI Tools](/docs/llms) Choose the method that best fits your workflow and preferred AI tools. > [!WARNING] > > AI tools can make mistakes, so double-check the answer, and in case of doubt contact us: [Contacts](/docs/contacts). # Overview Source: https://docs.p2p.org/docs/overview-aptos How staking on Aptos works with the P2P.org Staking API. Staking in the Aptos network using the Staking API consists of several main steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | 11 APT | | **Unbonding Period** | \~30 hours | | **Networks** | mainnet, testnet | 1. Create a staking request. 2. Sign and send the transaction to the network. For Aptos, there are two networks available: * `mainnet` — production network * `testnet` — Aptos devnet # Overview Source: https://docs.p2p.org/docs/overview-celestia How staking on Celestia works with the P2P.org Staking API. Staking in Celestia using the Staking API consists of several main steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | No minimum | | **Unbonding Period** | 21 days | | **Networks** | celestia, mocha-4 | 1. Create a staking request. 2. Sign and send the transaction to the network. For Celestia, there are several networks available: * `mainnet-beta` — production network * `mocha-testnet` — testnet # Overview Source: https://docs.p2p.org/docs/overview-cosmos How staking on Cosmos works with the P2P.org Staking API. Staking in the Cosmos Hub network using the Staking API consists of several main steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | No minimum | | **Unbonding Period** | 21 days | | **Networks** | cosmoshub-4 | 1. Create a staking request. 2. Sign and send the transaction to the network. For Cosmos Hub, one network is available: * `cosmoshub-4` — production network # Overview Source: https://docs.p2p.org/docs/overview-dvt-solutions When it comes to staking on the SSV network, P2P.org offers two main options to choose from, each catering to different needs and preferences. Below, we'll explore these two solutions, highlighting their key benefits and drawbacks to help you decide which approach best suits your requirements. ## SSV 1.0 Our SSV 1.0 offers a direct integration for SSV staking, allowing you to manage your staking operations without relying on any third-party solutions. This method is ideal for those who prefer to stay as close to the native SSV staking design as possible. ### Pros: * Native Staking: This method aligns perfectly with the SSV network’s original staking architecture, providing a pure, unaltered staking experience. * Reduced Risk: By avoiding third-party smart contracts, you minimize dependency risks and maintain complete control over your staking process. ### Cons: * Token Management: To maintain your validator on the network, you’ll need to manage and transfer SSV tokens, which might require additional effort. ## SSV 3.1 For those who prefer a more streamlined experience, the SSV 3.1 (Proxy Smart Contract) built by P2P.org simplifies the staking process by handling much of the complexity for you. This solution is designed to alleviate common challenges, particularly around managing SSV tokens. ### Pros: * Simplicity: Your staking process is simplified to a single step—just transfer ETH to the contract, and we take care of the rest. This is particularly advantageous for users looking for a hassle-free experience. ### Cons: * Not Native: This approach deviates from the native SSV staking flow as it relies on our smart contract to facilitate the process. In conclusion, whether you choose the direct approach via the DVT API or the simplified process via the Proxy Smart Contract, both solutions provide unique advantages tailored to different needs. Your choice depends on whether you prioritize maintaining full control and alignment with the native SSV staking flow, or if you prefer a more hands-off approach with simplified management. # Overview Source: https://docs.p2p.org/docs/overview-eth How staking on Ethereum works with the P2P.org Staking API. Staking API enables staking in the Ethereum network. The staking process consists of several steps: 1. Create staking request: set up nodes for staking using P2P infrastructure. 2. Check request status: check the status of the node set-up operation. 3. Prepare staking transaction: construct a serialized transaction to deposit the stake amount with a smart contract. The stake amount can be deposited either by utilizing the functionalities of P2P smart contract or by interacting with Ethereum deposit smart contract directly. To start using Staking API in any of the flows, [get an authentication token](/docs/authentication). We provide distinct endpoints for testing and production environments. The test environment is linked to the Hoodi network (Ethereum). * PRODUCTION: [https://api.p2p.org](https://api.p2p.org) * TESTING ON HOODI: [https://api-test.p2p.org](https://api-test.p2p.org) # Overview Source: https://docs.p2p.org/docs/overview-hyperliquid Stake HYPE with P2P.org’s co-branded node, partnered with the Hyperbeat team, to earn rewards and strengthen the Hyperliquid network, a leading Layer-1 blockchain for DeFi. ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | 100 HYPE | | **Unbonding Period** | 1 day | | **Networks** | mainnet | Staking in the Hyperliquid network using the Staking API consists of several main steps: 1. **\[Optional]** Transfer tokens from the spot balance to the staking balance. 2. Create a delegate request. 3. Sign and send the transaction to the network. For Hyperliquid, there are two networks available: * `mainnet` — production network * `testnet` — Hyperliquid testnet # Overview Source: https://docs.p2p.org/docs/overview-monad How staking on Monad works with the P2P.org Staking API. Staking in the Monad network using the Staking API consists of several main steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | No minimum | | **Unbonding Period** | 7 days | | **Networks** | testnet | 1. Create a delegate request. 2. Sign and send the transaction to the network. For Monad, there are two networks available: * `mainnet` — Monad mainnet * `testnet` — Monad testnet # Overview Source: https://docs.p2p.org/docs/overview-polkadot How staking on Polkadot works with the P2P.org Staking API. Staking on the Polkadot network, also referred to bonding (On Polkadot and Avail, a process by which tokens can be "frozen" in exchange for rewards. For example, staking is a form of bonding for which you receive rewards in exchange for securing the network.), using the Staking API is possible in two ways: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | 10 DOT | | **Unbonding Period** | 28 days | | **Networks** | polkadot, westend | * By staking directly * By staking via a nomination pool (On Polkadot and Avail, nomination pools allow users to contribute tokens and earn staking rewards. Unlike nominating directly, where your bonded funds remain in your account but become locked, the tokens you bond to a pool is transferred to the pool's stash account. Staking using pools requires a small amount of tokens, and the pool manages nominees on your behalf.) > [tab] Direct staking > > The [direct staking](/docs/staking-polkadot#staking-directly) process consists of several steps: > > 1. Create a bonding (On Polkadot and Avail, a process by which tokens can be “frozen” in exchange for rewards. For example, staking is a form of bonding for which you receive rewards in exchange for securing the network.) request: submit a bond to the Polkadot network. > > 2. Create a nomination (On Polkadot and Avail, nominating is the process of selecting validators that the user wants to stake their tokens. You can choose to nominate up to 16 validators for each of your accounts. Once the selected validators have been submitted, bonded funds are automatically distributed to nominees who are active in the current era. As long as at least one of the selected validators is actively validating in a session, bonded funds will be backing that validator. For nomination pools, a user does not nominate directly, as the pool managers are in charge of nominating validators on behalf of all the pool members.) request: select validator (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.)s within the Polkadot network. > > 3. Add a staking proxy (On Polkadot and Avail, this is an account that acts on behalf of the stash account, signalling decisions about nominating and validating. It can set preferences like commission (for validators) and the staking rewards payout account. The earned rewards can be locked immediately for bonding on your stash account, which would effectively compound the rewards you receive over time. You could also choose to have them deposited to a different account as a free (transferable) balance. If you are a validator, it can also be used to set your session keys. Staking proxies only need sufficient funds to pay for the transaction fees.): delegate your staking rights to another account, which can then sign transactions on your behalf (optional). > [tab] Nomination pool > > To [stake via a nomination pool](/docs/staking-polkadot#staking-via-a-nomination-pool): > > 1. Create a claim permission request to allow your nomination pool to bond and nominate on your behalf. > > 2. Create a bonding request to the Polkadot network. > > 3. Create a claim payout request. For Polkadot, there are several networks available: * `mainnet` — Polkadot mainnet * `kusama` — Kusama mainnet * `westend` — testnet environment # Overview Source: https://docs.p2p.org/docs/overview-polygon How staking on Polygon works with the P2P.org Staking API. Staking MATIC is done via a smart contract on the Ethereum network. By using the Staking API, the staking flow consists of the following steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | 1 MATIC | | **Unbonding Period** | 80 checkpoints (\~2-3 days) | | **Networks** | mainnet | 1. Approve token management with the Polygon smart contract. 2. Create a staking request. 3. Sign and send the transaction to the network. # Overview Source: https://docs.p2p.org/docs/overview-sei How staking on Sei works with the P2P.org Staking API. Staking on Sei using the Staking API can be done in several steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | No minimum | | **Unbonding Period** | 21 days | | **Networks** | pacific-1, atlantic-2 | 1. Create a staking request. 2. Sign and send the transaction to the network. For Sei blockchain, there are several networks available: * `pacific-1` — production network * `atlantic-2` — testnet for development and testing purposes # Overview Source: https://docs.p2p.org/docs/overview-solana How staking on Solana works with the P2P.org Staking API. Staking in the Solana network using the Staking API consists of several main steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | \~1 SOL (1002282880 lamports) | | **Unbonding Period** | \~2-3 days (1 epoch) | | **Networks** | mainnet-beta, testnet | 1. Create a staking request. 2. Sign and send the transaction to the network. For Solana, there are several networks available: * `mainnet-beta` — production environment * `testnet` — Solana testing environment called Testnet. Note that we don't support Devnet environment yet. # Overview Source: https://docs.p2p.org/docs/overview-story How staking on Story Protocol works with the P2P.org Staking API. Staking in the Story Protocol network using the Staking API consists of several main steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | 1 IP | | **Unbonding Period** | 14 days | | **Networks** | mainnet, testnet | 1. Create a staking request. 2. Sign and send the transaction to the network. For Story, there are several networks available: * `mainnet` — production environment * `aeneid` — Story testnet # Overview Source: https://docs.p2p.org/docs/overview-sui How staking on Sui works with the P2P.org Staking API. Staking on Sui using the Staking API can be done in several steps: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | 1 SUI | | **Unbonding Period** | \~1 day (1 epoch) | | **Networks** | mainnet, testnet | 1. Create a staking request. 2. Sign and send the transaction to the Sui network. All amounts are specified in MIST (1 SUI = 10⁹ MIST). For Sui blockchain, there are several networks available: * `mainnet` — production network * `testnet` — testnet for development and testing purposes # Overview Source: https://docs.p2p.org/docs/overview-ton How staking on TON works with the P2P.org Staking API. Staking within the TON network using the Staking API is possible in several ways: ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | 10,001 TON (single nominator) | | **Unbonding Period** | \~18 hours | | **Networks** | mainnet, testnet | * Via a Single Nominator Pool: for high-stake validators that nominate themselves * Via Ton Whales Pools: along with multiple nominators For both flows, the staking process consists of the same steps: 1. Create a staking transaction. 2. Sign and send the transaction to the network. For TON, there are the following networks available: * `mainnet` — mainnet * `testnet` — Testnet environment # Overview Source: https://docs.p2p.org/docs/overview-tron Staking on the TRON network using the Staking API is conducted via native blockchain operations — no smart contracts involved. Users participate by freezing TRX and voting for a Super Representative (SR), with all staking logic handled at the protocol level. ## Chain Details | Parameter | Value | | - | - | | **Minimum Stake** | No minimum | | **Unbonding Period** | 14 days | | **Networks** | mainnet, nile (testnet) | To start staking TRX using the Staking API: 1. Create the freezing request to gain voting power. 2. Create the voting request to assign it to SRs via vote transactions. The unstaking requires undelegation followed by unfreezing. For TRON, the following networks are available: * `mainnet` — mainnet * `testnet-nile` — Nile testnet > [!WARNING] > > **Note that TRON uses native staking** > > Voting is supported only on **mainnet**. On **testnet** (Nile), mocked responses are used. # Partial Withdrawals Source: https://docs.p2p.org/docs/partial-withdrawals For validators using the type of credentials, partial withdrawals are now available. If the validator's effective balance is above 32 ETH, it is possible to withdraw excessive funds without exiting the validator. To withdraw from a `0x02`-enabled validator, follow the steps below: 1. Create a withdrawal request. 2. Sign and broadcast the transaction. Request examples are provided using [cURL](https://curl.se/). > [!TIP] > > The flow is supported for both Ethereum and SSV validators via the same endpoint. ## 1. Create withdrawal request > The flow applies only to active validators using the `0x02` type of withdrawal credentials. Send a POST request to [/api/v1/eth/staking/direct/tx/withdrawal/partial](/reference/eth-staking-withdrawal-partial). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/direct/tx/withdrawal/partial \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "pubkeys": [ "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39" ], "amount": "10" }' ``` * `pubkeys` — list of validators' public keys. * `amount` — amount of tokens in ETH to withdraw from each validator. Note that remaining balance must be equal or more than 32 ETH. If specified as 0, the validator will be fully withdrawn and exit the network. Example response: ```json JSON theme={null} { "error": null, "result": { "serializeTx": "0x02f902d705808301674e8508530af16e830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aa5f27070a21d79455c4a9b73c0aa4a8b1a65a1fb530d7fd8e6cd23aa16660679ac43ee4861098f6d9166aed3a4d8abb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002001000000000000000000000028c84612d37de9209018ad96167f12169b653e9a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060978c565cd915f4e885b4201093d1501697610eb9ee99b9b60b70434dc330e98d5b42927725304ded48483a8b8f39506d09bcb22ee18d4f6b50257946ac5ee360385308d95c0e2bc963902d42e985c29ee489aa3c989ac1561c952a6424f107a800000000000000000000000000000000000000000000000000000000000000014cb452f6e3f10ba2175c86a0284f53fcb61404b458393391abc3d5622e3e55cdc0", "to": "0x00000000219ab540356cBB839Cbe05303d7705Fa", "gasLimit": "100000", "value": "10000000000000", "data": "0xa49b131b0200000000000000000000008eb2277e54a2a7db9b7c0d9fa9b78dcb35f74866000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000003fcd8d9acac042095dfba53f4c40c74d19e2e9d9000000000000000000000000000000000000000000000000000000000000251c0000000000000000000000003202b5b0602274197ccb22b8c02cec9539990c7c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000e86b78000ed3b7b820ac6a39b46602356daee0602180fefa69a94774c3209a9f5ad1df42aa2c426b1494a39afc4ee79a528dca95807f5a1b518c8fb0a4df1be92b8a8b6e5f4fccf35f3975f9cf64aa92f4896f2553a5ba9fb0b13cabb25f21a2881f027d9703bfa57f45a514fff7bcc1b8020c2a3ab0581cfbb748dfe612a14acef40bc61de068cf3117e8227ab1315e0302f97e17d5b8948aa8071645b27ad74f669783d363fbc7e9dd58c01e535aff418b2fdbff56a55212e25efbc6b963bb048d98ecc1d03020f890bbf7518fd2463afb82ffdf452863268bdae4eae18d6108dce9ef803669f466000000000000000000000000000000000000000000000000", "chainId": 560048, "type": 2, "maxFeePerGas": "2211533588", "maxPriorityFeePerGas": "69385672" } } ``` * `serializeTx` — serialized unsigned transaction. * `to` — recipient address for this transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ## 2. Sign and broadcast transaction Prepare `serializeTx` from the previous step to [sign](/docs/signing-transaction-eth) and broadcast the signed transaction to the Ethereum network. # Overview Source: https://docs.p2p.org/docs/pectra-overview On May 7, 2025, the major Pectra upgrade to the Ethereum network was carried out that brought the following benefits for clients who use ETH or SSV validators. * Enhanced efficiency and security with validators that can hold more than 32 ETH (up to 2048 ETH) * Several validators can now be consolidated into one * Auto-compounded rewards * Partial top-ups and withdrawals from validators P2P.ORG has introduced a series of improvements to its staking APIs, enabling clients to take full advantage of the new validator capabilities. These changes include support for both Ethereum and SSV-based validators. | Feature | Description | | - | - | | [Validator Consolidation](/docs/validator-consolidation) | Merge multiple validators into one with a single withdrawal address | | [Initial Staking](/docs/initial-staking) | Create `0x02` validators in a single transaction (via 3.1 Smart Contract) | | [Incremental Staking (Top-ups)](/docs/incremental-staking-tops-up) | Increase stake on an existing validator up to 2048 ETH | | [Partial Withdrawals](/docs/partial-withdrawals) | Withdraw tokens in excess of 32 ETH without exiting the validator | Note that most of these features require updating the validator’s withdrawal credential type from either `0x00` or `0x01` to a new `0x02`-type withdrawal credential. ## SSV Validator Support under Pectra P2P.ORG has extended its SSV staking API to fully support the capabilities introduced with the Ethereum Pectra upgrade. This ensures that clients using the SSV network can benefit from the same validator enhancements as native Ethereum staking users. All SSV staking methods now align with the Ethereum Staking API to offer consistent workflows, regardless of your validator backend. Key updates: 1. **Unified flow**. Most operations, except validator setup, use the same API methods for both Ethereum and SSV validators 2. **Simplified validator setup via the 3.1 Smart Contract**. SSV validator creation flow now supports `0x02` withdrawal credentials ## Backward Compatibility All changes are backward compatible with the current `0x01` validator flow and allow seamless migration to the `0x02` type of withdrawal credentials for enhanced functionality. * Clients currently using the `0x01` validator setup can continue without changes, as well as create new `0x01` validators as before * All existing methods remain supported * New functionality is exposed via new API methods or optional parameters in existing methods This ensures a seamless upgrade path without breaking changes. ## Next Steps To get started with the new Pectra-enabled features, we recommend following the next steps: 1. **Review the API overview table** below to learn which methods support new features. 2. **Select the relevant flows** based on your validator type (Ethereum or SSV) and your use case. 3. **Test in the Hoodi testnet** environment. 4. **Refer to the example section** for complete cURL samples and expected responses. 5. **Reach out to our team** if you need help integrating or have specific questions: 📧 [support@p2p.org](mailto:support@p2p.org) | Use Case | API Type | SSV Support | Compatibility | | - | - | - | - | | [Validator Consolidation](/docs/validator-consolidation) and upgrade to `0x02` | New | Same method | Compatible | | [Initial Staking](/docs/initial-staking) | Updated | Updated for `0x02` support | Compatible | | [Incremental Staking (Top-ups)](/docs/incremental-staking-tops-up) | New | Same method | Compatible | | [Partial Withdrawal](/docs/partial-withdrawals) | New | Same method | Requires `0x02` type of withdrawal credentials | | Full Withdrawal | Unchanged | Unchanged | Compatible | # Integration Planning Guide Source: https://docs.p2p.org/docs/planning-considerations Plan your integration with P2P.ORG Before starting your integration with P2P.org's APIs, it's important to understand the different approaches available and their implications. This guide will help you choose the right integration path and plan your development effectively. ## Integration Approach | | Unified API (recommended) | Staking API | | :- | :- | :- | | Estimated Integration Time | \<1 week for 20+ networks | \<1 week for a single network | | Network Support | Single endpoint for all networks | Network-specific endpoints | | Customization | Standard options | More control over the staking flow | | Development Complexity | Low — standardized requests | Medium — network-specific implementations | | Best For | Quick multichain integration | Single blockchain implementation | ## Integration Timeline ### Phase 1: Planning (estimation: \<1 week) * Choose between [Unified API](/docs/unified-api-overview) or [Staking API](/docs/staking-overview), or other APIs (Restaking API, DVT API) * Define required networks and features (see [Networks Supported](/docs/networks-supported)) * Check existing code [Recipes](https://docs.p2p.org/recipes) ### Phase 2: Development #### Option 1: Unified API (estimation: \<1 week for 10+ networks) * Implement [authentication](/docs/authentication) * Integrate single endpoint for all networks * Test with multiple networks #### Option 2: Staking API (estimation: \<1 week for a single network) * Implement [authentication](/docs/authentication) * Set up network-specific integrations * Implement advanced features for each network individually ### Phase 3: Testing & Production Launch (estimation: \~1 week) * Production credentials setup * End-to-end testing * Monitoring implementation Need help planning your integration? Contact our [team](/docs/contacts) for guidance. # Overview Source: https://docs.p2p.org/docs/platform-overview P2P.org provides enterprise-grade APIs that enable businesses to integrate staking operations and analytics across multiple blockchain networks. Our unified platform combines comprehensive staking capabilities with real-time data insights, all through a single, secure interface. The staking ecosystem is growing rapidly. The staking (The process of locking up tokens as collateral to secure the network, participate in consensus, and earn rewards in a Proof-of-Stake blockchain.) process can be complex and challenging to navigate for many users. The complexity arises even further when we look at large organizations. The P2P Staking APIs serve as an integration point for enterprises to access the entire staking ecosystem. The platform provides clients with access to direct staking on multiple blockchains. The product caters to institutional clients, crypto exchanges, crypto wallets, and anyone else who wants to participate in staking. ## Our Products * **Unified API**: Go multi-chain with one API for your staking needs * **Staking API**: Direct staking operations across multiple networks * **Restaking API**: Maximize yield through restaking capabilities * **DVT Staking**: Distributed validator technology for enhanced rewards with security and reliability * **Data API**: Analytics and historical staking data ## Introduction and Showcase of the Unified API [Introduction and Showcase of the Unified API](https://www.youtube.com/embed/8tilLxgyiok) ## Use Cases * Launch staking services on your platform without infrastructure overhead * Monitor validator performance and network statistics * Automate staking operations across multiple networks * Access historical staking data for analytics and reporting * Implement distributed validation for enhanced security ## Using AI Tools P2P.ORG provides multiple ways to consume the entire documentation with AI tools to help you build applications faster. Please see [Overview for AI Tools](/docs/overview-ai#/). Need help? Contact our [team](/docs/contacts) for dedicated assistance. # Getting Started Source: https://docs.p2p.org/docs/pooled-staking-getting-started > [!WARNING] > > **Accessing the Pooled Staking public vault** > > Contact our [team](/docs/contacts) for dedicated assistance before setting up your pooled staking flow. Staking via the Pooled Staking API enables enterprise partners to offer secure, seamless ETH staking to their users, without the 32 ETH minimum. The process consists of the following steps: 1. Get the list of available vaults. 2. Prepare a deposit transaction. 3. Sign and broadcast the transaction. You can also track the staking rewards, as well as monitor historical balance and APY. Below, a lifecycle diagram of the process is provided. ```mermaid theme={null} sequenceDiagram participant USER as User (wallet/app) participant PARTNER as Partner Backend participant API as Pooled Staking API participant ETH as Ethereum Network %% --- DEPOSIT FLOW --- USER->>PARTNER: Stake ETH (<32 ETH) PARTNER->>API: POST /staking/deposit API-->>PARTNER: Unsigned deposit transaction PARTNER->>USER: User signs transaction USER-->>PARTNER: Signed deposit transaction PARTNER->>API: POST /transaction/send API-->>ETH: Broadcast to Ethereum %% --- WITHDRAWAL FLOW --- USER->>PARTNER: Unstake (withdraw) ETH PARTNER->>API: POST /staking/withdraw API-->>PARTNER: Unsigned withdrawal transaction PARTNER->>USER: User signs transaction USER-->>PARTNER: Signed withdrawal transaction PARTNER->>API: POST /transaction/send API-->>ETH: Broadcast to Ethereum %% --- OPTIONAL: STATUS/CLAIM --- Note over USER,PARTNER: ETH claimable after 1–4 days. PARTNER->>API: POST /staking/claim (when claimable) API-->>PARTNER: Unsigned claim transaction PARTNER->>USER: User signs transaction USER-->>PARTNER: Signed claim transaction PARTNER->>API: POST /transaction/send API-->>ETH: Broadcast to Ethereum ETH-->>USER: ETH returned to user wallet ``` [Get an authentication token](/docs/authentication) to start using Pooled Staking API. Request examples are provided using [cURL](https://curl.se/). > [!WARNING] > > **Please note** > > The Pooled Staking API does not use base URL switching to differentiate between Mainnet and Testnet as compared to other ETH APIs. It uses path switching in the endpoints. **1. Get list of vaults** Before depositing, retrieve the list of vaults associated to your token by sending a GET request to [/api/v1/staking/pool/\{network}/staking/vaults](/reference/eth-pool-staking-vaults-list). Example request (for `hoodi` network): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/vaults \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/vaults", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/vaults", headers={ "accept": "application/json", "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/vaults", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` Example response: ```json theme={null} { "error": null, "result": { "network": "hoodi", "vaults": [ { "vaultAddress": "0xba447498DC4c169f2b4f427B2c4D532320457E89", "displayName": "Genesis Vault", "apy": 2.183411246189064, "baseApy": 2.183411246189064, "capacity": 1000000.0, "totalAssets": 1565.298221320626932191, "feePercent": 5, "isPrivate": false, "isGenesis": true, "isSmoothingPool": true, "isErc20": false, "tokenName": null, "tokenSymbol": null, "createdAt": 1743445116000 }, { "vaultAddress": "0x2b3eB77e5cbde5DEb70c928E1E2814F8A6f143e0", "displayName": "NodeSet Hoodi Test Vault", "apy": 0.11080513448983267, "baseApy": 0.11080513448983267, "capacity": 1000000.0, "totalAssets": 12015.065998077636066564, "feePercent": 10, "isPrivate": false, "isGenesis": false, "isSmoothingPool": true, "isErc20": false, "tokenName": null, "tokenSymbol": null, "createdAt": 1744827492000 } ] } } ``` * `network` — network name: `mainnet` or `hoodi`. * `vaults` — detailed information on each vault available to integration: * `vaultAddress` — Ethereum address of the vault. * `displayName` — vault name. * `apy` — current annual percentage yield (APY) including boost incentives. * `baseApy` — average weekly base APY of the vault (without extra incentives). * `capacity` — vault maximum total value locked (TVL). * `totalAssets` — current amount of funds staked on the vault. * `feePercent` — amount of fee in percent charged by the vault. * `isPrivate` — parameter indicating if this vault is exclusive to current integration: `true` means the vault is private, `false` means the vault is public or shared. * `isGenesis` — parameter indicating if this vault is a [StakeWise](https://docs.stakewise.io/) vault. * `isSmoothingPool` — parameter indicating if this vault is a [Smoothing Pool](https://docs.stakewise.io/protocol-overview-in-depth/vaults#eth-8) or a [Vault Escrow](https://docs.stakewise.io/protocol-overview-in-depth/vaults#eth-8:~:text=thief%22%20status%20internally.-,Own%20Escrow,-Own%20Escrow%20allows). * `isErc20` — parameter indicating if this vault has its own ERC-20 token. * `tokenName` — name of the ERC-20 token that represents ETH staked by delegators in the vault. * `tokenSymbol` — symbol of the vault's ERC-20 token. * `createAt` — timestamp of the vault creation in the ISO 8601 format. **2. Prepare the transaction** To create an unsigned deposit transaction for the selected vault, send a POST request to [/api/v1/staking/pool/\{network}/staking/deposit](/reference/eth-pool-staking-deposit). Example request (for `hoodi` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/deposit \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "delegatorAddress": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", "vaultAddress": "0xba447498dc4c169f2b4f427b2c4d532320457e89", "amount": 0.07 } ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/deposit", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ delegatorAddress: "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", vaultAddress: "0xba447498dc4c169f2b4f427b2c4d532320457e89", amount: 0.07, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/deposit", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "delegatorAddress": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", "vaultAddress": "0xba447498dc4c169f2b4f427b2c4d532320457e89", "amount": 0.07, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "delegatorAddress": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", "vaultAddress": "0xba447498dc4c169f2b4f427b2c4d532320457e89", "amount": 0.07, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/staking/pool/hoodi/staking/deposit", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `delegatorAddress` — account address of the user initiating the staking transaction. * `vaultAddress` — Ethereum address of the vault to which the deposit is being made. Mind to specify the correct `vaultAddress` for all staking operations. * `amount` — amount of tokens in ETH to deposit. The value must be decimal, e.g., 0.01. Example response: ```bash theme={null} "error": null, "result": { "amount": 0.07, "vaultAddress": "0xba447498dc4c169f2b4f427b2c4d532320457e89", "delegatorAddress": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", "unsignedTransaction": { "serializeTx": "0x02f87683088bb0168459682f0084d16be71082d54e94ba447498dc4c169f2b4f427b2c4d532320457e8987f8b0a10e470000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c0", "to": "0xba447498dc4c169f2b4f427b2c4d532320457e89", "data": "0xf9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000", "value": "70000000000000000", "nonce": 22, "chainId": 560048, "gasLimit": "54606", "type": 2, "maxFeePerGas": "3513509648", "maxPriorityFeePerGas": "1500000000" }, "createdAt": "2025-07-21T12:05:59.015Z" } } ``` * `amount` — amount of tokens in ETH to deposit. * `vaultAddress` — Ethereum address of the vault to which the deposit is being made. * `delegatorAddress` — account address of the user initiating the staking transaction. * `unsignedTransaction` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `serializeTx` — unsigned serialized transaction. * `to` — recipient address for this transaction. * `data` — transaction data payload in the hexadecimal format. * `value` — amount this transaction is sending in Wei. * `nonce` — nonce of the sender account. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. **3. Sign and send the transaction** Use `unsignedTransaction` from the previous step to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. By broadcasting this transaction, you're initiating the staking operation on the Ethereum vault. ## Additional operations ### Get account info To track delegator balances, staking status, and withdrawal eligibility, send a GET request to [/api/v1/staking/pool/\{network}/account/\{delegatorAddress}/vault/\{vaultAddress}/](/reference/eth-pool-account-info). Example request (for `hoodi` network): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89/ \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89/", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89/", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89/", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `delegatorAddress` — account address of the user initiated the staking transaction. * `vaultAddress` — Ethereum address of the vault. Example response: ```json theme={null} { "error": null, "result": { "delegatorAddress": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", "vaultAddress": "0xba447498dc4c169f2b4f427b2c4d532320457e89", "stake": { "assets": 0.40002974751806797, "totalEarnedAssets": 0.000086455591795945 }, "availableToWithdraw": 0.010034115368561011, "exitQueue": { "total": 0.09007179878300194, "requests": [ { "ticket": "14550213999915345334", "totalAssets": 0.010034115368561011, "timestamp": 1749747696000, "withdrawalTimestamp": 0, "isClaimable": true }, { "ticket": "23001870415343779687", "totalAssets": 0.010000509804222077, "timestamp": 1752413688000, "withdrawalTimestamp": 1752500088000, "isClaimable": false }, { "ticket": "23011815987815344974", "totalAssets": 0.06000305882533247, "timestamp": 1752413796000, "withdrawalTimestamp": 1752500196000, "isClaimable": false } ] } } } ``` * `delegatorAddress` — account address of the user initiated the staking transaction. * `vaultAddress` — Ethereum address of the vault. * `stake` — detailed information about the current stake: * `assets` — amount of tokens in the stake in Wei. * `totalEarnedAssets` — total amount of rewards received in Wei. * `availableToWithdraw` — amount of tokens in Wei available to withdraw from the vault. * `exitQueue` — detailed information on the tokens locked for the waiting period. * `total` — total amount of tokens in Wei in the exit queue. * `requests` — detailed information on the unstaking requests initiated by the delegator: * `ticket` — position of the unstaking request in a special format required for claiming. * `totalAssets` — total amount of tokens in Wei queued for unstaking. * `timestamp` — timestamp of the unstaking request creation in the ISO 8601 format. * `withdrawalTimestamp` — estimated timestamp in the ISO 8601 format indicating when the tokens become withdrawable. * `isClaimable` — parameter indicating if this amount of tokens is available to withdraw. ### Get rewards history To retrieve daily balance and reward history, as well as current APY, send a GET request to [/api/v1/staking/pool/\{network}/account/\{delegatorAddress}/vault/\{vaultAddress}/rewards](/reference/eth-pool-account-rewards). Example request (for `hoodi` network): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89\rewards / \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89/rewards", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89/rewards", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/staking/pool/hoodi/account/0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe/vault/0xba447498dc4c169f2b4f427b2c4d532320457e89/rewards", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `delegatorAddress` — account address of the user initiated the staking transaction. * `vaultAddress` — Ethereum address of the vault. Example response: ```json theme={null} { "error": null, "result": { "delegatorAddress": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", "vaultAddress": "0xba447498dc4c169f2b4f427b2c4d532320457e89", "rewards": [ { "date": "2025-07-13T00:00:00.000Z", "apy": 2.1705144753973515, "balance": 0.4000192848063124, "rewards": 0.23001511006385378 }, { "date": "2025-07-12T00:00:00.000Z", "apy": 0.6728186791771593, "balance": 0.1700041747424586, "rewards": 0.000003202086219675 }, { "date": "2025-07-11T00:00:00.000Z", "apy": 1.8252614817398076, "balance": 0.04000089425699653, "rewards": 0.000001960880296672 }, { "date": "2025-07-10T00:00:00.000Z", "apy": 1.806864874160972, "balance": 0.0399988582881249, "rewards": 0.000003918771522507 }, { "date": "2025-07-08T00:00:00.000Z", "apy": 2.889941328415176, "balance": 0.03999476781018422, "rewards": 0.000005056349354517 }, { "date": "2025-07-06T00:00:00.000Z", "apy": 1.7762765993571947, "balance": 0.03998953257364396, "rewards": 0.000001989611942596 }, { "date": "2025-07-05T00:00:00.000Z", "apy": 1.878205919278462, "balance": 0.03998746377580935, "rewards": 0.000001995075528891 }, { "date": "2025-07-04T00:00:00.000Z", "apy": 1.6840977946143212, "balance": 0.03998539531683224, "rewards": 0.000001903591244608 }, { "date": "2025-07-03T00:00:00.000Z", "apy": 2.9042127452251387, "balance": 0.039983395559925, "rewards": 0.000003130564053543 }, { "date": "2025-07-02T00:00:00.000Z", "apy": 1.8025197659824885, "balance": 0.03998016066470251, "rewards": 0.000002004548585118 }, { "date": "2025-07-01T00:00:00.000Z", "apy": 2.9738768552591783, "balance": 0.039978033387643545, "rewards": 0.000003155011811334 }, { "date": "2025-06-30T00:00:00.000Z", "apy": 1.8162541709061624, "balance": 0.039974802212567426, "rewards": 0.00000201347365414 }, { "date": "2025-06-29T00:00:00.000Z", "apy": 1.8075625838524545, "balance": 0.03997270942400358, "rewards": 0.000001992735938527 }, { "date": "2025-06-28T00:00:00.000Z", "apy": 3.5107177909087954, "balance": 0.03997061537620456, "rewards": 0.0000038755055009 }, { "date": "2025-06-27T00:00:00.000Z", "apy": 1.8759957590284255, "balance": 0.03996661168951173, "rewards": 0.000002013656908218 }, { "date": "2025-06-26T00:00:00.000Z", "apy": 1.7944579365558677, "balance": 0.039964522307306544, "rewards": 0.000001965603707971 }, { "date": "2025-06-25T00:00:00.000Z", "apy": 1.7550488747436979, "balance": 0.03996248113678149, "rewards": 0.000001944488887432 }, { "date": "2025-06-24T00:00:00.000Z", "apy": 1.8379157842851654, "balance": 0.039960459210225195, "rewards": 0.000001972758389168 }, { "date": "2025-06-23T00:00:00.000Z", "apy": 1.7928563914758289, "balance": 0.03995841203163699, "rewards": 0.000003915092206271 }, { "date": "2025-06-21T00:00:00.000Z", "apy": 2.8871373517191192, "balance": 0.03995432882638032, "rewards": 0.000003123063599167 }, { "date": "2025-06-20T00:00:00.000Z", "apy": 2.828933988702405, "balance": 0.03995108713916603, "rewards": 0.000003060285847402 }, { "date": "2025-06-19T00:00:00.000Z", "apy": 1.7454148564582386, "balance": 0.0399479201945625, "rewards": 0.000001900741504801 }, { "date": "2025-06-18T00:00:00.000Z", "apy": 2.788462639348563, "balance": 0.0399458996835444, "rewards": 0.000003144115598416 }, { "date": "2025-06-17T00:00:00.000Z", "apy": 1.8359009572035467, "balance": 0.03994267570940807, "rewards": 0.000001986181925313 }, { "date": "2025-06-16T00:00:00.000Z", "apy": 1.8726943585624019, "balance": 0.03994061341223341, "rewards": 0.000002023036371899 }, { "date": "2025-06-15T00:00:00.000Z", "apy": 1.8306555099791324, "balance": 0.039938512940331676, "rewards": 0.000001986143112602 }, { "date": "2025-06-14T00:00:00.000Z", "apy": 1.7559323566628742, "balance": 0.03993645014333918, "rewards": 0.000001984760250822 }, { "date": "2025-06-13T00:00:00.000Z", "apy": 2.350308909342375, "balance": 0.03993438526261774, "rewards": 0.000002537884144973 } ] } } ``` * `delegatorAddress` — account address of the user initiated the staking transaction. * `vaultAddress` — Ethereum address of the vault. * `rewards` — list of daily snapshots: * `date` — timestamp of each data point in the ISO 8601 format. * `apy` — delegator current annual percentage yield (APY) based on time, rewards, and balance. * `balance` — total amount of tokens in Wei staked by the delegator on the vault. * `rewards` — amount of tokens in Wei received as rewards. # Overview Source: https://docs.p2p.org/docs/pooled-staking-overview Pooled Staking API by P2P.ORG empowers enterprise partners — including wallets, exchanges, and custodians — to offer Ethereum staking to their users without the traditional 32 ETH minimum. User deposits are aggregated into dedicated vaults, with validator operations and staking workflows fully managed by P2P.ORG’s infrastructure. The API provides the interface for initiating stakes, processing withdrawals, and accessing real-time status and reporting. All staking operations are fully non-custodial: the API constructs only unsigned transactions, while transaction signing and key management remain entirely within the partner’s or user’s control. Private keys are never transmitted to or stored by P2P.ORG at any point. ## Key features * **No 32 ETH Minimum**: Stake any amount of ETH. * **API-Driven**: Full staking and withdrawal lifecycle managed via API endpoints. * **Non-Custodial**: Only unsigned transactions are generated; signing stays on the client side. * **White-Label Vaults**: Partners may have a dedicated vault with their own branding and configuration. * **Transparent Reward Tracking**: Query endpoints for current balance, earnings, and withdrawal status. * **Enterprise Grade**: Designed for integration with high-volume, regulated platforms. We provide distinct endpoints for testing and production environments. The test environment is linked to the Hoodi network (Ethereum). * PRODUCTION: [https://api.p2p.org](https://api.p2p.org) * TESTING ON HOODI: [https://api-test.p2p.org](https://api-test.p2p.org) [Get an authentication token](/docs/authentication) to start using Pooled Staking API. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/pooled-staking-signing-transaction To complete any staking or withdrawal operation on Ethereum, sign the unsigned transaction provided by the Pooled Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `/staking/deposit`, `/staking/unstake` or `/staking/withdraw`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Ethereum network by sending a POST request to [/api/v1/staking/pool/\{network}/transaction/send](/reference/eth-pool-transaction-broadcast). Example request (for `hoodi` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/staking/pool/hoodi/transaction/send \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8" }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/staking/pool/hoodi/transaction/send", { method: "POST", headers: { "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ "signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8" }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/staking/pool/hoodi/transaction/send", headers={ "authorization": "Bearer ", "content-type": "application/json", }, json={ "signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8" }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0x02f8b983088bb00e8459682f0084cf5f645482cb2694ba447498dc4c169f2b4f427b2c4d532320457e89872386f26fc10000b844f9609f08000000000000000000000000092af80778ff3c3d27fd2744c39f6e9326d9aaee0000000000000000000000000000000000000000000000000000000000000000c080a0709f764a37d31ed49fa84913082568b241b57a3cc7e660a597868f9d39bb4055a018ce04abc90fcceec21bf084c8966426ad7eda33a1cb541078b8a597ea7340a8", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/staking/pool/hoodi/transaction/send", bytes.NewBuffer(body)) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction in the hexadecimal format which needs to be broadcasted to the network. Example response: ```json theme={null} { "error": null, "result": { "hash": "0x9945ee6bbbdb7c34565b8833d37d302da9c76d63262d12a36f7c8f822553fa84", "status": "success", "blockNumber": 791360, "transactionIndex": 0, "gasUsed": "51613", "cumulativeGasUsed": "51613", "effectiveGasPrice": "2606634082", "from": "0x092Af80778ff3c3D27Fd2744C39f6e9326d9AaEe", "to": "0xba447498DC4c169f2b4f427B2c4D532320457E89" } } ``` * `hash` — hash of the Ethereum transaction. * `status` — transaction status: `pending`, `confirmed`, or `failed`. * `blockNumber` — block number in which the transaction has been included; `null` if the transaction has not been confirmed yet. * `transactionIndex` — value of the position of the transaction in the block in which it has been included. * `gasUsed` — amount of gas spent for the transaction. * `cumulativeGasUsed` — total amount of gas used by all transactions in a block up to this transaction. * `effectiveGasPrice` — actual price per gas unit. * `from` — sender address of this transaction. * `to` — recipient address for this transaction. # Getting Started Source: https://docs.p2p.org/docs/restaking-eth Restake Ethereum with EigenLayer using the P2P.org Restaking API. The EigenLayer restaking flow includes the following steps: 1. Create EigenPod address: construct a serialized transaction to generate an EigenPod address, which your validator can use as a withdrawal address. 2. Create Staking Request: set up nodes for staking using P2P infrastructure. 3. Check Request Status: check the status of the node set-up operation. 4. Prepare Staking Transaction: construct a serialized transaction to deposit the stake amount with a smart contract. 5. Verify Withdrawal Credentials: construct a serialized transaction to verify the validator withdrawal credentials on-chain. 6. Delegate Restake to Operator: construct a serialized transaction to delegate the restake amount to the EigenLayer node operator. [Get an authentication token](/docs/authentication) to start using Restaking API. Request examples are provided using [cURL](https://curl.se/). *** ## 1. Create eigenPod address 1. Retrieve a serialized transaction to generate an EigenPod address by sending a POST request to [/api/v1/eth/staking/eigenlayer/tx/create-pod](/reference/eth-eigen-create-pod). Example request: ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/create-pod \ --header 'accept: application/json' \ --header 'authorization: Bearer ' --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/create-pod", { method: "POST", headers: { "authorization": "Bearer ", "content-type": "application/json", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/create-pod", headers={ "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/create-pod", nil) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` Example response: ```json theme={null} { "result": { "serializeTx": "0x02f902d705808301674e8508530af16e830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aa5f27070a21d79455c4a9b73c0aa4a8b1a65a1fb530d7fd8e6cd23aa16660679ac43ee4861098f6d9166aed3a4d8abb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002001000000000000000000000028c84612d37de9209018ad96167f12169b653e9a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060978c565cd915f4e885b4201093d1501697610eb9ee99b9b60b70434dc330e98d5b42927725304ded48483a8b8f39506d09bcb22ee18d4f6b50257946ac5ee360385308d95c0e2bc963902d42e985c29ee489aa3c989ac1561c952a6424f107a800000000000000000000000000000000000000000000000000000000000000014cb452f6e3f10ba2175c86a0284f53fcb61404b458393391abc3d5622e3e55cdc0", "to": "0x30770d7E3e71112d7A6b7259542D1f680a70e315", "gasLimit": "10000000", "data": "0x84d81062", "value": "0", "chainId": "17000", "type": "2", "maxFeePerGas": "1000040", "maxPriorityFeePerGas": "1000000" }, "error": {} } ``` * `serializeTx` — serialized unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.). * `to` — recipient address for this transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. 2. Use `serializeTx` to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. By broadcasting this transaction, you are generating an EigenPod address. The Ethereum address used to sign this transaction will become the `eigenPodOwnerAddress`. ## 2. Create staking request 1. Prepare`id` that is an arbitrary UUID. Generate it in one of the following ways: * [Online UUID Generator](https://www.uuidgenerator.net/) * [uuid npm package](https://www.npmjs.com/package/uuid) 2. Set up staking nodes through the P2P infrastructure by sending a POST request with the `RESTAKING` type to [/api/v1/eth/staking/direct/nodes-request/create](/reference/eth-nodes-request-create). Example request: ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/create \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "id":"6df58880-c4c9-484a-8fc4-7f7668fe9522", "type": "RESTAKING", "validatorsCount": 1, "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "feeRecipientAddress":"0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "controllerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "nodesOptions":{ "location": "any", "relaysSet": null } } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/create", { method: "POST", headers: { "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ "id": "6df58880-c4c9-484a-8fc4-7f7668fe9522", "type": "RESTAKING", "validatorsCount": 1, "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "controllerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "nodesOptions": { "location": "any", "relaysSet": null } }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/create", headers={ "authorization": "Bearer ", "content-type": "application/json", }, json={ "id": "6df58880-c4c9-484a-8fc4-7f7668fe9522", "type": "RESTAKING", "validatorsCount": 1, "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "controllerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "nodesOptions": { "location": "any", "relaysSet": None } }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "id": "6df58880-c4c9-484a-8fc4-7f7668fe9522", "type": "RESTAKING", "validatorsCount": 1, "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "controllerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "nodesOptions": map[string]interface{}{"location": "any", "relaysSet": nil}, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/create", bytes.NewBuffer(body)) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `id` — arbitrary UUID. You can later use that UUID to check the status of the set-up operation. * `type` — staking operation type: * `RESTAKING` — value for initiating a restaking operation. * `REGULAR` — default value used for native staking transactions. * `validatorsCount` — number of validators. One validator is equal to 32 ETH. * `feeRecipientAddress` — fee recipient address. * `eigenPodOwnerAddress` — owner of the EigenPod address, created in the [previous step](/docs/restaking-eth#1-create-eigenpod-address). * `controllerAddress` — controller address (On Ethereum, we introduced the controller address entity to provide greater flexibility and maintain high-level security during the withdrawal flow. When the user requests the validator withdrawal, only authorized addresses can initiate this request by calling our withdrawal smart contract. The authorized addresses are the withdrawal address and the controller address. Since many users prefer not to use the withdrawal address to interact with smart contracts, a second authorized address can be specified as controller address in the new staking request.) for the validators. * `nodesOptions`: * * `location` — node location. Currently, only `any` is supported. * `relaysSet` — Miner Extractable Value (MEV (Miner Extractable Value Relay Selection is a process of selecting a validator to participate in the next Ethereum block based on the value that they can extract from transactions in that block.)) relay selection. Example response: ```json theme={null} { "result": true } ``` ## 3. Check request status Check the status of the node set-up operation by sending a GET request to [`/api/v1/eth/staking/direct/nodes-request/status/\{id}`](/reference/eth-nodes-request-status). Example request: ```bash curl theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/status/6df58880-c4c9-484a-8fc4-7f7668fe9522 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/status/6df58880-c4c9-484a-8fc4-7f7668fe9522", { headers: { "authorization": "Bearer ", "content-type": "application/json", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/status/6df58880-c4c9-484a-8fc4-7f7668fe9522", headers={ "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/status/6df58880-c4c9-484a-8fc4-7f7668fe9522", nil) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `id` — UUID that was specified in the node set-up request. Example response: ```json theme={null} { "result": { "id": "6df58880-c4c9-484a-8fc4-7f7668fe9522", "status": "ready", "type": "RESTAKING", "validatorsCount": 1, "withdrawalAddress": null, "eigenPodAddress": "0x1433F808a4867aDEeEb3AE0Df58691C252269A2C", "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "controllerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "feeRecipientAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "depositData": [ { "pubkey": "0xaed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13", "signature": "0x91b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf5", "depositDataRoot": "0xd0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89", "withdrawalCredentials": "0100000000000000000000001433f808a4867adeeeb3ae0df58691c252269a2c", "amount": 32000000000, "depositMessageRoot": "04f641c39de982aee68cc7c78bd23bcafffed91fd1c455282b651e0c8d6c4e20", "forkVersion": "01017000", "eth2NetworkName": "hoodi", "depositCliVersion": "2.7.0" } ], "createdAt": "2025-01-29T15:07:08.399Z" } } ``` * `id` — UUID that was specified in the node set-up request. * `status` — current status of the node request: * `init` — node request is created. * `processing` — node request is in progress. * `ready` — backend has the deposit data for the node request. * `cancel` — something went wrong and the deposit data was not created. * `validatorsCount` — number of validators. One validator is equal to 32 ETH. * `withdrawalAddress` — withdrawal address for the validators that is set to `null` by default; corresponds to the EigenPod address. * `eigenPodAddress` — EigenPod address also used as the validator withdrawal address. * `eigenPodOwnerAddress` — owner of the EigenPod address. * `controllerAddress` — controller address (On Ethereum, we introduced the controller address entity to provide greater flexibility and maintain high-level security during the withdrawal flow. When the user requests the validator withdrawal, only authorized addresses can initiate this request by calling our withdrawal smart contract. The authorized addresses are the withdrawal address and the controller address. Since many users prefer not to use the withdrawal address to interact with smart contracts, a second authorized address can be specified as controller address in the new staking request.) for the validators. * `feeRecipientAddress` — fee recipient address. * `depositData`: * `pubkey` — validator public key. * `signature` — validator signature. * `depositDataRoot` — SHA-256 hash of the SSZ-encoded DepositData object; used as a protection against malformed input. * `withdrawalCredentials`— withdrawal address credentials, passed in the expected format by the Ethereum deposit smart contract. * `amount` — amount of ETH, denominated in Gwei, that is being deposited. * `depositMessageRoot` — cryptographic hash of the Merkle tree’s root, ensuring the integrity and authenticity of the deposit data. * `forkVersion` — version of the network fork that the deposit is intended for. It helps in aligning the deposit with a specific version of the protocol. * `eth2NetworkName` — name of the Ethereum 2.0 network where the deposit is made. * `depositCliVersion` — version of the deposit command-line interface (CLI) tool that was used to generate the deposit data. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ## 4. Prepare staking transaction There are two flow to make a deposit: | Workflow | Best For | Logic | | - | - | - | | Simplified Smart Contract | Most Users | Uses P2P proxy contract to handle registration and deposit in one flow. | | Direct Interaction | Power Users | Manually interacting with the Ethereum Deposit Contract for fine-grained control. | ### 4.1 [P2P Proxy deposit](/docs/direct-staking#p2p-direct-staking-v1-eth2-depositor--message-sender-flow) Create a serialized transaction for depositing the stake amount and send it as a POST request to [/api/v1/eth/staking/direct/tx/deposit](/reference/eth-staking-deposit). ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/direct/tx/deposit \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "withdrawalAddress": "0x1433F808a4867aDEeEb3AE0Df58691C252269A2C", "depositData": [ { "pubkey": "0xaed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13", "signature": "0x91b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf5", "depositDataRoot": "0xd0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89" } ] } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/direct/tx/deposit", { method: "POST", headers: { "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ "withdrawalAddress": "0x1433F808a4867aDEeEb3AE0Df58691C252269A2C", "depositData": [ { "pubkey": "0xaed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13", "signature": "0x91b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf5", "depositDataRoot": "0xd0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89" } ] }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/eth/staking/direct/tx/deposit", headers={ "authorization": "Bearer ", "content-type": "application/json", }, json={ "withdrawalAddress": "0x1433F808a4867aDEeEb3AE0Df58691C252269A2C", "depositData": [ { "pubkey": "0xaed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13", "signature": "0x91b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf5", "depositDataRoot": "0xd0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89" } ] }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "withdrawalAddress": "0x1433F808a4867aDEeEb3AE0Df58691C252269A2C", "depositData": []interface{}{map[string]interface{}{"pubkey": "0xaed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13", "signature": "0x91b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf5", "depositDataRoot": "0xd0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89"}}, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/eth/staking/direct/tx/deposit", bytes.NewBuffer(body)) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `withdrawalAddress` — withdrawal address for the validators. For the `RESTAKING` operation type, this corresponds to the `eigenPodAddress` in the step 3 [Check Request Status](/docs/restaking-eth#3-check-request-status). * `depositData`: * `pubkey` — validator public key. * `signature` — validator signature. * `depositDataRoot` — hash of the deposit data. * `withdrawalCredentials`— withdrawal address credentials, passed in the expected format by the Ethereum deposit smart contract. * `amount` — amount of ETH, denominated in Gwei, that is being deposited. * `depositMessageRoot` — cryptographic hash of the Merkle tree’s root, ensuring the integrity and authenticity of the deposit data. * `forkVersion` — version of the network fork that the deposit is intended for. It helps in aligning the deposit with a specific version of the protocol. * `eth2NetworkName` — name of the Ethereum 2.0 network where the deposit is made. * `depositCliVersion` — version of the deposit command-line interface (CLI) tool that was used to generate the deposit data. Example response: ```json theme={null} { "error": null, "result": { "serializeTx": "0x02f902d305808205508205c8830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000001433f808a4867adeeeb3ae0df58691c252269a2c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006091b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf50000000000000000000000000000000000000000000000000000000000000001d0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89c0", "to": "0xAD91441aB557b5eC5d9f29DB64522Eb918B4f32b", "gasLimit": "100000", "data": "0x4f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000001433f808a4867adeeeb3ae0df58691c252269a2c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006091b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf50000000000000000000000000000000000000000000000000000000000000001d0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89", "value": "32000000000000000000", "chainId": 17000, "type": 2, "maxFeePerGas": "1000030", "maxPriorityFeePerGas": "1000000" } } ``` Example response is the same as in the [Create EigenPod Address](/docs/restaking-eth#1-create-eigenpod-address) step. Use `serializeTx` to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. By broadcasting this transaction, you are depositing the required stake amount in the Ethereum deposit smart contract by using the [P2P smart contract](/docs/direct-staking#p2p-direct-staking-v1-eth2-depositor--message-sender-flow) as a proxy. ### 4.2 Ethereum direct deposit Use this if you prefer to interact with the official Ethereum contract without a proxy. 1. Take the pubkey, signature, and depositDataRoot from the deposit-data response. 2. Go to the [Official Ethereum Deposit Contract](https://etherscan.io/address/0x00000000219ab540356cBB839Cbe05303d7705Fa) 3. Manually execute the `deposit` function with your 32 ETH and the provided data. ## 5. Verify withdrawal credentials Before starting, ensure your validator has reached the `active_ongoing` status. The API identifies your associated EigenPod and ownership via the EigenPod Owner and signer of your request. > [!WARNING] > > Time taken for validator activation depends on the state of the chain. Verify status by sending a POST request to [/api/v1/eth/staking/direct/validator/status](/reference/eth-validator-status). Proceed only once the status is `active_ongoing`. 1. Verify withdrawal credentials by sending a POST request to [/api/v1/eth/staking/eigenlayer/tx/verify-withdrawal-credentials](/reference/eth-eigen-verify-withdrawal-credentials). This links your validator's principal withdrawal path to your EigenPod. ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/verify-withdrawal-credentials \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "pubkey": "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/verify-withdrawal-credentials", { method: "POST", headers: { "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "pubkey": "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39" }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/verify-withdrawal-credentials", headers={ "authorization": "Bearer ", "content-type": "application/json", }, json={ "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "pubkey": "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39" }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "eigenPodOwnerAddress": "0x27AABeE07E0dbC8b0de20f42b1a1980871314Ef5", "pubkey": "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/verify-withdrawal-credentials", bytes.NewBuffer(body)) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `eigenPodOwnerAddress` — owner of the EigenPod address. * `pubkey` — validator public key. Example response: ```json theme={null} { "error": null, "result": { "list": [ { "serializeTx": "0x02f902d305808205508205c8830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000001433f808a4867adeeeb3ae0df58691c252269a2c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006091b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf50000000000000000000000000000000000000000000000000000000000000001d0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89c0", "to": "0xAD91441aB557b5eC5d9f29DB64522Eb918B4f32b", "gasLimit": "10000000", "data": "0x4f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aed7226d86d884dd44bc45c2b57f7634e72abf247713163388b1c34d89a1322d7228ca023dbaf2465b822e35ba00da13000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000001433f808a4867adeeeb3ae0df58691c252269a2c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006091b710f0e3affe704e76ada81b095afbedf4b760f3160760e8fa0298cc4858e0f325c2652dc698ec63c59db65562551114ab7fcafe1d675eaaf186fa7758800f0157bd0b51cd3a131fac562d6933658ddbf182aab8d20a9483b1392085e54cf50000000000000000000000000000000000000000000000000000000000000001d0d00dce54b4ec8a7803783fc786a859459ead1d35b856c525cb289aba4b0f89", "value": "0", "chainId": 17000, "type": 2, "maxFeePerGas": "1000032", "maxPriorityFeePerGas": "1000000" } ], } } ``` 2. Use `serializeTx` to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. > [!WARNING] > > **Time Sensitive Transaction** > > You must sign and broadcast this transaction within **8192 slots (approx. 27 hours)** of generation. If this window expires, the transaction will be rejected by the network and you must generate a new one, [contact](/docs/contacts) us for support. By broadcasting this transaction, you are verifying the validator withdrawal credentials on-chain. You can proceed to delegate your restake amount to an EigenLayer node operator. ## 6. Delegate restake to operator Once withdrawal credentials are verified, you can delegate your ETH restaking power to a Node Operator. ### 6.1 Get list of operators Retrieve the list of available EigenLayer node operators by sending a GET request to [/api/v1/eth/staking/eigenlayer/operator](/reference/eth-eigen-operator-list). ```bash curl theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/eigenlayer/operator \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/eigenlayer/operator", { headers: { "authorization": "Bearer ", }, }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api.p2p.org/api/v1/eth/staking/eigenlayer/operator", headers={ "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api.p2p.org/api/v1/eth/staking/eigenlayer/operator", nil) req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` Example response: ```json theme={null} { "error": null, "result": { "list": [ { "id": "6df58880-c4c9-484a-8fc4-7f7668fe9522", "name": "P2P", "address": "0xdbed88d83176316fc46797b43adee927dc2ff2f5", } ], "limit": 10, "offset": 0, "totalCount": 1 } } ``` * `list`: * `id` — UUID that was specified in the node set-up request. * `name` — name of provider. * `address` — EigenLayer node operator address. * `limit` — number of resources that a single response page contains. * `offset` — number of resources to exclude from a response. * `totalCount` — total number of validators relevant to the current request, based on filters applied. ### 6.2 Prepare delegation transaction Create a serialized transaction for delegating the restaked amount to the node operator by sending a POST request to [/api/v1/eth/staking/eigenlayer/tx/delegate-to](/reference/eth-eigen-delegate-to). The Eigen Pod delegated is associated to the signer of the request. ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/delegate-to \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "operatorAddress": "0xdbed88d83176316fc46797b43adee927dc2ff2f5" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/delegate-to", { method: "POST", headers: { "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ "operatorAddress": "0xdbed88d83176316fc46797b43adee927dc2ff2f5" }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/delegate-to", headers={ "authorization": "Bearer ", "content-type": "application/json", }, json={ "operatorAddress": "0xdbed88d83176316fc46797b43adee927dc2ff2f5" }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "operatorAddress": "0xdbed88d83176316fc46797b43adee927dc2ff2f5", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/eth/staking/eigenlayer/tx/delegate-to", bytes.NewBuffer(body)) req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `operatorAddress` — address of the EigenLayer node operator retrieved from the previous step, to delegate the restaked assets. Example response: ```json theme={null} { "error": null, "result": { "serializeTx": "0x02f8ef8242688084030825768486442318830186a094a44151489861fe9e3055d95adc98fbd462b948e780b8c4eea9064b00000000000000000000000037d5077434723d0ec21d894a52567cbe6fb2c3d800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0", "to": "0xA44151489861Fe9e3055d95adC98FbD462B948e7", "gasLimit": "0.0000000000001", "data": "0xeea9064b00000000000000000000000037d5077434723d0ec21d894a52567cbe6fb2c3d800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "value": "0.0", "chainId": 17000, "type": 2, "maxFeePerGas": "0.0000000000034557", "maxPriorityFeePerGas": "1000000" } } ``` Use `serializeTx` from the previous step to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. By broadcasting this transaction, you are delegating your restake to the EigenLayer node operator. # Overview Source: https://docs.p2p.org/docs/restaking-overview Restaking API enables automated native restaking on EigenLayer with early AVS integration access. Restaking API enables [restaking in the EigenLayer protocol](https://docs.eigenlayer.xyz/eigenlayer/restaking-guides/overview) with: * Ability to restake natively on EigenLayer in an automated way and without any manual step. * Automatically qualifying for the restaking points by EigenLayer team. * Early access to future AVS integration via our API. We provide distinct endpoints for testing and production environments. The test environment is linked to the Hoodi network (Ethereum). * PRODUCTION: [https://api.p2p.org](https://api.p2p.org) * TESTING ON HOODI: [https://api-test.p2p.org](https://api-test.p2p.org) [Get an authentication token](/docs/authentication) to start using Restaking API. # Getting started Source: https://docs.p2p.org/docs/signer-sdk-getting-started The P2P.ORG Signer SDK allows you to sign transactions for 15+ networks using a unified interface. This guide demonstrates how to configure a signer and sign an transaction using the Hoodi testnet as an example. ## 1. Installation Install the Signer SDK NPM package. Refer to [this link](https://www.npmjs.com/package/@p2p-org/signer-sdk) for more information. ## 2. Configuration To initialize a signer, you need two sets of data: your Signer Configuration (sensitive keys) and your Network Parameters (RPC and public addresses). ```javascript JavaScript theme={null} // 1. Signer Config: Contains sensitive private keys and network targeting const signerConfig = { ethereumPrivateKey: process.env.PRIVATE_KEY, // e.g., '0x...' networkName: 'hoodi', // Use 'mainnet' for production or 'hoodi' for testnet }; // 2. Network Parameters: Public data for transaction preparation const parameters = { apiBase: 'https://api-test.p2p.org/api/v1', token: 'YOUR_P2P_API_TOKEN', rpcURL: 'https://ethereum-hoodi-rpc.publicnode.com', walletAddress: '0x88bf...' }; ``` ## 3. Signing a transaction The following function illustrates the standard workflow: fetching a fresh nonce from the blockchain, initializing the factory, and signing the payload. ```javascript JavaScript theme={null} import { SignerFactory, Signers } from '@p2p-org/signer-sdk'; import { ethers } from 'ethers'; /** * @param unsignedTransactionData - The transaction object received from the Staking API */ async function signTransaction(unsignedTransactionData) { // A. Prepare the provider to fetch on-chain metadata const provider = new ethers.providers.JsonRpcProvider(parameters.rpcURL); // B. Ensure the transaction has the correct Nonce for the wallet unsignedTransactionData['nonce'] = await provider.getTransactionCount(parameters.walletAddress); // C. Create a typed signer instance using the SignerFactory // We specify 'Signers.Ethereum' to handle EVM-compatible logic const signer = SignerFactory.createSigner(Signers.Ethereum, signerConfig); // D. Sign the transaction locally // The private key never leaves your environment const signedTx = await signer.sign(unsignedTransactionData); return signedTx; } ``` # Overview Source: https://docs.p2p.org/docs/signer-sdk-overview The is a JavaScript/TypeScript library designed to handle the secure signing of blockchain transactions. While the Staking API/SDK helps you build transactions, the Signer SDK provides the tools to authorize them using various signing methods, ensuring a seamless flow from creation to broadcast. The SDK is designed for Node.js (version 20 or higher) and is distributed as an ESM-only package. ## Key Features The library provides a unified interface for different signing environments: * Secure Local Signing - Maintain absolute custody of your assets. Private keys are handled exclusively within your local environment and are never exposed to external services or the P2P.ORG API. * Unified Multi-Chain Interface - A single, consistent API for 15+ integrated blockchain networks (including Solana, Ethereum, Cosmos, and more). Switch between networks without rewriting your signing logic. * Offline Transaction Logic - Sign transactions in air-gapped or secure server-side environments. The SDK handles the heavy lifting of network-specific transaction formats and serialization. * TypeScript-First Architecture - Built with full type safety and IntelliSense support to prevent runtime errors and ensure correct transaction parameters for every protocol. * Flexible Integration - Use as a high-level SDK within your Node.js applications or as a CLI tool for manual operations and DevOps workflows. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-aptos To complete any bonding or withdrawal operation on Aptos, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `/staking/delegated/add`,`/staking/delegated/reactivate`, `/staking/delegated/withdraw`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Send the signed transaction to the Aptos network by making a POST request to [/api/v1/aptos/\{network}/transaction/send](/reference/aptos-transaction-send). Example request: ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/aptos/mainnet/transaction/send \ --header 'accept: application/json' \ --head 'Authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "transaction": "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140d386bb294c9a3ce9c8e6b49c4d6dba1bbf4d99b7803f9947bcec59855414d064bf138d29c14e884fb0e7f18c35fd39ffcae96fe767a3ddcbdc6603e407673006", "signature": "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140960e71dc383c5e0660940bbe476499ed8b64bc37efff47db1c20274f20b39d5858737269d6c7bcb1b9fc88dce0f0f7cc12b5e86516cf9f8d787827eaedf9f906" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/aptos/mainnet/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ transaction: "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140d386bb294c9a3ce9c8e6b49c4d6dba1bbf4d99b7803f9947bcec59855414d064bf138d29c14e884fb0e7f18c35fd39ffcae96fe767a3ddcbdc6603e407673006", signature: "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140960e71dc383c5e0660940bbe476499ed8b64bc37efff47db1c20274f20b39d5858737269d6c7bcb1b9fc88dce0f0f7cc12b5e86516cf9f8d787827eaedf9f906", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/aptos/mainnet/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "transaction": "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140d386bb294c9a3ce9c8e6b49c4d6dba1bbf4d99b7803f9947bcec59855414d064bf138d29c14e884fb0e7f18c35fd39ffcae96fe767a3ddcbdc6603e407673006", "signature": "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140960e71dc383c5e0660940bbe476499ed8b64bc37efff47db1c20274f20b39d5858737269d6c7bcb1b9fc88dce0f0f7cc12b5e86516cf9f8d787827eaedf9f906", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "transaction": "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140d386bb294c9a3ce9c8e6b49c4d6dba1bbf4d99b7803f9947bcec59855414d064bf138d29c14e884fb0e7f18c35fd39ffcae96fe767a3ddcbdc6603e407673006", "signature": "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140960e71dc383c5e0660940bbe476499ed8b64bc37efff47db1c20274f20b39d5858737269d6c7bcb1b9fc88dce0f0f7cc12b5e86516cf9f8d787827eaedf9f906", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/aptos/mainnet/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `transaction` — signed transaction in the hexadecimal format which needs to be broadcasted to the network. * `signature` — delegator signature of the transaction. Example response: ```json theme={null} { "result": { "network": "mainnet", "senderAddress": "0xa571a5bc9b1bfd5fe58e6e09a5be251a3299985494d022959ce206f1f23f752e", "transaction": "0x0020b92f133c8e4768d990f39853f1931eb0481ea289a985687f0b7e59e83456333140d386bb294c9a3ce9c8e6b49c4d6dba1bbf4d99b7803f9947bcec59855414d064bf138d29c14e884fb0e7f18c35fd39ffcae96fe767a3ddcbdc6603e407673006", "status": "success", "transactionHash": "0x8d80b8ed85b578eeb873731101a926221701ee48318f6c9b83895f7ac1535640", "gas": { "unitPrice": 100, "maxGasLimit": 100, "used": 100 }, "createdAt": "2023-08-24T08:14:50.455Z" }, "error": {} } ``` * `network` — Aptos network: `mainnet` or `testnet`. * `senderAddress` — transaction sender address. * `transaction` — signed transaction in hexadecimal format. * `status` — transaction status: `pending`, `success`, or `failed`. * `transactionHash` — hash of the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction. * `maxGasLimit` — maximum gas limit for the transaction. * `used` — amount of gas spent for the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-celestia To complete any staking or withdrawal operation on Celestia, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/stake`, `staking/redelegate/from`, `staking/unstake`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Celestia network by making a POST request to [/api/v1/celestia/\{network}/transaction/send](/reference/broadcast-celestia-transaction). Example request (for `celestia-mainnet-beta` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/send \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef" }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/celestia/celestia-mainnet-beta/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction which needs to be broadcasted to the network. Example response: ```json theme={null} { "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } } ``` * `status` — transaction status: `success`, `failed`. * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in TIA charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit that the transaction initiator was willing to consume for the transaction. * `transactionHash` — hash of the transaction. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-cosmos To complete any staking or withdrawal operation on Cosmos Hub, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/stake`, `staking/redelegate/from`, `staking/unstake`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Cosmos network by making a POST request to [/api/v1/cosmos/\{network}/transaction/send](/reference/broadcast-cosmos-transaction). Example request: ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/send \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef" }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction which needs to be broadcast to the network. Example response: ```json theme={null} { "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } } ``` * `status` — transaction status: `success`, `failed`. * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in ATOM charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit that the transaction initiator was willing to consume for the transaction. * `transactionHash` — hash of the transaction. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-eth Sign and broadcast Ethereum transactions built with the P2P.org Staking API. To complete a staking or withdrawal operation on Ethereum, sign the unsigned transaction provided by the Staking API and broadcast it to the network. **1. Prepare the transaction** Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/direct/tx/deposit` or `staking/direct/tx/withdrawal`. **2. Sign the transaction** Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. **3. Send the transaction** Broadcast the signed transaction to the Ethereum network by making a POST request to `/api/v1/eth/transactions`. ```bash theme={null} curl --request POST \ --url 'https://api-test.p2p.org/api/v1/eth/transactions' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data '{ "network": "hoodi", "signedTransaction": "0x02f9015483088bb081c7840198894a84754231e2830186a094917105cc314c12890d9c8224aee5af9574f871cf80b8e466792ba1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000867b22616374696f6e223a227769746864726177222c227075626b657973223a5b223078613635633030373135663565303032636439366465326264376539626631613433333130653739376230303235306262303063393833363231316135366631333235646663393535633664326338636166313333303862343739643266333839225d7d0000000000000000000000000000000000000000000000000000c080a0260d1310fecca35e62ef3c01b47fabf7af78aad0a841b38f6850fa5d2102245fa009d0e72ab14e6dfc78740c752eeee7fb8aa0676e12f3059f30149ff762a0a040" }' ``` * `network` — environment in which the transaction is processed. * `signedTransaction`— signed transaction which needs to be broadcast to the network. Example response: ```json theme={null} { "error": null, "result": { "broadcastedAt": "2026-02-05T07:12:35.851Z", "from": "0xeE6FFB3fEf95AdA9b4FA606C2Ef90A31D37b6AdB", "gas": {}, "status": "pending", "to": "0x917105CC314C12890D9C8224Aee5aF9574F871cf", "transactionHash": "0xf94d480405cf5e45a5c4361321643084ef6b7db834938018f9ef99d0d9541b4d" } } ``` * `broadcastedAt`— time of transaction being broadcasted. * `from`— sender address for this transaction. * `gas`— gas consumed to broadcast transaction. * `status`— transaction status: `pending`, `success`. * `to`— recipient address for this transaction. * `transactionHash`— hash of the transaction. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-hyperliquid To complete any staking or withdrawal operation on Hyperliquid, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an `unsignedTransaction` object from the relevant API endpoint, e.g., `/staking/transfer`, `/staking/delegate`, `/staking/undelegate`, `/staking/withdraw`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Hyperliquid network by sending a POST request to [/api/v1/hyperliquid/\{network}/transaction/send](/reference/hyperliquid-send). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/transaction/send \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "string" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/hyperliquid/testnet/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "string", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/hyperliquid/testnet/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "string", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "string", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction in the hexadecimal format which needs to be broadcasted to the network. Example response: ```json theme={null} { "result": { "createdAt": "2025-10-10T05:28:10.434Z", "network": "mainnet" }, "error": {} } ``` * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `network` — network name. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-monad To complete any operation on Monad, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an `unsignedTransaction` object from the relevant API endpoint, e.g., `/stakes/delegations`, `/stakes/undelegations`, `/stakes/withdrawals`, `/stakes/compound-rewards`, `/stakes/claim-rewards`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Monad network by sending a POST request to [/api/v2/monad/\{network}/transactions](/reference/monad-transactions-broadcast-transaction). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v2/monad/testnet/transactions \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "0x02f8758301e24004..." } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v2/monad/testnet/transactions", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "0x02f8758301e24004...", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v2/monad/testnet/transactions", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "0x02f8758301e24004...", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0x02f8758301e24004...", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v2/monad/testnet/transactions", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction in the hexadecimal format which needs to be broadcasted to the network. Example response: ```json theme={null} { "result": { "transactionHash": "0xdef456...789abc", "broadcastedAt": "2025-05-06T10:40:00.000Z" }, "error": {} } ``` * `transactionHash` — hash of the transaction. * `broadcastedAt` — timestamp of the transaction in the ISO 8601 format. # Sign the Transaction Offline Source: https://docs.p2p.org/docs/signing-transaction-offline-polkadot This guide covers some crucial details on the offline transaction signing flow, such as new extended request parameter with additional metadata. For Polkadot signing instructions, refer to the [transaction signing](/docs/signing-transaction-offline-polkadot#offline-transaction-signing) section. ## Extended metadata All Polkadot endpoints generating staking transactions now support an optional boolean parameter `extended`. When it is set to `true`, the response includes additional metadata, which can be required for offline transaction signing and external processing. ### Examples Example request with `extended: true` to [/api/v1/polkadot/\{network}/staking/bond](/reference/polkadot-staking-bond): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/bond \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "rewardDestinationType": "account", "rewardDestination": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "amount": 1, "extended": true }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/polkadot/westend/staking/bond", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", rewardDestinationType: "account", rewardDestination: "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", amount: 1, extended: true, }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/staking/bond", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "rewardDestinationType": "account", "rewardDestination": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "amount": 1, "extended": True, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "rewardDestinationType": "account", "rewardDestination": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "amount": 1, "extended": true, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/staking/bond", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` Example response: ```json theme={null} { "error": null, "result": { "unsignedTransaction": "0xa8040600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e", "unsignedTransactionSerialized": "7b2261646472657373223a22354568314336396a774e6742507470326f4b784a375a79356453364c4a6e33585a36434a485077634142326946705a51222c22626c6f636b48617368223a22307835333039616433373261623530396633363331666664666163633130633066386433396138303339616664666432353265393564653263336636653064306236222c22626c6f636b4e756d626572223a2230783031383734346262222c22657261223a22307862353033222c2267656e6573697348617368223a22307865313433663233383033616335306538663666386536323639356431636539653465316436386161333663316364326366643135333430323133663334323365222c226d65746164617461527063223a223078222c226d6574686f64223a22307830363030303730303130613564346538303337343237613764656535393263343763363837353236363335376565376166643736336464666466366264313633346534313062373333356663333833333165222c226e6f6e6365223a2230783030303030303136222c227369676e6564457874656e73696f6e73223a5b22436865636b4e6f6e5a65726f53656e646572222c22436865636b5370656356657273696f6e222c22436865636b547856657273696f6e222c22436865636b47656e65736973222c22436865636b4d6f7274616c697479222c22436865636b4e6f6e6365222c22436865636b576569676874222c224368617267655472616e73616374696f6e5061796d656e74222c22436865636b4d6574616461746148617368222c225765696768745265636c61696d225d2c227370656356657273696f6e223a2230783030306638383932222c22746970223a2230783030303030303030303030303030303030303030303030303030303030303030222c227472616e73616374696f6e56657273696f6e223a2230783030303030303162222c2276657273696f6e223a347d", "unsignedTransactionPayload": "0x0600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e", "unsignedTransactionObject": { "blockHash": "0x339985858981806fa80352e0ea533f94e5f92855296aa24b63b00fee7e40a448", "eraPeriod": 64, "currentEra": 9186, "genesisHash": "0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e", "metadataRpc": "0x", "method": { "args": { "value": "1,000,000,000,000", "payee": { "Account": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ" } }, "method": "bond", "section": "staking" }, "nonce": 22, "specVersion": 1018002, "transactionVersion": 27, "tip": 0 }, "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "rewardDestinationType": "account", "rewardDestination": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "amount": 1, "createdAt": "2025-04-17T13:25:14.508Z" } } ``` * `unsignedTransaction` — unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) in the hexadecimal format. * `unsignedTransactionSerialized` — unsigned serialized transaction containing all the data. * `unsignedTransactionPayload` — only raw payload of the unsigned transaction in the hexadecimal format. * `unsignedTransactionObject` — full decoded transaction structure with all the fields and metadata: * `blockHash`— hash of the checkpoint block in which the transaction was included. * `eraPeriod` — validity period of the transaction, representing the number of blocks following after the checkpoint for which the transaction is valid. * `currentEra` — current staking era of the transaction. * `genesisHash` — hash of the genesis block. * `metadataRpc` — serialized metadata used for offline decoding and transaction signing. * `method` is the list of data fields containing information on the method called to construct a transaction. * `nonce` — nonce of the transaction. * `specVersion` — current version of the chain specification for the runtime. * `transactionVersion` — current version of the transaction format. * `tip` — optional fee used to increase the transaction priority. * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `rewardDestinationType` — rewards destination type: * `staked` — rewards will be sent to the stash account and added to the current bond (compounding rewards). * `stash` — rewards will be sent to the stash account as a transferrable balance (not compounding rewards). * `account` — rewards will be sent to any account specified as a transferrable balance. * `rewardDestination` — rewards destination account address. * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### Supported endpoints The `extended` parameter is available for the following endpoints: * [/staking/bond](/reference/polkadot-staking-bond) * [/staking/nominate](/reference/polkadot-staking-nominate) * [/staking/pool/bond](/reference/polkadot-pool-bond) * [/staking/pool/set-claim-permission](/reference/polkadot-pool-set-claim-permission) * [/staking/pool/claim-payout](/reference/polkadot-pool-claim-payout) * [/account/add](/reference/polkadot-account-add) ## Offline transaction signing To sign the transaction offline, follow these steps: 1. Prepare the `unsignedTransactionSerialized` object. 2. Sign the transaction in your preferred way of signing. Example (for `westend` network): ```javascript theme={null} /* Instructions: 1. Install Sidecar and run with the environment variable for Substrate URL: yarn global add @substrate/api-sidecar SAS_SUBSTRATE_URL=wss://westend-ws-proxy.polka.p2p.world substrate-api-sidecar 2. Install dependencies: yarn install 3. Run the script: npx ts-node test.ts */ const API_BASE_URL = 'https://api.p2p.org'; const TOKEN = '*******'; const WS_PROVIDER_URL = 'wss://westend-ws-proxy.polka.p2p.world'; const SECRET_FILE_PATH = 'secret.json'; const TEST_PASSWORD = 'testtest'; const SIDECAR_URL = 'http://localhost:8080/transaction'; const STASH_ACCOUNT_ADDRESS = '5GW6GmWBPhbpWPwRkria91Dn8EjTxEoqVorZxE9gkvTCHVN8'; import { readFileSync } from 'fs'; import { Keyring, WsProvider } from '@polkadot/api'; import { cryptoWaitReady } from '@polkadot/util-crypto'; import { construct, getRegistry, KeyringPair, UnsignedTransaction, } from '@substrate/txwrapper-polkadot'; import { ApiPromise } from '@polkadot/api/cjs/bundle'; interface ApiResponse { result: { unsignedTransactionSerialized: string; }; } interface TransactionResponse { hash: string; } async function getBondTx(data: any): Promise { return fetchData( `${API_BASE_URL}/api/v1/polkadot/westend/staking/bond`, data ); } async function getBondExtraTx(data: any): Promise { return fetchData( `${API_BASE_URL}/api/v1/polkadot/westend/staking/bond-extra`, data ); } async function fetchData(url: string, data: any): Promise { try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json', Authorization: 'Bearer ' + TOKEN, }, body: JSON.stringify(data), }); return (await response.json()) as ApiResponse; } catch (error) { console.error('Error fetching data:', error); throw error; } } async function fetchMetadata(): Promise { const provider = new WsProvider(WS_PROVIDER_URL); const api = await ApiPromise.create({ provider }); const metadataRpc = await api.rpc.state.getMetadata(); await api.disconnect(); return metadataRpc.toHex(); } function createKeypair(): KeyringPair { const keyring = new Keyring({ type: 'sr25519' }); const keyInfo = JSON.parse(readFileSync(SECRET_FILE_PATH, 'utf8')); const sender = keyring.addFromJson(keyInfo); sender.decodePkcs8(TEST_PASSWORD); return sender; } function signTransaction(unsignTx: string, metadataRpc: `0x{string}`): string { const keypair = createKeypair(); const registry = getRegistry({ chainName: 'Polkadot', specName: 'westend', specVersion: 1018001, metadataRpc, }); const serialized = unsignTx; const jsonString = Buffer.from(serialized, 'hex').toString('utf-8'); const unsigned = JSON.parse(jsonString); const extrinsicPayload = registry.createType('ExtrinsicPayload', unsigned, { version: unsigned.version, }); const signature = extrinsicPayload.sign(keypair).signature; const rawT = construct.signedTx( unsigned as unknown as UnsignedTransaction, signature, { metadataRpc, registry, userExtensions: { SetEvmOrigin: { payload: {}, extrinsic: {} } }, } ); return rawT; } async function sendTransaction( transactionData: string ): Promise { try { const response = await fetch(SIDECAR_URL, { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ tx: transactionData }), }); return (await response.json()) as TransactionResponse; } catch (error) { console.error('Error sending transaction:', error); throw error; } } void (async () => { await cryptoWaitReady(); // Get Bond Transaction const unsignTx = await getBondTx({ stashAccountAddress: STASH_ACCOUNT_ADDRESS, rewardDestinationType: 'account', rewardDestination: STASH_ACCOUNT_ADDRESS, amount: 1, extended: true, }); /* // Get Bond Extra Transaction const unsignTx = await getBondExtraTx({ stashAccountAddress: STASH_ACCOUNT_ADDRESS, amount: 0.001, extended: true, }); */ console.log('unsignTx', unsignTx); // Fetch Metadata const metadataRpc = await fetchMetadata(); // Sign Transaction const signTx = signTransaction( unsignTx.result.unsignedTransactionSerialized, metadataRpc as `0x{string}` ); console.log('signTx', signTx); // Send Signed Transaction const result = await sendTransaction(signTx); console.log('result', result); })(); ``` # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-polkadot To complete any bonding or withdrawal operation on Polkadot, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/bond`,`staking/nominate`, `staking/withdraw-unbonded`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the transaction to the Polkadot network by sending a POST request to [/api/v1/polkadot/\{network}/tx/send](/reference/polkadot-transaction-send). Example request (for `westend` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/tx/send \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "0x450284002c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f01befdb7fa39c5a995a8d58676a0513d082be" }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/polkadot/westend/tx/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "0x450284002c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f01befdb7fa39c5a995a8d58676a0513d082be", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/tx/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "0x450284002c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f01befdb7fa39c5a995a8d58676a0513d082be", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0x450284002c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f01befdb7fa39c5a995a8d58676a0513d082be", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/tx/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction (A transaction that has been digitally signed by the sender using their private key.) in hex format. Example response: ```json theme={null} { "result": { "status": "success", "blockHash": "0x0628743b05ffb4c9d5ea2144b359af38910f0ae439a685f57d85b50b9481ba3f", "blockId": "17168395", "extrinsicId": "0xb838911d5a5f965f33b8ee134e1115b5b9902abfc567f0c3050073faf9d3c3e0", "transactionHash": "0x450284002c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f01befdb7fa39c5a995a8d58676a0513d082be", "signerAccount": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "createdAt": "2023-08-15T15:07:54.795Z" } } ``` * `staus` — transaction status. * `blockHash` — block hash in which the transaction was included. * `blockId` — unique block identifier. * `extrinsicId` — unique extrinsic (On Polkadot and Avail, a SCALE encoded array consisting of a version number, signature, and varying data types indicating the resulting runtime function to be called, including the parameters required for that function to be executed. These state changes are invoked from the outside world, i.e., they are not part of the system itself. Extrinsics can take two forms, “inherents” and “transactions”.) identifier. * `transactionHash` — signed transaction in hex format. * `signerAccount` — account that signed the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-polygon ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/approve`, `staking/delegate`, `staking/unstake`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Send the signed transaction to the Ethereum network by making a POST request to [/api​/v1​/polygon​/transaction​/send](/reference/polygon-transaction-send). Example request: ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polygon/transaction/send \ --head 'accept: application/json' \ --head 'Authorization: Bearer ' \ --head 'Content-Type: application/json' \ --data ' { "signedTransaction": "0x02f902d705808301674e8508530af16e830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aa5f27070a21d79455c4a9b73c0aa4a8b1a65a1fb530d7fd8e6cd23aa16660679ac43ee4861098f6d9166aed3a4d8abb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002001000000000000000000000028c84612d37de9209018ad96167f12169b653e9a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060978c565cd915f4e885b4201093d1501697610eb9ee99b9b60b70434dc330e98d5b42927725304ded48483a8b8f39506d09bcb22ee18d4f6b50257946ac5ee360385308d95c0e2bc963902d42e985c29ee489aa3c989ac1561c952a6424f107a800000000000000000000000000000000000000000000000000000000000000014cb452f6e3f10ba2175c86a0284f53fcb61404b458393391abc3d5622e3e55cdc0", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/polygon/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "0x02f902d705808301674e8508530af16e830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aa5f27070a21d79455c4a9b73c0aa4a8b1a65a1fb530d7fd8e6cd23aa16660679ac43ee4861098f6d9166aed3a4d8abb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002001000000000000000000000028c84612d37de9209018ad96167f12169b653e9a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060978c565cd915f4e885b4201093d1501697610eb9ee99b9b60b70434dc330e98d5b42927725304ded48483a8b8f39506d09bcb22ee18d4f6b50257946ac5ee360385308d95c0e2bc963902d42e985c29ee489aa3c989ac1561c952a6424f107a800000000000000000000000000000000000000000000000000000000000000014cb452f6e3f10ba2175c86a0284f53fcb61404b458393391abc3d5622e3e55cdc0", stakerAddress: "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polygon/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "0x02f902d705808301674e8508530af16e830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aa5f27070a21d79455c4a9b73c0aa4a8b1a65a1fb530d7fd8e6cd23aa16660679ac43ee4861098f6d9166aed3a4d8abb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002001000000000000000000000028c84612d37de9209018ad96167f12169b653e9a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060978c565cd915f4e885b4201093d1501697610eb9ee99b9b60b70434dc330e98d5b42927725304ded48483a8b8f39506d09bcb22ee18d4f6b50257946ac5ee360385308d95c0e2bc963902d42e985c29ee489aa3c989ac1561c952a6424f107a800000000000000000000000000000000000000000000000000000000000000014cb452f6e3f10ba2175c86a0284f53fcb61404b458393391abc3d5622e3e55cdc0", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0x02f902d705808301674e8508530af16e830186a094681a1b3441c6bfb12f91651efd9f02c83c0702938901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030aa5f27070a21d79455c4a9b73c0aa4a8b1a65a1fb530d7fd8e6cd23aa16660679ac43ee4861098f6d9166aed3a4d8abb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002001000000000000000000000028c84612d37de9209018ad96167f12169b653e9a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060978c565cd915f4e885b4201093d1501697610eb9ee99b9b60b70434dc330e98d5b42927725304ded48483a8b8f39506d09bcb22ee18d4f6b50257946ac5ee360385308d95c0e2bc963902d42e985c29ee489aa3c989ac1561c952a6424f107a800000000000000000000000000000000000000000000000000000000000000014cb452f6e3f10ba2175c86a0284f53fcb61404b458393391abc3d5622e3e55cdc0", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polygon/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — serialized signed transaction. * `stakerAddress` — staker account address. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-sei To complete any staking or withdrawal operation on Sei, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/stake`, `staking/redelegate/from`, `staking/unstake`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Sei network by making a POST request to [/api/v1/sei/\{network}/transaction/send](/reference/broadcast-sei-transaction). Example request (for `atlantic-2` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/send \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef" }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction which needs to be broadcast to the network. Example response: ```json theme={null} { "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } } ``` * `status` — transaction status: `success`, `failed`. * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in SEI charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit that the transaction initiator was willing to consume for the transaction. * `transactionHash` — hash of the transaction. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-solana To complete any staking or withdrawal operation on Solana, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned transaction in Base64 encrypted format from the relevant API endpoint, e.g., `/staking/stake`, `/staking/deactivate` or `/staking/withdraw`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Send the signed transaction to the Solana network by making a POST request to [/api/v1/solana/\{network}/tx/send](/reference/solana-staking-send). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/solana/testnet/tx/send \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+jagnMHpK8BDHt0PpssHwXGD2fBxS6MWBoxptD2u9TvrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NjSeWM5+GSJdoQd43Al9SVVXC9FfWGwbe7icpomwAUGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAijW940iwWddz25ZC37fI0ue5fa+eTbC2ynBM3b0t4pcDAgMAAQBgAwAAAI5ELeF3F+N1ZPBWe0G1FV0heaKPY7e8dg5tBPbrf8voBAAAAAAAAABzZWVkgJaYAAAAAADIAAAAAAAAAAah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABAIBB3QAAAAAjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+iORC3hdxfjdWTwVntBtRVdIXmij2O3vHYObQT263/L6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQGAQMGCAUABAIAAAA=" }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/solana/testnet/tx/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+jagnMHpK8BDHt0PpssHwXGD2fBxS6MWBoxptD2u9TvrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NjSeWM5+GSJdoQd43Al9SVVXC9FfWGwbe7icpomwAUGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAijW940iwWddz25ZC37fI0ue5fa+eTbC2ynBM3b0t4pcDAgMAAQBgAwAAAI5ELeF3F+N1ZPBWe0G1FV0heaKPY7e8dg5tBPbrf8voBAAAAAAAAABzZWVkgJaYAAAAAADIAAAAAAAAAAah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABAIBB3QAAAAAjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+iORC3hdxfjdWTwVntBtRVdIXmij2O3vHYObQT263/L6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQGAQMGCAUABAIAAAA=", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/solana/testnet/tx/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+jagnMHpK8BDHt0PpssHwXGD2fBxS6MWBoxptD2u9TvrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NjSeWM5+GSJdoQd43Al9SVVXC9FfWGwbe7icpomwAUGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAijW940iwWddz25ZC37fI0ue5fa+eTbC2ynBM3b0t4pcDAgMAAQBgAwAAAI5ELeF3F+N1ZPBWe0G1FV0heaKPY7e8dg5tBPbrf8voBAAAAAAAAABzZWVkgJaYAAAAAADIAAAAAAAAAAah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABAIBB3QAAAAAjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+iORC3hdxfjdWTwVntBtRVdIXmij2O3vHYObQT263/L6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQGAQMGCAUABAIAAAA=", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+jagnMHpK8BDHt0PpssHwXGD2fBxS6MWBoxptD2u9TvrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NjSeWM5+GSJdoQd43Al9SVVXC9FfWGwbe7icpomwAUGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAijW940iwWddz25ZC37fI0ue5fa+eTbC2ynBM3b0t4pcDAgMAAQBgAwAAAI5ELeF3F+N1ZPBWe0G1FV0heaKPY7e8dg5tBPbrf8voBAAAAAAAAABzZWVkgJaYAAAAAADIAAAAAAAAAAah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABAIBB3QAAAAAjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+iORC3hdxfjdWTwVntBtRVdIXmij2O3vHYObQT263/L6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQGAQMGCAUABAIAAAA=", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/solana/testnet/tx/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction in Base64 encrypted format. Example response: ```json theme={null} { "result": { "transactionId": "0x0628743b05ffb4c9d5ea2144b359af38910f0ae439a685f57d85b50b9481ba3f", "slot": 17168395, "signerAccounts": [ "C83GxcNFTC2tK22rLCCrLKYRkckbNVGsjethN5iswgfC" ], "createdAt": "2023-08-15T15:07:54.795Z" } } ``` * `transactionId` — block hash in which the transaction was included. * `slot` — period of time during which each leader collects transactions and creates a block in the Solana network. * `signerAccounts` — account addresses that signed the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-story To complete any staking or withdrawal operation on Story Protocol, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Obtain the `unsignedTransaction` object provided by a transaction builder or the relevant Staking API endpoint, e.g., `/staking/stake` or `/staking/withdraw`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Send the signed transaction to the Story network by making a POST request to [/api/v1/story/\{network}/tx/send](/reference/story-transaction-send). Example request (for `aeneid` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/story/aeneid/tx/send \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "signedTransaction": "" }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/story/aeneid/tx/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/story/aeneid/tx/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/story/aeneid/tx/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction in the hexadecimal format. Example response: ```json theme={null} { "result": { "transactionId": "0xadcba25d1bcedaa2fd17ff5db6b45d5e7060cf3a3c17e263feebf7b460f742c9", "signerAccounts": [ "0x3202B5B0602274197CcB22B8c02CEC9539990c7c" ], "createdAt": "2025-07-22T14:08:23.456Z" } } ``` * `transactionId` — hash of the transaction included in the Story Protocol chain. * `signerAccounts` — list of account addresses that signed the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-sui To complete any staking or withdrawal operation on Sui, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unsigned serialized transaction from the relevant API endpoint, e.g., `staking/stake` or `staking/withdraw`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Sui network by sending a POST request to [/api/v1/sui/\{network}/transaction/send](/reference/sui-transaction-send). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/sui/testnet/transaction/send \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "transaction": "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p", "signature": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/sui/testnet/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ transaction: "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p", signature: "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/sui/testnet/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "transaction": "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p", "signature": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "transaction": "0x1f2e3d4c5b6a7e8f9a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6b7c8d9e0f1g2h3i4j5k6l7m8n9o0p", "signature": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/sui/testnet/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction in the hexadecimal format which needs to be broadcasted to the network. * `signature` — signature of the staker account address. Example response: ```json theme={null} { "error": null, "result": { "transactionDigest": "DiXajfAeTLVhiQZuW8aH2UD1XsCEoZVH4twRC5PjeK5" } } ``` * `transactionDigest` — hash of the transaction. Use the `transactionDigest` object to check the transaction status via [explorer](https://suiscan.xyz/testnet/home), e.g., [example of the broadcasted transaction](https://suiscan.xyz/testnet/tx/DiXajfAeTLVhiQZuW8aH2UD1XsCEoZVH4twRC5PjeK5). # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-ton To complete any staking or withdrawal operation on TON, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Retrieve an unserialized transaction data from the relevant API endpoint, e.g., `single-nominator/stake`, `ton-whales/unstake`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the transaction to the network by sending a POST request to [/api/v1/ton/\{network}/transactions/broadcast](/reference/ton-staking-broadcast). Example request (for the `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/ton/testnet/transactions/broadcast \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "walletVersion": "V4", "unsignedTransaction": "te6ccgEBAQEABgAACCiAmCM=", "signature": "te6ccgEBAQEABgAACCiAmCM=", "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6" } ' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api.p2p.org/api/v1/ton/testnet/transactions/broadcast", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ walletVersion: "V4", unsignedTransaction: "te6ccgEBAQEABgAACCiAmCM=", signature: "te6ccgEBAQEABgAACCiAmCM=", publicKey: "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/ton/testnet/transactions/broadcast", headers={ "Content-Type": "application/json", }, json={ "walletVersion": "V4", "unsignedTransaction": "te6ccgEBAQEABgAACCiAmCM=", "signature": "te6ccgEBAQEABgAACCiAmCM=", "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "walletVersion": "V4", "unsignedTransaction": "te6ccgEBAQEABgAACCiAmCM=", "signature": "te6ccgEBAQEABgAACCiAmCM=", "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/ton/testnet/transactions/broadcast", bytes.NewBuffer(body)) req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction (A transaction that has been digitally signed by the sender using their private key.) in the hexadecimal format which needs to be broadcasted to the network. * `signature` — external message signature, which has to be signed with the private key. * `publicKey` — public key of the nominator for the TON network. * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. Example response: ```json theme={null} { "error": null, "result": { "extraData": { "messageHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" } } } ``` * `messageHash` — hash of the transaction. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/signing-transaction-tron To complete any operation on Tron, sign the unsigned transaction provided by the Staking API and broadcast it to the network. ## 1. Prepare the transaction Obtain the `unsignedTransaction` object provided by a transaction builder or the relevant API endpoint, e.g., `/staking/delegate`, `/staking/vote`, `/staking/undelegate`. ## 2. Sign the transaction Use the [P2P Signer SDK](/docs/signer-sdk-overview) to sign the unsigned data following protocol specific configuration. ## 3. Send the transaction Broadcast the signed transaction to the Celestia network by making a POST request to [/api/v1/tron/\{network}/transaction/send](/reference/tron-transaction-send). Example request: ```bash curl theme={null} curl --request POST \ --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/send' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "signedTransaction": "0x7b2276697369626c65223a66616c73652c2274784944223a22..." }' ``` ```typescript TypeScript theme={null} const response = await fetch("https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/send", { method: "POST", headers: { "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ signedTransaction: "0x7b2276697369626c65223a66616c73652c2274784944223a22...", }), }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/send", headers={ "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "signedTransaction": "0x7b2276697369626c65223a66616c73652c2274784944223a22...", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "signedTransaction": "0x7b2276697369626c65223a66616c73652c2274784944223a22...", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/send", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `signedTransaction` — signed transaction in the hexadecimal which needs to be broadcasted to the network. Example response: ```json theme={null} { "error": null, "result": { "transactionHash": "c8e47301ca1d4a56120e6f13f0ce5f8a680e2fda221b3d8bc423cc355f924a70", "createdAt": "2025-07-04T09:01:10.000Z", "network": "testnet-nile", "senderAddress": "41da53d324a354aa5924c7117caff3ead97910a5e1", "block": null, "status": "PENDING", "gas": { "bandwidthUsed": 0, "energyUsed": 0 } } } ``` * `transactionHash` — hash of the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `network` — identifier of the TRON network (e.g., `mainnet`, `testnet-nile`). * `senderAddress` — address of the transaction sender in the base58 format. * `block` — unique identifier of the block in which the transaction has been included. `null`, if still pending. * `status` — transaction status: `PENDING`, `FAILED` or `CONFIRMED`. * `gas` — resources consumed by the transaction depending on their type: * `bandwidthUsed` — amount of bandwidth points consumed by the transaction. * `energyUsed` — amount of energy points consumed by the transaction. To check the transaction status, use the transaction hash in explorers like [Tronscan](https://nile.tronscan.org/). # Overview Source: https://docs.p2p.org/docs/ssv-31-overview SSV 3.1 provides seamless integration for initiating DVT staking requests using the SSV proxy smart contract developed by P2P.org. By integrating with our smart contract on-chain solution, your platform can offer SSV staking without the need to handle $SSV tokens. Our smart contract manages all the $SSV tokens while you retain full control over the assets that you stake. You can check the details of our SSV proxy smart contract in [this GitHub link](https://github.com/p2p-org/p2p-ssv-proxy). ## Key Benefits * **Reduced Complexity**: Start offering a new staking flow to your users with the security advantages of DVT. While the native staking flow requires you to manage \$SSV token to register validators, our on-chain integration solution removes that pain point by providing a seamless staking flow. * **Risk Mitigation**: Our strategically designed cluster minimizes risks by distributing validators across diverse locations and client software, ensuring your operations are safeguarded against single points of failure and regionalized threats. * **Operational Efficiency**: Embrace the ease of automated integration with our API, designed to align with the SSV protocol, reducing your operational overhead and simplifying the staking process for your clients. By seamlessly integrating SSV 3.1 into your systems, you can enhance your offering and simplify the staking process for your customers. We provide two distinct endpoints for testing and production environments. The test environment is linked to the Hoodi network (Ethereum). * PRODUCTION: [https://api.p2p.org](https://api.p2p.org) * TESTING ON HOODI: [https://api-test.p2p.org](https://api-test.p2p.org) # Getting Started Source: https://docs.p2p.org/docs/staking-cosmos Stake on Cosmos programmatically with the P2P.org Staking API. Staking in the Cosmos network using the Staking API consists of several main steps: 1. Create a staking request. 2. Sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create staking request** Send a POST request to [/api/v1/cosmos/\{network}/staking/stake](/reference/create-cosmos-stake-transaction). Example request: ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/staking/stake \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "memo": "This is your memo message", "amount": 0.00420 }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/staking/stake", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", memo: "This is your memo message", amount: 0.00420, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/staking/stake", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "memo": "This is your memo message", "amount": 0.00420, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "memo": "This is your memo message", "amount": 0.00420, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/staking/stake", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — delegator (A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.) stash account address which keeps tokens. * `memo` — arbitrary text data to add to the transactions. * `amount` — amount of tokens to stake in ATOM. Example response: ```json theme={null} { "error": null, "result": { "amount": 0.0042, "currency": "atom", "validatorAddress": "cosmosvaloper17lgg03ze9x6xka02fs0hhw4ad4wwg05heqr2y8", "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "rewardDestinationAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "transactionData": { "messages": [ { "typeUrl": "/cosmos.staking.v1beta1.MsgDelegate", "value": { "delegatorAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "validatorAddress": "cosmosvaloper17lgg03ze9x6xka02fs0hhw4ad4wwg05heqr2y8", "amount": { "denom": "uatom", "amount": "4200" } } } ], "fee": { "amount": [ { "amount": "5953", "denom": "uatom" } ], "gas": "238098" }, "memo": "The message", "encodedBody": "0a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d657373616765", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801182312130a0d0a057561746f6d1204353935331092c40e" }, "createdAt": "2023-11-02T11:21:40.810Z" } } ``` * `amount` — amount of tokens to stake. * `currency` — currency of tokens: * `atom` — ATOM, Cosmos native staking token. * `uatom` — 1 ATOM = 10⁶ uATOM, * `matom` — 1 ATOM = 10³ mATOM. * `validatorAddress` — validator (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.) address to which tokens are delegated. * `stashAccountAddress` — delegator stash account address which keeps tokens. * `rewardDestinationAddress` — reward destination account address. * `createdAt` — timestamp of the transaction in the ISO 8601 format. `transactionData` is the list of data fields to be used to construct the staking transactions: * `messages`: * `typeUrl` — Cosmos network operation type. * `delegatorAddress` — delegator address. * `validatorAddress` — validator address. * `amount` — amount of tokens to stake. * `currency` — currency of tokens. * `fee` — fee charged for the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `atom`, `uatom`, or `matom`. * `gas` — amount of gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. **2. Sign and Send Transaction** Use `transactionData` to [sign and send](/docs/signing-transaction-cosmos) the signed transaction to the Cosmos network. To check the transaction status, send a GET request to [/api/v1/cosmos/\{network}/transaction/status/\{transactionHash}](/reference/get-cosmos-transaction-status). Example request: ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `transactionHash` — hash of the transaction. Example response: ```json theme={null} { "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } } ``` * `status` — transaction status: `success`, `failed`. * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in ATOM charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit that the transaction initiator was willing to consume for the transaction. * `transactionHash` — hash of the transaction. # Getting Started Source: https://docs.p2p.org/docs/staking-ethereum Stake on Ethereum programmatically with the P2P.org Staking API. To start staking on the Ethereum network using the Staking API: 1. Set up nodes for staking using P2P infrastructure. 2. Check the status of the node set-up operation. 3. Construct a serialized transaction to deposit the stake amount with a smart contract. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). > [!WARNING] > > **Please note** > > On May 7, 2025, the major Ethereum network upgrade was carried out that brought many benefits for clients who use ETH or SSV validators. **P2P.ORG recommends** upgrading to the `0x02` withdrawal credentials to enhance your functionality. It can be done in two ways: > > * By [consolidating multiple existing validators](/docs/validator-consolidation) into a single one > * By [creating a new `0x02`-enabled validator](/docs/initial-staking) via simplified 3.1 integrators with smart contract flow > allowlists > > For more details, see [Pectra Upgrade overview](/docs/pectra-overview). > > However, upgrading to the new address format is not necessary, all existing endpoints remain supported. You can follow the `0x01` creation flow below, if you need fine-grained control over validator count, effective balance per validator, or you intend to manually broadcast deposit transactions. **1. Create setting-up node request** 1. Prepare`id` that is an arbitrary UUID. Generate it in one of the following ways: * [Online UUID Generator](https://www.uuidgenerator.net/) * [uuid npm package](https://www.npmjs.com/package/uuid) 2. Set up staking nodes through the P2P infrastructure by sending a POST request to [/api/v1/eth/staking/direct/nodes-request/create](/reference/eth-nodes-request-create). Use [https://api-test.p2p.org](https://api-test.p2p.org) for testing or [https://api.p2p.org](https://api.p2p.org) for production. Example request: ```bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/create \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "id": "3611b95c-e1b3-40c0-9086-3de0a4379943", "type": "REGULAR", "validatorsCount": 2, "amountPerValidator": "32000000000", "withdrawalCredentialsType": "0x01", "withdrawalAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "eigenPodOwnerAddress": "", "controllerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "feeRecipientAddress": "0x53da3c92fCCEb0CFE1764f65DDfF1564A2b15585", "nodesOptions": { "location": "any", "relaysSet": "" } }' ``` * `id` — arbitrary UUID. You can later use that UUID to check the status of the set-up operation. * `type` — staking operation type: * `REGULAR`— default value for native staking transactions. Set the `REGULAR` operation type for this flow. * `RESTAKING`— value that is used to initiate a [restaking operation](/docs/restaking-overview) with the EigenPod address. * `MANAGED_SSV`— value that is used to initiate a managed SSV cluster. * `validatorsCount` — number of validators. One validator is equal to 32 ETH. * `amountPerValidator` — amount of tokens to stake in Gwei per validator. Note that if the amount is more than 32 ETH (1 ETH = 10⁹ Gwei), the `withdrawalCredentialsType` parameter defaults to `0x02`. * `withdrawalCredentialsType` — withdrawal credentials preferred format: `0x01` or `0x02`. * `withdrawalAddress` — withdrawal address for the validators. * `eigenPodOwnerAddress` — owner of the EigenPod address. Used in the [restaking flow](/docs/restaking-eth). * `feeRecipientAddress` — fee recipient address. * `controllerAddress` — controller address (On Ethereum, we introduced the controller address entity to provide greater flexibility and maintain high-level security during the withdrawal flow. When the user requests the validator withdrawal, only authorized addresses can initiate this request by calling our withdrawal smart contract. The authorized addresses are the withdrawal address and the controller address. Since many users prefer not to use the withdrawal address to interact with smart contracts, a second authorized address can be specified as controller address in the new staking request.) for the validators. * `nodesOptions`: * `location` — node location. Currently, only `any` is supported. * `relaysSet` — Miner Extractable Value (MEV (Miner Extractable Value Relay Selection is a process of selecting a validator to participate in the next Ethereum block based on the value that they can extract from transactions in that block.)) relay selection. Example response: ```json theme={null} { "error": null, "result": true } ``` **2. Check request status** After setting up the node, check the status of the node set-up operation by sending a GET request to [/api/v1/eth/staking/direct/nodes-request/status/\{id}](/reference/eth-nodes-request-status) . You must poll this until status is `ready`. Example request: ```bash theme={null} curl --request GET \ --url https://api.p2p.org/api/v1/eth/staking/direct/nodes-request/status/3611b95c-e1b3-40c0-9086-3de0a4379943 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` * `id` — UUID that was specified in the node set-up request. Example response: ```json theme={null} { "error": null, "result": { "status": "ready", "amountPerValidator": "32000000000", "withdrawalCredentialsType": "0x01", "depositData": [ { "pubkey": "0xac1e9969d7b87f3102549ab41558136674a7306b85b9f73cfbd7d9fdb7db85724569da3ebd4d7de9689f6ac058d7e2a3", "signature": "0xb656f9c771166c82a7891b930e6a920878d9736eb3f9f241753a15ea69d8e2f20a3740dfaf546c70e31bd323e14b341205d04e3227dd4cf2923644a375f6792875ac02c5f256f7a17c96b09bafcbce7e4443e1862356b1e90d78875d78e9a742", "withdrawalCredentials": "0100000000000000000000005cef11327af4104ba0f8a82fbb8628caee7cb1e3", "amount": 32000000000, "depositDataRoot": "0xba013b4950b9aff0c3c19017ec5b6e0ed5b957b36f6ff03a545e5cc5605baff8", "depositMessageRoot": "6a572503239cd1f11998af7901c0947fe36eb8efec080f22598d607d3938c1a8", "forkVersion": "10000910", "eth2NetworkName": "hoodi", "depositCliVersion": "2.7.0" }, { "pubkey": "0xbe5E9c3Bb9eba1BF4C5eC1c1cbcF85ee2CE2fEC66Ce5460C23eF82332A044FDCabF7011F588CCbD77E73CCe6c4accDF0", "signature": "0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88", "withdrawalCredentials": "010000000000000000000000515ea819fde1c0d36eb8e78e9a69dbf8e4a21", "amount": 32000000000, "depositDataRoot": "0x53da3c92fCCEb0CFE1764f65DDfF1564A2b15585", "depositMessageRoot": "0x2b1c6bbdeadb0b23ca8260a819fde1c0b0347b0fd42c33a9b2513b36d6521dc6", "forkVersion": "10000910", "eth2NetworkName": "hoodi", "depositCliVersion": "2.7.0" } ] } } ``` * `status` — current status of the nodes request: * `init` — node request was created. * `processing` — node request is in progress. * `ready` — backend has the deposit data for the node request. * `cancel` — something went wrong, and the deposit data was not created. * `amountPerValidator` — amount of tokens to stake in Gwei per validator. * `withdrawalCredentialsType` — withdrawal credentials preferred format: `0x01` or `0x02`. * `depositData`: * `pubkey` — validator public key. * `signature` — validator signature. * `withdrawalCredentials`— withdrawal address credentials, passed in the expected format by the Ethereum deposit smart contract. * `amount` — amount of ETH, denominated in Gwei, that is being deposited. * `depositDataRoot` — SHA-256 hash of the SSZ-encoded `depositData` object. Used as a protection against malformed input. * `depositMessageRoot` — cryptographic hash of the Merkle tree’s root, ensuring the integrity and authenticity of the deposit data. * `forkVersion` — version of the network fork that the deposit is intended for. It helps in aligning the deposit with a specific version of the protocol. * `eth2NetworkName` — name of the Ethereum 2.0 network where the deposit is made. * `depositCliVersion` — version of the deposit command-line interface (CLI) tool that was used to generate the deposit data. **3. Prepare staking transaction** After setting up the nodes and successfully generating the `depositData`, retrieve it and proceed with make the deposit. There are two flows to make a deposit: | Workflow | Best For | Logic | | - | - | - | | Simplified Smart Contract | Most Users | Uses P2P proxy contract to handle registration and deposit in one flow. | | Direct Interaction | Power Users | Manually interacting with the Ethereum Deposit Contract for fine-grained control. | ### [P2P Proxy deposit](/docs/direct-staking#p2p-direct-staking-v1-eth2-depositor--message-sender-flow) Create a serialized transaction for depositing the stake amount and send it as a POST request to [/api/v1/eth/staking/direct/tx/deposit](/reference/eth-staking-deposit). ```bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/direct/tx/deposit \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data '{ "withdrawalAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", "depositData": [ { "pubkey": "0xac1e9969d7b87f3102549ab41558136674a7306b85b9f73cfbd7d9fdb7db85724569da3ebd4d7de9689f6ac058d7e2a3", "signature": "0xb656f9c771166c82a7891b930e6a920878d9736eb3f9f241753a15ea69d8e2f20a3740dfaf546c70e31bd323e14b341205d04e3227dd4cf2923644a375f6792875ac02c5f256f7a17c96b09bafcbce7e4443e1862356b1e90d78875d78e9a742", "withdrawalCredentials": "0100000000000000000000005cef11327af4104ba0f8a82fbb8628caee7cb1e3", "depositDataRoot": "0xba013b4950b9aff0c3c19017ec5b6e0ed5b957b36f6ff03a545e5cc5605baff8", "amount": 32000000000 }, { "pubkey": "0xbe5E9c3Bb9eba1BF4C5eC1c1cbcF85ee2CE2fEC66Ce5460C23eF82332A044FDCabF7011F588CCbD77E73CCe6c4accDF0", "signature": "0x83D2E925AEAEdcB18db983Bd447db0BFc1Ee9a6Ead118E5BEfeBcb24BA8C0efd3BD19Cb1cE8e807Fc980a67bBbf8b11e039efe2DB71fcdF096fccac5B04dF80f6a1804cd8d492455D30abE27FcDbDA78AFE61856cad65ffF5cA48Ed4776edd88", "withdrawalCredentials": "010000000000000000000000515ea819fde1c0d36eb8e78e9a69dbf8e4a21", "depositDataRoot": "0x53da3c92fCCEb0CFE1764f65DDfF1564A2b15585", "amount": 32000000000 } ] }' ``` * `withdrawalAddress` — withdrawal address for the validators. * `depositData`: * `pubkey` — validator public key. * `signature` — validator signature. * `withdrawalCredentials`— withdrawal address credentials, passed in the expected format by the Ethereum deposit smart contract. * `depositDataRoot` — hash of the deposit data. Example response: ```json theme={null} { "error": null, "result": { "serializeTx": "0x02f902d9824268808402718e18847c8ca34c830186a09494edf7e950fa01baa44a8690cac64264cdb7ca7c8901bc16d674ec800000b902a44f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000308c0bbe942f40bf50895da668c95fb1feede465ab175d5f93e00a8c33d146584f7f4ee4f963d317844be5d552135b595a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020010000000000000000000000338ef19fa2ec0fc4d1277b1307a613fa1fbbc0cb000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060ac5b5e49f647d6107d71a08e255bfead1c5c42375f50e5301ffa4f5e36a8ccf159e3a594069375aef5dd2a23718634950f99947f24e67cc7a84c9f805849a7b0ac5ca732e63cca1f876dbac7e0efc8000a0f19e04bf5df80c7131d30cf45e8f3000000000000000000000000000000000000000000000000000000000000000101a591baee083825d59d36f06b4d0fbd55688ed81b337819a2bf145cb8a2a022c0", "to": "0x94EDf7e950fA01bAa44a8690cAC64264cdB7cA7c", "gasLimit": "100000", "data": "0x4f498c730000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000308c0bbe942f40bf50895da668c95fb1feede465ab175d5f93e00a8c33d146584f7f4ee4f963d317844be5d552135b595a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020010000000000000000000000338ef19fa2ec0fc4d1277b1307a613fa000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000060ac5b5e49f647d6107d71a08e255bfead1c5c42375f50e5301ffa4f5e36a8ccf159e3a594069375aef5dd2a23718634950f99947f24e67cc7a84c9f805849a7b0ac5ca732e63cca1f876dbac7e0efc8000a0f19e04bf5df80c7131d30cf45e8f3000000000000000000000000000000000000000000000000000000000000000101a591baee083825d59d36f06b4d0fbd55688ed81b337819a2bf145cb8a2a022", "value": "64000000000000000000", "chainId": 560048, "type": 2, "maxFeePerGas": "2221240288", "maxPriorityFeePerGas": "79693564" } } ``` * `serializeTx` — serialized unsigned transaction. * `to` — recipient address for this transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. Use `serializeTx` from the previous step to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. By broadcasting this transaction, you are depositing the required stake amount in the Ethereum deposit smart contract by using the P2P smart contract as a proxy. ### Ethereum direct deposit Use this if you prefer to interact with the official Ethereum contract without a proxy. 1. Take the pubkey, signature, and depositDataRoot from the deposit-data response. 2. Go to the [Official Ethereum Deposit Contract](https://etherscan.io/address/0x00000000219ab540356cBB839Cbe05303d7705Fa) 3. Manually execute the `deposit` function with your 32 ETH and the provided data. After your deposit is successful, your validator will enter the activation queue and soon start performing the validator tasks. ## Smart contracts ### Current addresses > Returned by the API endpoint; forwards to Beacon DepositContract. * [Mainnet](https://etherscan.io/address/0xa6cf239220a8a9939d3207dfd8f26cd5e4f36ae6) `0xa6cf239220a8a9939d3207dfd8f26cd5e4f36ae6` * [Hoodi](https://hoodi.etherscan.io/address/0xda2934020efd473fac5cd73bdde440a719bf4c59) `0xda2934020efd473fac5cd73bdde440a719bf4c59` ### Previous addresses > Direct on-chain deposits (v1), still accepted. * [Mainnet](https://etherscan.io/address/0x4ca21e4d3a86e7399698f88686f5596dbe74adeb) `0x4ca21e4d3a86e7399698f88686f5596dbe74adeb` * [Hoodi](https://hoodi.etherscan.io/address/0x375e183efA05fb2bb66Cd0e7C3a05D9942046612) `0x375e183efA05fb2bb66Cd0e7C3a05D9942046612` [Github](https://github.com/p2p-org/p2p-eth2-depositor/blob/main/src/P2pEth2Depositor.sol) [Audit](https://github.com/mixbytes/audits_public/tree/master/P2P.org/ETH2%20Depositor%20%26%20ETH%20Staking%20Fee%20Distributor%20\(v.1\)) # Getting Started Source: https://docs.p2p.org/docs/staking-hyperliquid Stake on Hyperliquid programmatically with the P2P.org Staking API. Staking on the Hyperliquid network using the Staking API consists of several main steps: 1. Transfer tokens from the spot to the staking balance. 2. Create a delegate request. After each step, sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant HyperCore Client->>P2P API: Create transfer transaction (spot → staking) P2P API-->>Client: Unsigned transfer transaction Client->>Client: Sign transaction locally Client->>HyperCore: Broadcast transfer transaction HyperCore-->>Client: Transfer confirmed Client->>P2P API: Create delegate transaction P2P API-->>Client: Unsigned delegate transaction Client->>Client: Sign transaction locally Client->>HyperCore: Broadcast delegate transaction HyperCore-->>Client: Delegation confirmed ``` **1. Transfer tokens to staking balance** Since staking on Hyperliquid happens within [HyperCore](https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore), the HYPE tokens are required to be in the staking balance. Just like USDC can be transferred between perps (Perpetual contracts, or perps, allow making operations with an asset with no expiration date so that traders can use leverage and take positions larger than their account balance.) and spot accounts, HYPE can be transferred between spot and staking balances. 1. Send a POST request to [/api/v1/hyperliquid/\{network}/staking/transfer](/reference/hyperliquid-transfer). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "amount": 10, "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e" } ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ amount: 10, delegatorAddress: "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "amount": 10, "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "amount": 10, "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/transfer", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `amount` — amount of tokens to transfer in HYPE. * `delegatorAddress` — delegator (A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.) account address which keeps tokens. Example response: ```json theme={null} { "result": { "amount": "10", "unsignedTransaction": "string", "createdAt": "2025-10-01T12:00:00Z" }, "error": {} } ``` * `amount` — amount of tokens to transfer in HYPE. * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-hyperliquid) the transaction to Hyperliquid network. After the transaction has been successfully executed, the delegator staking balance can delegate transferred tokens to the P2P validator. Transfers from the spot to the staking balance are instant. **2. Create delegate request** 1. Send a POST request to [/api/v1/hyperliquid/\{network}/staking/delegate](/reference/hyperliquid-delegate). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "amount": 10, "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e" } ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ amount: 10, delegatorAddress: "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "amount": 10, "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "amount": 10, "delegatorAddress": "0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/delegate", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `amount` — amount of tokens to delegate. * `delegatorAddress` — delegator address on the Hyperliquid network. Example response: ```json theme={null} { "result": { "amount": "10", "unsignedTransaction": "string", "createdAt": "2025-10-01T12:00:00Z" }, "error": {} } ``` * `amount` — amount of tokens to delegate. * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-hyperliquid) the transaction to Hyperliquid network. After this transaction has been successfully executed, the delegator starts actively participating in staking through the P2P validator. Note that delegations have a lock-up duration of 1 day, which means that only after this period can delegations be partially or fully undelegated. Rewards are accrued every minute and distributed to stakers every day. Rewards are redelegated automatically to the staked validator, i.e., compounded. ## Get delegator summary Additionally, check the delegator's active balances for HYPE spot balance, stake balance, active delegations, and pending withdrawals by sending the GET request to [/api/v1/hyperliquid/\{network}/staking/info/\{delegatorAddress}](/reference/hyperliquid-info). Example request (for `testnet` network): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e \ --header 'accept: application/json' \ --header 'authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", headers={ "accept": "application/json", "authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/hyperliquid/testnet/staking/info/0x80f0cd23da5bf3a0101110cfd0f89c8a69a1384e", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `delegatorAddress` — delegator address on the Hyperliquid network. Example response: ```json theme={null} { "result": { "spotBalance": 500.25, "stakeBalance": 250.75, "delegations": [ { "amount": 100.5, "validator": "0x497beec89958848126c2ea65934ce430e1410ad2", "lockedUntil": "2024-12-31T23:59:59Z" } ], "pendingWithdrawal": 75 }, "error": {} } ``` * `spotBalance` — amount of tokens on the spot balance available to transfer to the staking balance. * `stakeBalance` — amount of tokens on the staking balance available to delegate. * `delegations` — list of all the delegations per delegator. * `amount` — amount of delegated tokens in HYPE. * `validator` — validator address. * `lockedUntil` — timestamp of the delegation expiration in the ISO 8601 format. * `pendingWithdrawal` — total amount of tokens withdrawn that are pending in the unstaking queue. # Getting Started Source: https://docs.p2p.org/docs/staking-monad Stake on Monad programmatically with the P2P.org Staking API. Staking on the Monad network using the Staking API consists of several main steps: 1. Create a delegate request. 2. Sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create delegate transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create delegate request** Send a POST request to [/api/v2/monad/\{network}/delegators/\{delegatorAddress}/stakes/delegations](/reference/monad-delegators-create-delegation). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/delegations \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "gas": { "priorityPricePerGas": "21000", "maxPricePerGas": "1000000000" }, "amount": "1000000000000000000" } ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/delegations", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ gas: { priorityPricePerGas: "21000", maxPricePerGas: "1000000000", }, amount: "1000000000000000000", }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/delegations", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "gas": { "priorityPricePerGas": "21000", "maxPricePerGas": "1000000000", }, "amount": "1000000000000000000", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "gas": map[string]interface{}{ "priorityPricePerGas": "21000", "maxPricePerGas": "1000000000", }, "amount": "1000000000000000000", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v2/monad/testnet/delegators/0x1234567890abcdef1234567890abcdef12345678/stakes/delegations", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `delegatorAddress` — delegator address on the Monad network. * `amount` — amount of tokens to delegate in Wei (1 MON = 10¹⁸ Wei). * `gas` — computational effort required to execute the transaction measured in gas units (optional). If not specified, the values will be set due to the network load. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. Example response: ```json theme={null} { "result": { "amount": "1000000000000000000", "createdAt": "2025-05-06T10:40:00.000Z", "delegatorAddress": "0x1234567890abcdef1234567890abcdef12345678", "gas": { "gasLimit": "260850", "priorityPricePerGas": "1000000000", "maxPricePerGas": "2000000000" }, "unsignedTransaction": "0x02f8758301e24004...", "validatorId": 1 }, "error": {} } ``` * `amount` — amount of tokens to delegate in Wei (1 MON = 10¹⁸ Wei). * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `delegatorAddress` — delegator address on the Monad network. * `gas` — computational effort required to execute the transaction measured in gas units: * `gasLimit` — maximum gas limit for the transaction. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action. * `validatorId` — ID of the validator to which tokens are delegated. **2. Sign and send transaction** Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-monad) the transaction to the Monad network. To check the transaction status, send a GET request to [/api/v2/monad/\{network}/transactions/\{transactionHash}/status](/reference/aptos-transaction-status). Example request (for `testnet` network): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v2/monad/testnet/transactions/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641/status \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v2/monad/testnet/transactions/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641/status", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v2/monad/testnet/transactions/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641/status", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v2/monad/testnet/transactions/0x8d80b8ed85b578eeb873731101a926221701ee48218f6c9b83895f7ac1535641/status", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `transactionHash` — hash of the transaction. Example response: ```json theme={null} { "result": { "transactionHash": "0xdef456...789abc", "status": "success", "blockNumber": 1234567, "gasUsed": 21000, "createdAt": "2025-05-06T10:40:00.000Z" }, "error": {} } ``` * `transactionHash` — hash of the transaction. * `status` — transaction status: `pending`, `success`, `reverted` or `unknown`. * `blockNumber` — unique identifier of the block in which the transaction has been included. Only defined if the transaction status is `success` or `reverted`. * `gasUsed` — amount of gas spent for the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. After this transaction has been successfully executed, the delegator starts actively participating in staking through the P2P validator. Since the rewards are not auto-compounded, use the separate endpoints to manually [claim](/reference/monad-delegators-claim-rewards) or [compound rewards](/reference/monad-delegators-compound-rewards) to the staked validator. # Overview Source: https://docs.p2p.org/docs/staking-overview Staking API provides seamless integration for initiating staking requests and accessing staking data. By integrating your systems with our validators' infrastructure, you can eliminate the need for dedicated web page forms, making it easier to offer staking services to your customers. ## Key Benefits * **Reliable Infrastructure**: Gain access to our P2P validator (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.) infrastructure, consistently ranked among the top-performing validators, ensuring the reliability and security of your staking operations. * **Dedicated Support**: Our experienced developers provide customer-oriented support through a dedicated channel, assisting you with any questions or issues during the integration process. * **Customizable Configuration**: Tailor your staking node by selecting the desired location, MEV (Miner Extractable Value Relay Selection is a process of selecting a validator to participate in the next Ethereum block based on the value that they can extract from transactions in that block.) relay, and regulatory entity (currently in development). This flexibility allows you to align the staking setup with your specific requirements. * **Slashing Insurance**: We offer extensive insurance protection against slashing events, with customizable plans to mitigate the risks associated with staking. The illustration below shows the interaction with Staking API and relationships in the project infrastructure. ![](https://mintcdn.com/p2p0rg/lhVL1KmaAlMzkTnO/images/docs/staking-api-architecture-diagram.png?fit=max\&auto=format\&n=lhVL1KmaAlMzkTnO\&q=85\&s=99152ba2345103f6d17e86f42376053c) By seamlessly integrating Staking API into your systems, you can enhance your offering and simplify the staking process for your customers. Staking API is gradually expanding to support close to 50 Proof-of-Stake protocols, allowing you to stake in all of them. For the list of currently supported networks, visit [Networks Supported](/docs/networks-supported-staking-api). ## API Limitations To ensure optimal usage of Staking API, please be aware of the following limitations: * **Request Rate Limit**: The API enforces a maximum of 60 requests per minute. Ensure that your application adheres to this limit to avoid disruptions in service. * **Response Times**: While the P2P infrastructure aims for an average response time of 200 milliseconds (ms), please note that response times may vary depending on the specific nature of the request. P2P guarantees a 95th percentile response time of 10 seconds and a 99th percentile response time of 60 seconds to provide transparency. * **Node Request Limit**: The API supports the ability to request a maximum of 3125 validators in a single API call. This is to prevent the risk of users mistakenly requesting an excessive number of validators. If more validators are needed, you can send additional requests, each supporting up to 3125 validators. * **Validator Keys Limit**: The node request creation is subject to a limit based on the available validator keys in our clusters. Ensure that our team knows the amount and frequency of your validator key requests to prevent service disruptions. * **Withdrawal and Validator Status Endpoint Limits**: For specific endpoints like Withdrawal and Validator Status, the rate limit is 10 requests per minute, with 10,000 requests per day and a total of 30,000 requests per month. By keeping these limitations in mind, you can optimize your usage of Staking API and ensure a smooth and reliable integration process. If you have any questions or need further assistance, please [contact](/docs/contacts) us. We are committed to helping you make the most of Staking API and providing a seamless staking experience for your customers. # Getting Started Source: https://docs.p2p.org/docs/staking-polkadot Stake on Polkadot programmatically with the P2P.org Staking API. There are two ways to start staking on the Polkadot network using the Staking API with a public node: * Stake directly. * Stake via a nomination pool (On Polkadot and Avail, nomination pools allow users to contribute tokens and earn staking rewards. Unlike nominating directly, where your bonded funds remain in your account but become locked, the tokens you bond to a pool is transferred to the pool's stash account. Staking using pools requires a small amount of tokens, and the pool manages nominees on your behalf.). [Get an authentication token](/docs/authentication) to start using Staking API. For staking, it is essential to keep a minimum deposit of 1 DOT on the account. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain rect rgb(240, 248, 255) note right of Client: Direct Staking Client->>P2P API: Create bond transaction P2P API-->>Client: Unsigned bond transaction Client->>Client: Sign transaction locally Client->>Blockchain: Broadcast bond transaction Blockchain-->>Client: Bond confirmed Client->>P2P API: Create nomination transaction P2P API-->>Client: Unsigned nomination transaction Client->>Client: Sign transaction locally Client->>Blockchain: Broadcast nomination transaction Blockchain-->>Client: Nomination confirmed end rect rgb(255, 248, 240) note right of Client: Nomination Pool Client->>P2P API: Create pool bond transaction P2P API-->>Client: Unsigned pool bond transaction Client->>Client: Sign transaction locally Client->>Blockchain: Broadcast pool bond transaction Blockchain-->>Client: Pool bond confirmed end ``` ## Staking directly ### 1. Create bonding request 1. Send a POST request to [/api/v1/polkadot/\{network}/staking/bond](/reference/polkadot-staking-bond). Note that there is a [dynamic minimum threshold to stake](https://wiki.polkadot.network/docs/learn-staking). Example request (for `westend` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/bond \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "rewardDestinationType": "account", "rewardDestination": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "amount": 1, "extended": true }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polkadot/westend/staking/bond", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", rewardDestinationType: "account", rewardDestination: "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", amount: 1, extended: true, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/staking/bond", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "rewardDestinationType": "account", "rewardDestination": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "amount": 1, "extended": True, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "rewardDestinationType": "account", "rewardDestination": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "amount": 1, "extended": true, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/staking/bond", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — main stash account (On Polkadot and Avail, this is an account that holds funds bonded for staking, but delegates all staking functions to a staking proxy account. You may actively participate in staking with a stash private key kept in a cold wallet like Ledger, meaning it stays offline all the time. Having a staking proxy will allow you to sign all staking-related transactions with the proxy instead of using your Ledger device. This will allow you to avoid carrying around your Ledger device just to sign staking-related transactions, and to keep the transaction history of your stash clean.) address which keeps tokens for bonding (On Polkadot and Avail, a process by which tokens can be “frozen” in exchange for rewards. For example, staking is a form of bonding for which you receive rewards in exchange for securing the network.). * `rewardDestinationType` — rewards destination type: * `staked` — rewards will be sent to the stash account (On Polkadot and Avail, this is an account that holds funds bonded for staking, but delegates all staking functions to a staking proxy account. You may actively participate in staking with a stash private key kept in a cold wallet like Ledger, meaning it stays offline all the time. Having a staking proxy will allow you to sign all staking-related transactions with the proxy instead of using your Ledger device. This will allow you to avoid carrying around your Ledger device just to sign staking-related transactions, and to keep the transaction history of your stash clean.) and added to the current bond (compounding rewards). * `stash` — rewards will be sent to the stash account (On Polkadot and Avail, this is an account that holds funds bonded for staking, but delegates all staking functions to a staking proxy account. You may actively participate in staking with a stash private key kept in a cold wallet like Ledger, meaning it stays offline all the time. Having a staking proxy will allow you to sign all staking-related transactions with the proxy instead of using your Ledger device. This will allow you to avoid carrying around your Ledger device just to sign staking-related transactions, and to keep the transaction history of your stash clean.) as a transferable balance (not compounding rewards). * `account` — rewards will be sent to any account specified as a transferable balance. * `rewardDestination` — rewards destination account address. * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `extended` — optional boolean parameter (`true` or `false`) indicating whether to include additional metadata in the response. This information may be crucial for integrating with custodial platforms, offline signers, or advanced transaction builders. Example response (for `extended` parameter set to `true`): ```json theme={null} { "result": { "unsignedTransaction": "0xa8040600070010a5d4e803f690e412f0f0d6a963b89e78f9f44015c8909b2ee57836fff9a739e56897d51b", "unsignedTransactionSerialized": "7b2261646472657373223a223548647a67....", "unsignedTransactionPayload": "0x0600070010a5d4e803f690e412f0f0d6a963b89e78f9f44015c8909b2ee57836fff9a739e56897d51b", "unsignedTransactionObject": { "blockHash": "0xe9ee44203904ee47859882a6944bb9cb57a28a21146d699f0f731076f3beffe2", "eraPeriod": 64, "genesisHash": "0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e", "metadataRpc": "0x6d6574610e150f000c1c73705f636f72...", "method": { "args": { "value": "1,000,000,000,000", "payee": { "Account": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE" } }, "method": "bond", "section": "staking" }, "nonce": 1, "specVersion": 1018001, "transactionVersion": 27, "tip": 0 }, "stashAccountAddress": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "rewardDestinationType": "account", "rewardDestination": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "amount": 1, "createdAt": "2025-04-02T15:38:35.826Z" } } ``` * `unsignedTransaction` — unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action. * `unsignedTransactionSerialized` — unsigned serialized transaction. * `unsignedTransactionObject` — full decoded transaction structure with all metadata: * `blockHash`— hash of the checkpoint block in which the transaction was included. * `eraPeriod` — validity period of the transaction, representing the number of blocks after the checkpoint for which the transaction is valid. * `currentEra` — current staking era of the transaction. * `genesisHash` — hash of the genesis block. * `metadataRpc` — serialized metadata used for offline decoding and transaction signing. * `method` is the list of data fields containing information on the method called to construct a transaction. * `nonce` — nonce of the transaction. * `specVersion` — current version of the chain specification for the runtime. * `transactionVersion` — current version of the transaction format. * `tip` — optional fee used to increase the transaction priority. * `stashAccountAddress` — main stash account address which keeps tokens for bonding (On Polkadot and Avail, a process by which tokens can be “frozen” in exchange for rewards. For example, staking is a form of bonding for which you receive rewards in exchange for securing the network.). * `rewardDestinationType` — rewards destination type: * `staked` — rewards will be sent to the stash account and added to the current bond (compounding rewards). * `stash` — rewards will be sent to the stash account as a transferable balance (not compounding rewards). * `account` — rewards will be sent to any account specified as a transferable balance. * `rewardDestination` — rewards destination account address. * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. [Sign and broadcast](/docs/signing-transaction-polkadot) the `unsignedTransaction` to the Polkadot network. ### 2. Create nomination request > [!WARNING] > > **Accessing high-APR nodes** > > To benefit from P2P.org's high-APR validator (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.)s on Polkadot (DOT), you must attach the **P2P.org proxy** to your account. These private validator (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.)s require explicit approval and cannot be nominated via standard methods. Ensure the proxy is attached during your integration flow to unlock the enhanced staking rewards. > > Contact our [team](/docs/contacts) for dedicated assistance. 1. Send a POST request to [/api/v1/polkadot/\{network}/staking/nominate](/reference/polkadot-staking-nominate) to select validators within the Polkadot network. Example request (for `westend` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/nominate \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "extended": false }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polkadot/westend/staking/nominate", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", extended: false, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/staking/nominate", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "extended": False, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "extended": false, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/staking/nominate", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — main stash account address which keeps tokens for bonding (On Polkadot and Avail, a process by which tokens can be “frozen” in exchange for rewards. For example, staking is a form of bonding for which you receive rewards in exchange for securing the network.). * `extended` — optional boolean parameter (`true` or `false`) indicating whether to include additional metadata in the response. Example response (for `extended` request parameter set to `false`): ```json theme={null} { "result": { "unsignedTransaction": "0x2102040605100096b33e0a9647f13198ad16a2812c549a363646a3a7ddbdcc5590f5839c408c6200767f36484b1e2acf5c265c7a64bfb46e95259c66a8189bbcd216195def43685200c21ad1e5198cc0dc3b0f9f43a50f292678f63235ea321e59385d7ee45a7208360018164fa6f9ce28792fb781185e8de4e6eaae34c0f545e5864952fe23c183df0c", "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "targets": [ "5FUJHYEzKpVJfNbtXmR9HFqmcSEz6ak7ZUhBECz7GpsFkSYR", "5Ek5JCnrRsyUGYNRaEvkufG1i1EUxEE9cytuWBBjA9oNZVsf", "5GTD7ZeD823BjpmZBCSzBQp7cvHR1Gunq7oDkurZr9zUev2n", "5CcHdjf6sPcEkTmXFzF2CfH7MFrVHyY5PZtSm1eZsxgsj1KC" ], "createdAt": "2023-09-18T14:49:23.998Z" } } ``` * `unsignedTransaction` — unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) in hex format. Sign the transaction and submit it to the blockchain to perform the called action. * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `targets` — addresses of validators selected in the targets. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. [Sign and broadcast](/docs/signing-transaction-polkadot) the `unsignedTransaction` to the Polkadot network. ### 3. Add proxy account — optional step It is possible to add a staking proxy (On Polkadot and Avail, this is an account that acts on behalf of the stash account, signalling decisions about nominating and validating. It can set preferences like commission (for validators) and the staking rewards payout account. The earned rewards can be locked immediately for bonding on your stash account, which would effectively compound the rewards you receive over time. You could also choose to have them deposited to a different account as a free (transferable) balance. If you are a validator, it can also be used to set your session keys. Staking proxies only need sufficient funds to pay for the transaction fees.) to utilize the main stash account less frequently. It allows delegating your staking rights to another account, which can then sign transactions on your behalf. The original account retains all of its rights, and the proxy account can be removed at any time. 1. Send a POST request to [/api/v1/polkadot/\{network}/account/add](/reference/polkadot-account-add). Example request (for `westend` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/account/add \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "proxyAccountAddress": "5Ggpg3JepXM3ZrktNpoc5QA1sKaFVpUPWMRr7jppiMxTuU75", "extended": false }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polkadot/westend/account/add", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", proxyAccountAddress: "5Ggpg3JepXM3ZrktNpoc5QA1sKaFVpUPWMRr7jppiMxTuU75", extended: false, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/account/add", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "proxyAccountAddress": "5Ggpg3JepXM3ZrktNpoc5QA1sKaFVpUPWMRr7jppiMxTuU75", "extended": False, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "proxyAccountAddress": "5Ggpg3JepXM3ZrktNpoc5QA1sKaFVpUPWMRr7jppiMxTuU75", "extended": false, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/account/add", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — main stash account address which keeps tokens for bonding; a proxied address that transfers rights to a proxy account. * `proxyAccountAddress` — address that receives rights from the proxied account. * `extended` — optional boolean parameter (`true` or `false`) indicating whether to include additional metadata. Example response (for `extended` request parameter set to `false`): ```json theme={null} { "result": { "unsignedTransaction": "0xa404160100cc7cb7325ad1208212e2d8ee41a7572e816d53ac1bcac1be5df433486819213c0200000000", "createdAt": "2023-09-18T14:49:23.998Z" } } ``` * `unsignedTransaction` — unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) in hex format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. [Sign and broadcast](/docs/signing-transaction-polkadot) the `unsignedTransaction` to the Polkadot network. ## Staking via a nomination pool ### 1. Create bonding request 1. Create a bond request by sending a POST request to [/api/v1/polkadot/\{network}/staking/pool/bond](/reference/polkadot-pool-bond). The P2P.org pool ID on Polkadot mainnet is **238**. Example request (for `westend` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/pool/bond \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "poolId": 238, "amount": 3, "extended": true }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/bond", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", poolId: 238, amount: 3, extended: true, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/bond", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "poolId": 238, "amount": 3, "extended": True, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "poolId": 238, "amount": 3, "extended": true, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/bond", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `poolId` — ID of the nomination pool. * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `extended` — optional boolean parameter (`true` or `false`) indicating whether to include additional metadata in the response. This information may be crucial for integrating with custodial platforms, offline signers, or advanced transaction builders. Example response (for `extended` parameter set to `true`): ```json theme={null} { "result": { "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f", "unsignedTransactionSerialized": "7b2261646472657373223a223548647a67....", "unsignedTransactionPayload": "0x0600070010a5d4e803f690e412f0f0d6a963b89e78f9f44015c8909b2ee57836fff9a739e56897d51b", "unsignedTransactionObject": { "blockHash": "0xe9ee44203904ee47859882a6944bb9cb57a28a21146d699f0f731076f3beffe2", "eraPeriod": 64, "genesisHash": "0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e", "metadataRpc": "0x6d6574610e150f000c1c73705f636f72...", "method": { "args": { "value": "3,000,000,000,000", "payee": { "Account": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE" } }, "method": "bond", "section": "staking" }, "nonce": 1, "specVersion": 1018001, "transactionVersion": 27, "tip": 0 }, "stashAccountAddress": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "rewardDestinationType": "account", "rewardDestination": "5HdzgJMcKFwCeiso1izCWGLyVLk9YFztVFjK4rCadNXz6ztE", "amount": 3, "createdAt": "2025-04-02T15:38:35.826Z" } } ``` * `unsignedTransaction` — unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action. * `unsignedTransactionSerialized` — unsigned serialized transaction. * `unsignedTransactionObject` — full decoded transaction structure with all metadata: * `blockHash`— hash of the checkpoint block in which the transaction was included. * `eraPeriod` — validity period of the transaction, representing the number of blocks after the checkpoint for which the transaction is valid. * `currentEra` — current staking era of the transaction. * `genesisHash` — hash of the genesis block. * `metadataRpc` — serialized metadata used for offline decoding and transaction signing. * `method` is the list of data fields containing information on the method called to construct a transaction. * `nonce` — nonce of the transaction. * `specVersion` — current version of the chain specification for the runtime. * `transactionVersion` — current version of the transaction format. * `tip` — optional fee used to increase the transaction priority. * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `rewardDestinationType` — rewards destination type: * `staked` — rewards will be sent to the stash account and added to the current bond (compounding rewards). * `stash` — rewards will be sent to the stash account as a transferable balance (not compounding rewards). * `account` — rewards will be sent to any account specified as a transferable balance. * `rewardDestination` — rewards destination account address. * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. [Sign and broadcast](/docs/signing-transaction-polkadot) the `unsignedTransaction` to the Polkadot network. ### 2. Create setting permission request 1. Grant permission to the pool for managing rewards on your behalf by sending a POST request to [api/v1/polkadot/\{network}/staking/pool/set-claim-permission](/reference/polkadot-pool-set-claim-permission). Example request (for `westend` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/pool/set-claim-permission \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "permission": "PermissionlessAll", "extended": false } ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/set-claim-permission", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", permission: "PermissionlessAll", extended: false, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/set-claim-permission", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "permission": "PermissionlessAll", "extended": False, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "permission": "PermissionlessAll", "extended": false, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/set-claim-permission", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `permission` — state of the permission to grant: * `Permissioned` — only you can claim, bond or withdraw rewards. If this level of permission is set, an additional [claiming payout request](/docs/staking-polkadot#3-create-claim-payout-request) is needed. * `PermissionlessCompound` — compounding of rewards (claim and then bond) on your behalf is permitted. * `PermissionlessWithdraw` — withdrawing of rewards (claim and then keep as a free balance) on your behalf is permitted. * `PermissionlessAll` — claiming, bonding and withdrawing rewards on your behalf are permitted. * `extended` — optional boolean parameter (`true` or `false`) indicating whether to include additional metadata in the response. Example response: ```json theme={null} { "result": { "unsignedTransaction": "0xa404160200165874de804160c3cd013d9b6f4bba864657c4c2168a542f78ff14a0253873190200000000", "createdAt": "2023-08-24T08:23:18.830Z" }, "error": {} } ``` * `unsignedTransaction` — unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. [Sign and broadcast](/docs/signing-transaction-polkadot) the `unsignedTransaction` to the Polkadot network. ### 3. Create claiming payout request Unlike direct staking, after the rewards are distributed to the nomination pool by a validator, each pool member has to claim their part manually. Since that, to bond, compound, or withdraw your rewards, you may need to perform an additional claiming payout request. Whether it is required depends on the claim rewards permissions you [set in step 2](/docs/staking-polkadot#2-create-set-permission-request) : * For `PermissionlessAll`, the step is optional. * For `Permissioned`, the step is necessary, as you are the only one who can claim the rewards. * For `PermissionlessCompound` and `PermissionlessWithdraw`, the step is required if you want to withdraw and compound your rewards accordingly. To create a claim payout request: 1. Send a POST request to [/api/v1/polkadot/\{network}/staking/pool/claim-payout](/reference/polkadot-pool-claim-payout). Example request (for `westend` network): ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polkadot/westend/staking/pool/claim-payout \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "extended": false }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/claim-payout", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", extended: false, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/claim-payout", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "extended": False, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "5H6ryBWChC5w7eaQ4GZjo329sEnhvjetSr6MBEt42mZ5tPw5", "extended": false, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polkadot/westend/staking/pool/claim-payout", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `extended` — optional boolean parameter (`true` or `false`) indicating whether to include additional metadata in the response. Example response: ```json theme={null} { "result": { "unsignedTransaction": "0xa404160100cc7cb7325ad1208212e2d8ee41a7572e816d53ac1bcac1be5df433486819213c0200000000", "createdAt": "2023-08-24T08:23:18.830Z" } } ``` * `unsignedTransaction` — unsigned transaction in hex format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. 2. [Sign and broadcast](/docs/signing-transaction-polkadot) the `unsignedTransaction` to the Polkadot network. # Getting Started Source: https://docs.p2p.org/docs/staking-polygon Stake on Polygon programmatically with the P2P.org Staking API. Staking on the Polygon network using the Staking API consists of the following steps: 1. Approve token management with the Polygon smart contract. 2. Create a staking request. After each operation, [sign and send the transaction](/docs/signing-transaction-polygon) to the Polygon network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create approve transaction P2P API-->>Client: Unsigned approve transaction Client->>Client: Sign transaction locally Client->>Blockchain: Broadcast approve transaction Blockchain-->>Client: Approval confirmed Client->>P2P API: Create delegate transaction P2P API-->>Client: Unsigned delegate transaction Client->>Client: Sign transaction locally Client->>Blockchain: Broadcast delegate transaction Blockchain-->>Client: Delegation confirmed ``` **1. Approve token management** Allow the Polygon smart contract to manage tokens by obtaining approval. Any amount can be approved, but preferably specify the exact amount ready to stake. Send a POST request to [/api/v1/polygon/staking/approve](/reference/polygon-staking-approve). Use [https://api.p2p.org](https://api.p2p.org) for production. Example request: ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polygon/staking/approve \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data ' { "amount": "1000000000000000000", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17" }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polygon/staking/approve", { method: "POST", headers: { "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ amount: "1000000000000000000", stakerAddress: "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polygon/staking/approve", headers={ "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "amount": "1000000000000000000", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "amount": "1000000000000000000", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polygon/staking/approve", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `amount` — amount of tokens in Wei (1 POL = 10¹⁸ Wei) to approve for staking. * `stakerAddress` — staker account address. Example response: ```json theme={null} { "result": { "serializeTx": "0x02f86505800214830186a094499d11e0b6eac7c0593d8fb292dcbbf815fb29ae80b844095ea7b300000000000000000000000000200ea4ee292e253e6ca07dba5edc07c8aa37a3000000000000000000000000000000000000000000000000016345785d8a0000c0", "to": "0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae", "gasLimit": "0.0000000000001", "data": "0x095ea7b300000000000000000000000000200ea4ee292e253e6ca07dba5edc07c8aa37a3000000000000000000000000000000000000000000000000016345785d8a0000", "value": "0.0", "chainId": 1, "type": 2, "maxFeePerGas": "0.00000000000000002", "maxPriorityFeePerGas": "2" } } ``` * `serializeTx` — serialized unsigned transaction. * `to` — recipient address for this transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. **2. Create staking request** To create a stake transaction, delegate tokens to P2P validator by sending a POST request to [/api/v1/polygon/staking/delegate](/reference/polygon-staking-delegate). Example request: ```bash curl theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/polygon/staking/delegate \ --head 'accept: application/json' \ --head 'Authorization: Bearer ' \ --head 'Content-Type: application/json' \ --data ' { "amount": "100000000000000000", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17" } ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api.p2p.org/api/v1/polygon/staking/delegate", { method: "POST", headers: { "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ amount: "100000000000000000", stakerAddress: "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api.p2p.org/api/v1/polygon/staking/delegate", headers={ "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "amount": "100000000000000000", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "amount": "100000000000000000", "stakerAddress": "0x39D02C253dA1d9F85ddbEB3B6Dc30bc1EcBbFA17", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.p2p.org/api/v1/polygon/staking/delegate", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `amount` — amount of tokens in Wei (1 MATIC = 10¹⁸ Wei) to delegate. * `stakerAddress` — staker account address. Example response is the same as in the approve token management step. To complete staking, [sign and send](/docs/signing-transaction-polygon) the transaction to the Polygon network. # Overview Source: https://docs.p2p.org/docs/staking-sdk P2P.ORG Staking SDK is a JavaScript/TypeScript library that provides a typed client for interacting with the P2P.ORG Staking API. Currently, the SDK provides functionality for Solana staking workflows. The SDK is designed for Node.js (version 20 or higher) and is distributed as an ESM-only package. The library provides: * Wrappers to the [P2P.ORG Staking API](/docs/staking-api) endpoints. * Methods for decoding and verifying transactions. * Testing-only helpers for signing transactions. Note that for production environments, it is recommended to sign transactions via wallet software or hardware wallets or a dedicated signer service. To start using P2P.ORGStaking SDK, initialize a [`StakingApiClient`](/docs/staking-sdk-stakingapiclient) and use the object corresponding to your network: * `client.solana` — [Solana](/docs/staking-sdk-solana). More networks will be added in future versions. # Overview Source: https://docs.p2p.org/docs/staking-sdk-solana How to stake tokens in Solana network using P2P.ORG Staking SDK. 1. Initialize the API client object via the [`StakingApiClient`](/docs/staking-sdk-stakingapiclient) constructor. ```javascript JavaScript theme={null} const client = new StakingApiClient({ baseUrl: 'https://api.p2p.org', token: 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9', network: 'mainnet-beta', }); ``` 2. Retrieve the staking accounts from your P2P.ORG profile with [`getStakingAccounts()`](/docs/staking-sdk-solana-getstakingaccounts). ```javascript JavaScript theme={null} var result = await client.solana.getStakingAccounts({ status: 'active', }); const account = result.accounts[0]; ``` 3. Create a new stake transaction with [`stake()`](/docs/staking-sdk-solana-stake). The result will contain a base64-encoded unsigned transaction which you can convert to a Solana [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object. ```javascript JavaScript theme={null} var result = await client.solana.stake({ feePayer: account.stakeAccount, fromPublicKey: account.stakeAccount, stakeAuthority: account.stakeAuthority, withdrawAuthority: account.withdrawAuthority, amount: '1002282880', }); var transaction = client.solana.decodeTransaction(result.unsignedTransaction); ``` 4. Sign the transaction using the dedicated wallet software. P2P.ORG Staking SDK provides a simple method [`signWithKeypairs()`](/docs/staking-sdk-solana-signwithkeypairs), though it is intended for testing and development only. In production, replace it with the software or hardware wallet integration or a dedicated signing service integration. ```javascript JavaScript theme={null} const key = process.env.SOLANA_PRIVATE_KEY; client.solana.signWithKeypairs(transaction, [key]); ``` 5. Verify the signed transaction with [`verifyTransaction()`](/docs/staking-sdk-solana-verifytransaction). This ensures that the transaction was not modified by external software before signing. ```javascript JavaScript theme={null} client.solana.verifyTransaction({ tx: transaction, expectedFeePayer: account.stakeAuthority, expectedStakeAuthority: account.stakeAuthority, expectedWithdrawAuthority: account.withdrawAuthority, strict: true, }); ``` 6. Broadcast the transaction to the Solana network with [`sendTransaction()`](/docs/staking-sdk-solana-sendtransaction). ```javascript JavaScript theme={null} await client.solana.sendTransaction({ signedTransaction: transaction, }); ``` # deactivate() Source: https://docs.p2p.org/docs/staking-sdk-solana-deactivate Create deactivate stake request transaction. This method calls [`/solana/{network}/staking/deactivate`](/reference/solana-staking-deactivate) to create a new unsigned transaction which, if signed and broadcasted, will deactivate a previously created stake. ## Parameters ```javascript JavaScript theme={null} await client.solana.deactivate({ feePayer: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', stakeAccount: 'Fw82VhehY4yazX6tcZfNQWTsqHDSXaGmwVkbJYegDMbG', stakeAuthority: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', }); ``` | | | - | | **network** *string* Solana network: `mainnet-beta` — production network. `testnet` — testnet. If not specified, the method will use the default value from the [constructor](/docs/staking-sdk-stakingapiclient). | | **feePayer** *string, required* Account address that will pay the fee for the transaction. | | **nonceAccount** *string* Account address that keeps the value of the nonce. | | **computeUnitLimit** *number ≥ 1* Maximum computational effort limit for the transaction measured in compute units. | | **computeUnitPrice** *number ≥ 1* Price of compute unit for transaction. | | **stakeAccount** *string, required* Account address that stores tokens for staking. | | **stakeAuthority** *string, required* Account address that can perform staking operations with staking account. | ## Result The method returns a JSON object that contains a base64-encoded unsigned transaction and some metadata about it. You can decode the transaction using [`decodeTransaction()`](/docs/staking-sdk-solana-decodetransaction) or pass it directly to [`signWithKeypairs()`](/docs/staking-sdk-solana-signwithkeypairs). ```json JSON theme={null} { "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "stakeAccount": "Fw82VhehY4yazX6tcZfNQWTsqHDSXaGmwVkbJYegDMbG", "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "unsignedTransaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+jagnMHpK8BDHt0PpssHwXGD2fBxS6MWBoxptD2u9TvrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NjSeWM5+GSJdoQd43Al9SVVXC9FfWGwbe7icpomwAUGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAijW940iwWddz25ZC37fI0ue5fa+eTbC2ynBM3b0t4pcDAgMAAQBgAwAAAI5ELeF3F+N1ZPBWe0G1FV0heaKPY7e8dg5tBPbrf8voBAAAAAAAAABzZWVkgJaYAAAAAADIAAAAAAAAAAah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABAIBB3QAAAAAjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+iORC3hdxfjdWTwVntBtRVdIXmij2O3vHYObQT263/L6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQGAQMGCAUABAIAAAA=", "createdAt": "2023-08-24T08:14:50.455Z" } ``` | | | - | | **feePayer** *string, required* Account address that will pay the fee for the transaction. | | **stakeAccount** *string* Account address that stores tokens for staking. | | **stakeAuthority** *string* Account address that can perform staking operations with staking account. | | **unsignedTransaction** *string, required* Unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. | | **createdAt** *string, required* Timestamp of the transaction in the ISO 8601 format. | # decodeTransaction() Source: https://docs.p2p.org/docs/staking-sdk-solana-decodetransaction Decode unsigned transaction from base64 into Solana Transaction. ```javascript JavaScript theme={null} await client.solana.decodeTransaction(unsignedTxBase64); ``` ## Parameters | | | - | | **unsignedTxBase64** *string, required* | ## Result The method returns a Solana [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object that you can pass to [`signWithKeypairs()`](/docs/staking-sdk-solana-signwithkeypairs) . # getStakingAccounts() Source: https://docs.p2p.org/docs/staking-sdk-solana-getstakingaccounts Return information about staking accounts. This method calls [`/solana/{network}/staking/getStakingAccounts`](/reference/solana-staking-get-staking-account) and returns a list of accounts that can be used for staking in the Solana network. ## Parameters ```javascript JavaScript theme={null} await client.solana.getStakingAccounts({ stakeAuthorities: [ '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', 'AaMC5y1RofbY3unyrahRzyCzsesp7rfGuaGegbAg1Hxb', ], stakeAccounts: [ '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', 'AaMC5y1RofbY3unyrahRzyCzsesp7rfGuaGegbAg1Hxb', ], withdrawAuthorities: [ '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', 'AaMC5y1RofbY3unyrahRzyCzsesp7rfGuaGegbAg1Hxb', ], status: 'active', }); ``` | | | - | | **network** *string* Solana network: `mainnet-beta` — production network. `testnet` — testnet. If not specified, the method will use the default value from the [constructor](/docs/staking-sdk-stakingapiclient) . | | **stakeAuthorities** *string\[]* List of account addresses that can perform staking operations with staking accounts. | | **stakeAccounts** *string\[]* List of staking account addresses. | | **withdrawAuthorities** *string\[]* List of account addresses that can perform withdrawal operations with staking accounts. | | **status** *string* Staking account status: `active`, `inactive`, `activating`, `deactivating`. | ## Result In the resulting object, the field `accounts` is a list of objects, each representing a staking account. ```json JSON theme={null} { "accounts": [ { "stakeAccount": "Fw82VhehY4yazX6tcZfNQWTsqHDSXaGmwVkbJYegDMbG", "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "voteAccount": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "status": "active", "amount": 1, "amountWithoutRentExemption": 1, "stakeAmounts": { "active": 1000000000000, "inactive": 1000000000000 } } ] } ``` | | | - | | **stakeAccount** *string* Account address that stores tokens for staking. | | **stakeAuthority** *string* Account address that can perform staking operations with the staking account. | | **withdrawAuthority** *string* Account address that can perform withdrawal operations with the staking account. | | **voteAccount** *string* Vote account address. | | **status** *string* Stake account status: `active`, `inactive`, `activating`, `deactivating`. | | **amount** *number* Amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). | | **amountWithoutRentExemption** *number* Amount of tokens to stake in lamports (1 SOL = 10⁹ lamports) without rent exemption. | | **stakeAmounts** *object* Information about delegated stake amounts. `active` — amount of active stake in lamports. `inactive` — amount of inactive stake in lamports. | # sendTransaction() Source: https://docs.p2p.org/docs/staking-sdk-solana-sendtransaction Send the signed transaction to the Solana network. This method calls [`/solana/{network}/staking/send`](/reference/solana-staking-send) to broadcast a signed transaction to the specified network. > [!WARNING] > > It is strongly recommended to verify transactions before broadcasting, see [`verify()`](/docs/staking-sdk-solana-verifytransaction). ## Parameters ```javascript JavaScript theme={null} await client.solana.stake({ signedTransaction: transaction, }); ``` | | | - | | **signedTransaction** *Transaction or string, required* The signed transaction that needs to be broadcasted. Can be a Solana [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object or its base64-encoded representation. | | **network** *string* Solana network: `mainnet-beta` — production network. `testnet` — testnet. If not specified, the method will use the default value from the [constructor](/docs/staking-sdk-stakingapiclient) . | ## Result ```json JSON theme={null} { "transactionId": "0x0628743b05ffb4c9d5ea2144b359af38910f0ae439a685f57d85b50b9481ba3f", "slot": "17168395", "signerAccounts": ["9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw"], "createdAt": "2023-08-24T08:14:50.455Z" } ``` | | | - | | **transactionId** *string* Block hash in which the transaction was included. | | **slot** *number* Period of time during which each leader collects transactions and creates a block in the Solana network. | | **signerAccounts** *string* Account addresses that signed the transaction. | | **createdAt** *string* Timestamp of the transaction in the ISO 8601 format. | # signWithKeypairs() Source: https://docs.p2p.org/docs/staking-sdk-solana-signwithkeypairs Sign a Transaction using one or more keypairs. This method accepts an unsigned transaction (or its base64-encoded representation) and a set of keypairs (or private keys) and signs the transaction with the keys. Note that for the resulting transaction to be valid, you must provide the keys or keypairs corresponding to all the public keys that were originally passed when creating the transaction via [`stake()`](/docs/staking-sdk-solana-stake), [`withdraw()`](/docs/staking-sdk-solana-withdraw) or [`deactivate()`](/docs/staking-sdk-solana-deactivate). ```javascript JavaScript theme={null} client.solana.signWithKeypairs(unsignedTx, [keypair1, keypair2]); ``` > [!WARNING] > > **This method is intended for testing purposes only.** > > Using this method requires passing private keys directly to the running code, which is often **not safe**. We strongly recommend signing transactions via dedicated software or hardware wallets, such as [Phantom](https://phantom.com/) or [Solflare](https://solflare.com/). ## Parameters | | | - | | **unsignedTx** *Transaction or string, required* The transaction that needs to be signed. Can be a Solana [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object or its base64-encoded representation. For a base64-encoded representation, the method will internally call [`decodeTransaction()`](/docs/staking-sdk-solana-decodetransaction). | | **keypairs** *array, required* An array of one or more keypairs to use for signing. Each element of the array must be a Solana [`Keypair`](https://solana-foundation.github.io/solana-web3.js/classes/Keypair.html) object or its private key represented as `Uint8Array` or `string`. | ## Result Returns a signed [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object. If the method was called with an existing transaction object (not base64-encoded), all modifications will be done on that object, and the same object will be returned. You can pass the signed transaction to [`verifyTransaction()`](/docs/staking-sdk-solana-verifytransaction) and [`sendTransaction()`](/docs/staking-sdk-solana-sendtransaction). # stake() Source: https://docs.p2p.org/docs/staking-sdk-solana-stake Create staking request transaction. This method calls [`/solana/{network}/staking/stake`](/reference/solana-staking-stake) to create a new unsigned transaction which, if signed and broadcasted, will create a new staking request. ```javascript JavaScript theme={null} await client.solana.stake({ feePayer: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', fromPublicKey: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', amount: '1002282880', }); ``` ## Parameters | | | - | | **network** *string* Solana network: `mainnet-beta` — production network. `testnet` — testnet. If not specified, the method will use the default value from the [constructor](/docs/staking-sdk-stakingapiclient) . | | **feePayer** *string, required* Account address that will pay the fee for the transaction. | | **fromPublicKey** *string, required* Account address from which the staking account will be created. | | **nonceAccount** *string* Account address that keeps the value of the nonce. | | **computeUnitLimit** *number ≥ 1* Maximum computational effort limit for the transaction measured in compute units. | | **computeUnitPrice** *number ≥ 1* Price of a compute unit for the transaction in micro-lamports (1 microLamport = 10⁻⁶ lamports). | | **stakeAuthority** *string* Account address that can perform staking operations with the staking account. If not specified, rights will be taken from the `fromPublicKey` parameter. | | **withdrawAuthority** *string* Account address that can perform withdrawal operations with the staking account. If not specified, rights will be taken from the `fromPublicKey` parameter. | | **amount** *string, required* Amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). Min amount is `'1002282880'`. | ## Result The method returns a JSON object that contains a base64-encoded unsigned transaction and some metadata about it. You can decode the transaction using [`decodeTransaction()`](/docs/staking-sdk-solana-decodetransaction) or pass it directly to [`signWithKeypairs()`](/docs/staking-sdk-solana-signwithkeypairs). ```json JSON theme={null} { "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "fromPublicKey": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "stakeAccount": "6ZuLUCwVTvuQJrN1HrpoHJheQUw9Zk8CtiD3CEpHiA9E", "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "amount": 1, "unsignedTransaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+jagnMHpK8BDHt0PpssHwXGD2fBxS6MWBoxptD2u9TvrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NjSeWM5+GSJdoQd43Al9SVVXC9FfWGwbe7icpomwAUGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAijW940iwWddz25ZC37fI0ue5fa+eTbC2ynBM3b0t4pcDAgMAAQBgAwAAAI5ELeF3F+N1ZPBWe0G1FV0heaKPY7e8dg5tBPbrf8voBAAAAAAAAABzZWVkgJaYAAAAAADIAAAAAAAAAAah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABAIBB3QAAAAAjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+iORC3hdxfjdWTwVntBtRVdIXmij2O3vHYObQT263/L6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQGAQMGCAUABAIAAAA=", "createdAt": "2023-08-24T08:14:50.455Z" } ``` | | | - | | **feePayer** *string* Account address that will pay the fee for the transaction. | | **fromPublicKey** *string* Account address from which the staking account will be created. | | **stakeAccount** *string* Account address that stores tokens for staking. | | **stakeAuthority** *string* Account address that can perform staking operations with staking account. | | **withdrawAuthority** *string* Account address that can perform withdrawal operation with staking account. | | **amount** *number* Amount of tokens to stake in lamports (1 SOl = 10⁹ lamports). Min amount is `1002282880`. | | **unsignedTransaction** *string* Unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. | | **createdAt** string Timestamp of the transaction in the ISO 8601 format. | # verifyTransaction() Source: https://docs.p2p.org/docs/staking-sdk-solana-verifytransaction Perform some checks on a staking transaction. This method is intended to be called on a `Transaction` after it was signed by an external software or hardware wallet. This mitigates the risk of data being altered by third parties. If possible, it is recommended to call this method with the same data that was passed to [`stake()`](/docs/staking-sdk-solana-stake). > [!NOTE] > > **Example** > > A popular attack involves altering the content of the system clipboard when a user is copying the transaction data to their software wallet. A malicious software on a user's computer could replace the legitimate staking transaction with another transaction that sends funds to a third party. The user then signs the malicious transaction without noticing. > > By calling `verifyTransaction()`, you can detect that the transaction that was signed is not, in fact, the expected staking transaction. ```javascript JavaScript theme={null} client.solana.verifyTransaction({ tx: signedTx, expectedFeePayer: authority, expectedStakeAuthority: authority, expectedWithdrawAuthority: authority, strict: true, }); ``` ## Checks The following checks are performed. * The transaction must have a fee payer. If `expectedFeePayer` is provided, the transaction must have this exact fee payer. * The transaction must contain instructions. If the strict mode is on, each instruction must be either a [`StakeProgram`](https://solana-foundation.github.io/solana-web3.js/classes/StakeProgram.html) or a [`SystemProgram`](https://solana-foundation.github.io/solana-web3.js/classes/SystemProgram.html). * If the strict mode is on, both `expectedStakeAuthority` and `expectedWithdrawAuthority` (if provided) must be referenced in at least one instruction each. ## Parameters | | | - | | **tx** *Transaction, required* The signed transaction that needs to be verified. | | **expectedFeePayer** *string* The `feePayer` that was passed to [`stake()`](/docs/staking-sdk-solana-stake) . | | **expectedStakeAuthority** *string* The `stakeAuthority` that was passed to [`stake()`](/docs/staking-sdk-solana-stake). | | **expectedWithdrawAuthority** *string* The `withdrawAuthority` that was passed to [`stake()`](/docs/staking-sdk-solana-stake). | | **strict** *boolean* If true, some additional checks will be enabled. See the list of checks above for more information. | ## Result If the transaction is correct, the method does not return anything. It is assumed that you can safely publish the transaction via [`sendTransaction()`](/docs/staking-sdk-solana-sendtransaction). If the transaction is not correct, the method throws an `Error` with the corresponding message. It is strongly recommended to discard such a transaction and investigate whether the system is compromised. # withdraw() Source: https://docs.p2p.org/docs/staking-sdk-solana-withdraw Create withdrawal request transaction. This method calls [`/solana/{network}/staking/withdraw`](/reference/solana-staking-withdraw) to create a new unsigned transaction which, if signed and broadcasted, will create a new withdrawal request. ## Parameters ```javascript JavaScript theme={null} await client.solana.withdraw({ feePayer: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', stakeAccount: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', withdrawAuthority: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', recipient: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', amount: '1002282880', }); ``` | | | - | | **network** *string* Solana network: `mainnet-beta` — production network. `testnet` — testnet. If not specified, the method will use the default value from the [constructor](/docs/staking-sdk-stakingapiclient) . | | **feePayer** *string, required* Account address that will pay the fee for the transaction. | | **stakeAccount** *string, required* Account address that stores tokens for staking. | | **withdrawAuthority** *string, required* Account address that can perform staking operations with the staking account. | | **recipient** *string, required* Account address to which tokens will be sent. | | **amount** *string, required* Amount of tokens to withdraw in lamports (1 SOL = 10⁹ lamports). | | **nonceAccount** *string* Account address that keeps the value of the nonce. | | **computeUnitLimit** *number ≥ 1* Maximum computational effort limit for the transaction measured in compute units. | | **computeUnitPrice** *number ≥ 1* Price of compute unit for transaction. | ## Result The method returns a JSON object that contains a base64-encoded unsigned transaction and some metadata about it. You can decode the transaction using [`decodeTransaction()`](/docs/staking-sdk-solana-decodetransaction) or pass it directly to [`signWithKeypairs()`](/docs/staking-sdk-solana-signwithkeypairs). ```json JSON theme={null} { "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "stakeAccount": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "recipient": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "amount": 1, "unsignedTransaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+jagnMHpK8BDHt0PpssHwXGD2fBxS6MWBoxptD2u9TvrgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1NjSeWM5+GSJdoQd43Al9SVVXC9FfWGwbe7icpomwAUGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAijW940iwWddz25ZC37fI0ue5fa+eTbC2ynBM3b0t4pcDAgMAAQBgAwAAAI5ELeF3F+N1ZPBWe0G1FV0heaKPY7e8dg5tBPbrf8voBAAAAAAAAABzZWVkgJaYAAAAAADIAAAAAAAAAAah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABAIBB3QAAAAAjkQt4XcX43Vk8FZ7QbUVXSF5oo9jt7x2Dm0E9ut/y+iORC3hdxfjdWTwVntBtRVdIXmij2O3vHYObQT263/L6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQGAQMGCAUABAIAAAA=", "createdAt": "2023-08-24T08:14:50.455Z" } ``` | | | - | | **feePayer** *string, required* Account address that will pay the fee for the transaction. | | **stakeAccount** *string* Account address that stores tokens for staking. | | **withdrawAuthority** *string* Account address that can perform withdrawal operations with the staking account. | | **recipient** *string* Account address to which tokens will be sent. | | **amount** *number, required* Amount of tokens to withdraw in lamports (1 SOl = 10⁹ lamports). | | **unsignedTransaction** *string, required* Unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. | | **createdAt** *string, required* Timestamp of the transaction in the ISO 8601 format. | # StakingApiClient Source: https://docs.p2p.org/docs/staking-sdk-stakingapiclient The object for accessing all network-specific methods of P2P.ORG Staking SDK. A `StakingApiClient` object is initialized with a base URL and an authentication token that will be used by various methods. ```javascript JavaScript theme={null} import { StakingApiClient } from '@p2p/staking-api'; const client = new StakingApiClient({ baseUrl: 'https://api.p2p.org', token: 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9', network: 'mainnet-beta', retry: { retryOn: [429, 500, 502, 503], retryDelayMs: 500, retries: 3, retryOnTimeout: true, }, }); ``` The methods for each supported network can be accessed via a specific field in the `StakingApiClient` object. For example: ```javascript JavaScript theme={null} await client.solana.stake({ feePayer: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', fromPublicKey: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw', amount: '1002282880', }); ``` Currently, the following networks are supported: * `client.solana` — [Solana](/docs/staking-sdk-solana). More networks will be added in future versions. ## Parameters | | | - | | **baseUrl** *string, required* The base URL for all P2P.ORG API endpoints: \* `https://api.p2p.org` for production, \* `https://api-test.p2p.org` for testing. | | **token** *string, required* The [authentication token](/docs/authentication) for accessing P2P.ORG API. | | **network** *string, required* Network to use in all API calls by default, e.g., `mainnet` or `testnet`. See the specific methods' documentation for allowed values. | | **timeoutMs** *number* If specified, any request that takes longer than this amount of milliseconds will fail. | | **retry** *object* Parameters that affect how the API client handles HTTP errors. If the client encounters one of HTTP response codes listed in `retryOn`, it will wait for at least `retryDelayMs` milliseconds and attempt the same API request again. If the request fails repeatedly, the delay grows exponentially, according to formula: *retryDelayMs + 2^(attempt-1) + random jitter*. The client will throw an exception only if the request failed as many times as specified in the `retries` option. If `retryOnTimeout` is set to true, the same retry behavior will be used for requests that failed according to `timeoutMs`. Enable with caution for non-idempotent operations like [sendTransaction()](/docs/staking-sdk-solana-sendtransaction). If these parameters are not provided, the client will never retry failed requests and will fail immediately. | | **logger** *object* An optional object for accepting log messages. Any console-compatible logger object can be provided: `console`, [`pino`](https://getpino.io/), [`winston`](https://github.com/winstonjs/winston), etc. If the object is not provided, Staking SDK will not log any messages. | # Getting Started Source: https://docs.p2p.org/docs/staking-sei Stake on Sei programmatically with the P2P.org Staking API. Staking in the Sei network using the Staking API consists of the following main steps: 1. Create a staking request. 2. Sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create staking request** Send a POST request to [/api/v1/sei/\{network}/staking/stake](/reference/create-sei-stake-transaction). Example request (for `atlantic-2` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/sei/atlantic-2/staking/stake \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "memo": "This is your memo message", "amount": 0.00420 }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/sei/atlantic-2/staking/stake", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ stashAccountAddress: "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", memo: "This is your memo message", amount: 0.00420, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/sei/atlantic-2/staking/stake", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "memo": "This is your memo message", "amount": 0.00420, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "memo": "This is your memo message", "amount": 0.00420, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/sei/atlantic-2/staking/stake", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `stashAccountAddress` — delegator (A participant in a Proof-of-Stake network who delegates their tokens to a validator. Delegators share in the rewards and risks associated with the validator's performance in the consensus process.) stash account address which keeps tokens. * `memo` — arbitrary text data to add to the transactions. * `amount` — amount of tokens to stake in SEI. Example response: ```json theme={null} { "error": null, "result": { "amount": 0.0042, "currency": "sei", "validatorAddress": "cosmosvaloper17lgg03ze9x6xka02fs0hhw4ad4wwg05heqr2y8", "stashAccountAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "rewardDestinationAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "transactionData": { "messages": [ { "typeUrl": "/cosmos.staking.v1beta1.MsgDelegate", "value": { "delegatorAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r", "validatorAddress": "cosmosvaloper17lgg03ze9x6xka02fs0hhw4ad4wwg05heqr2y8", "amount": { "denom": "usei", "amount": "4200" } } } ], "fee": { "amount": [ { "amount": "5953", "denom": "usei" } ], "gas": "238098" }, "memo": "The message", "encodedBody": "0a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d657373616765", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801182312130a0d0a057561746f6d1204353935331092c40e" }, "createdAt": "2023-11-02T11:21:40.810Z" } } ``` * `amount` — amount of tokens to stake. * `currency` — currency of tokens: * `sei` — Sei native staking token. * `usei` — 1 SEI = 10⁶ uSEI. * `msei` — 1 SEI = 10³ mSEI. * `validatorAddress` — validator (A network participant responsible for proposing new blocks under a Proof-of-Stake consensus model, validating transactions, and securing a blockchain through staking tokens. Validators play a crucial role in maintaining the security and integrity of the network.) address to which tokens are delegated. * `stashAccountAddress` — delegator stash account address which keeps tokens. * `rewardDestinationAddress` — reward destination account address. * `createdAt` — timestamp of the transaction in the ISO 8601 format. `transactionData` is the list of data fields to be used to construct the staking transactions: * `messages`: * `typeUrl` — Sei network operation type. * `delegatorAddress` — delegator address. * `validatorAddress` — validator address. * `amount` — amount of tokens to stake. * `currency` — currency of tokens. * `fee` — fee charged for the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `sei`, `usei`, or `msei`. * `gas` — amount of gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. **2. Sign and send transaction** Use `transactionData` to [sign and send](/docs/signing-transaction-sei) the signed transaction to the Sei network. To check the transaction status, send a GET request to [/api/v1/sei/\{network}/transaction/status/\{transactionHash}](/reference/get-sei-transaction-status). Example request (for `atlantic-2` network): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47 \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", { method: "GET", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/sei/atlantic-2/transaction/status/ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47", nil) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `transactionHash` — hash of the transaction. Example response: ```json theme={null} { "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } } ``` * `status` — transaction status: `success`, `failed`. * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in SEI charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit that the transaction initiator was willing to consume for the transaction. * `transactionHash` — hash of the transaction. # Getting Started Source: https://docs.p2p.org/docs/staking-solana Stake on Solana programmatically with the P2P.org Staking API. Staking in the Solana network using the Staking API consists of several main steps: 1. Create a staking request. 2. Sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create staking request** Send a POST request to [/api/v1/solana/\{network}/staking/stake](/reference/solana-staking-stake). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/solana/testnet/staking/stake \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data '{ "feePayer": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "fromPublicKey": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "amount": "1002282880", "stakeAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf" }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/solana/testnet/staking/stake", { method: "POST", headers: { "Accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ feePayer: "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", fromPublicKey: "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", amount: "1002282880", stakeAuthority: "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", withdrawAuthority: "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", }), } ); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/solana/testnet/staking/stake", headers={ "Accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "feePayer": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "fromPublicKey": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "amount": "1002282880", "stakeAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", }, ) ``` ```go Go theme={null} import ( "bytes" "net/http" ) body := []byte(`{ "feePayer": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "fromPublicKey": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "amount": "1002282880", "stakeAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf" }`) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/solana/testnet/staking/stake", bytes.NewBuffer(body)) req.Header.Set("Accept", "application/json") req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) ``` * `feePayer` — account address that will pay the fee for the transaction. * `fromPublicKey` — account address from which the staking account will be created. * `amount` — amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). The minimum amount is `1002282880`. * `stakeAuthority` — account address that can perform staking operations with the staking account. If not specified, rights will be taken from the `fromPublicKey` parameter. * `withdrawAuthority` — account address that can perform withdrawal operations with the staking account. If not specified, rights will be taken from the `fromPublicKey` parameter. Example response: ```json theme={null} { "result": { "feePayer": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "fromPublicKey": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "stakeAccount": "6ZuLUCwVTvuQJrN1HrpoHJheQUw9Zk8CtiD3CEpHiA9E", "stakeAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "amount": "1002282880", "unsignedTransaction": "0xac0406000b00487835a302032c6eca5cdaa3e87d7f8e06d10015bf0508b52d301c8991af113d5cf49a53553f", "createdAt": "2023-08-15T15:07:54.795Z" } } ``` * `feePayer` — account address that will pay the fee for the transaction. * `fromPublicKey` — account address from which the staking account will be created. * `stakeAccount` — account address that stores tokens for staking. * `stakeAuthority` — account address that can perform staking operations with the staking account. * `withdrawAuthority` — account address that can perform withdrawal operations with the staking account. * `amount` — amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). The minimum amount is `1002282880`. * `unsignedTransaction` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. > The transaction exists for one minute. **2. Sign and send transaction** Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-solana) the signed transaction to the Solana network. To check the transaction status, send a GET request to [/api/v1/solana/\{network}/account/staking](/reference/solana-staking-get-staking-account). Example request (for `testnet` network): ```bash theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/solana/testnet/account/staking?stakeAuthorities=7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf&withdrawAuthorities=7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' ``` * `stakeAuthorities` — list of account addresses that can perform staking operations with staking accounts. * `stakeAccounts` — list of staking account addresses. * `withdrawAuthorities` — list of account addresses that can perform withdrawal operations with the staking accounts. * `status` — staking account status: `active`, `inactive`, `activating`, `deactivating`. Example response: ```json theme={null} { "result": { "accounts": [ "amount": 2282881, "stakeAccount": "1298uXQBW2azVA33UonLu2RoouDWkNqsV1rMUrQAy1SN", "withdrawAuthority": "7E5LgJx7w7AfoeA5YgLPZFdBptz18nhdT7hxZuDA9aQf", "stakeAuthority": "AaMC5y1RofbY3unyrahRzyCzsesp7rfGuaGegbAg1Hxb", "voteAccount": "FKsC411dik9ktS6xPADxs4Fk2SCENvAiuccQHLAPndvk", "status": "active" ] } } ``` * `accounts` — list of stake accounts. * `amount` — amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). * `stakeAccount` — account address that stores tokens for staking. * `stakeAuthority` — account address that can perform staking operations with the staking account. * `withdrawAuthority` — account address that can perform withdrawal operations with the staking account. * `voteAccount` — vote account address. * `status` — stake account status: `active`, `inactive`, `activating`, `deactivating`. # Getting Started Source: https://docs.p2p.org/docs/staking-story Stake on Story Protocol programmatically with the P2P.org Staking API. Staking with Story Protocol via the Staking API consists of several main steps: 1. Create a staking request. 2. Sign and send the transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create staking request** Send a POST request to [/api/v1/story/\{network}/staking/stake](/reference/story-staking-stake). Example request (for `aeneid` network): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/story/aeneid/staking/stake \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data '{ "amount": 1024, "delegatorAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", "stakingPeriod": 0, "tokenType": "UNLOCKED", "gas": { "maxFeePerGas": 100, "maxPriorityFeePerGas": 1, "gasLimit": 21000 } }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/story/aeneid/staking/stake", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ amount: 1024, delegatorAddress: "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", stakingPeriod: 0, tokenType: "UNLOCKED", gas: { maxFeePerGas: 100, maxPriorityFeePerGas: 1, gasLimit: 21000, }, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/story/aeneid/staking/stake", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "amount": 1024, "delegatorAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", "stakingPeriod": 0, "tokenType": "UNLOCKED", "gas": { "maxFeePerGas": 100, "maxPriorityFeePerGas": 1, "gasLimit": 21000, }, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "amount": 1024, "delegatorAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", "stakingPeriod": 0, "tokenType": "UNLOCKED", "gas": map[string]interface{}{ "maxFeePerGas": 100, "maxPriorityFeePerGas": 1, "gasLimit": 21000, }, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/story/aeneid/staking/stake", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `amount` — amount of tokens to stake in IP. The minimum stake amount is 1024 IP. * `delegatorAddress` — delegator EVM Story account address. * `stakingPeriod`— staking period duration: * `FLEXIBLE` — no lock-up; funds can be withdrawn at any time. * `SHORT` — 90 days of the lock-up period. * `MEDIUM` — 360 days of the lock-up period. * `LONG` — 540 days of the lock-up period. * `tokenType`— token source type: * `UNLOCKED` — tokens will be locked during staking from the user’s free balance. * `LOCKED`— tokens have already been locked, e.g., via the protocol rules; no additional lock-up applied. * `gas` — optional gas settings to execute the transaction: * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize miners to prioritize this transaction. * `gasLimit` — maximum gas limit for the transaction. Example response: ```json theme={null} { "result": { "unsignedTransaction": "0xf86e808504a817c80082520894c32e3d7c7e6e53d16b9a48d0ae76c70e6adf09f080801ba0f31401df9e6f6d861fdf09d1e69b5f51855f4f63b0179033a6c3871c05ec93da03e0f7d7eab4a3179b29b416d6c75dbe53de763153b7ed9e2c49883c8fca1ef29c", "createdAt": "2025-07-22T12:34:56.789Z" } } ``` * `unsignedTransaction` — unsigned serialized transaction in the hexadecimal format ready for signing. Sign the transaction and submit it to the blockchain to perform the called action. Note that it must be signed and submitted within a limited time window (e.g., 1 minute). * `createdAt` — timestamp of the transaction in the ISO 8601 format. **2. Sign and send transaction** Use `unsignedTransaction` to [sign and send](/docs/signing-transaction-story) the signed transaction to the Story Protocol network. # Getting Started Source: https://docs.p2p.org/docs/staking-sui Stake on Sui programmatically with the P2P.org Staking API. Staking on the Sui network using the Staking API consists of the following main steps: 1. Create a staking request. 2. Sign and broadcast the transaction. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>P2P API: Broadcast signed transaction P2P API->>Blockchain: Submit transaction Blockchain-->>P2P API: Transaction hash P2P API-->>Client: Transaction status ``` **1. Create staking request** Send a POST request to [/api/v1/sui/\{network}/staking/stake](/reference/sui-staking-stake). Example request (for `testnet` network): ```bash curl theme={null} curl --request POST --url 'https://api-test.p2p.org/api/v1/sui/testnet/staking/stake' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "sender": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", "amount": 1000000000, "gasPrice": 1000, "gasBudget": 500000000 }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/sui/testnet/staking/stake", { method: "POST", headers: { "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ sender: "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", amount: 1000000000, gasPrice: 1000, gasBudget: 500000000, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/sui/testnet/staking/stake", headers={ "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "sender": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", "amount": 1000000000, "gasPrice": 1000, "gasBudget": 500000000, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "sender": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", "amount": 1000000000, "gasPrice": 1000, "gasBudget": 500000000, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/sui/testnet/staking/stake", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `sender` — staker account address. * `amount` — amount of tokens to stake in MIST (1 SUI = 10⁹ MIST). * `gasPrice` — price per unit of gas in MIST for processing the Sui transaction. * `gasBudget` — maximum gas limit for the transaction. Example response: ```json theme={null} { "error": null, "result": { "unsignedTransaction": "0x000003000800ca9a3b00000000010100000000000000000000000000000000000000000000000000000000000000050100000000000000010020ab4fb3eeaa7b0ab4f91eedab33adf140c6750e60ca5e44b3df82491937d7bab4020200010100000000000000000000000000000000000000000000000000000000000000000000030a7375695f73797374656d11726571756573745f6164645f7374616b650003010100020000010200696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3024af02b603f7d65cced30be6ed44300d7d9d66522940e501e1a2083cfc25429e5a60bd0140000000020abca58a9797ecf7cc82596d71b4a154f8dd14b18e3190beee205b905611fbfa29c6ca3ef6b075ab6294342fe06c323768659879813e0544d3fd25a7db7875cca440000180000000020405515b0e64b00c04ebdb0517c2a1f07f3e32cba49adf4ea87d4daadc265c1f0696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3e8030000000000000065cd1d0000000000" } } ``` * `unsignedTransaction` — serialized unsigned transaction in the hexadecimal format. Sign the transaction and submit it to the blockchain to perform the called action. **2. Sign and send transaction** Use `unsignedTransaction` from the previous step to [sign and send](/docs/signing-transaction-sui) the signed transaction to the Sui network. Check your staking position and status by sending a GET request to [/api/v1/sui/\{network}/transaction/stake-list/\{address}](/reference/sui-transaction-get-stake-list). Example request (for `testnet` network): ```bash curl theme={null} curl --request GET --url 'https://api-test.p2p.org/api/v1/sui/testnet/transaction/stake-list/0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3' \ --header 'Authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/sui/testnet/transaction/stake-list/0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", { method: "GET", headers: { "Authorization": "Bearer ", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/sui/testnet/transaction/stake-list/0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", headers={ "Authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/sui/testnet/transaction/stake-list/0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", nil) req.Header.Set("Authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `network` — Sui network: `mainnet` or `testnet`. * `address` — staker account address. Example response: ```json theme={null} { "error": null, "result": { "validatorAddress": "0xab4fb3eeaa7b0ab4f91eedab33adf140c6750e60ca5e44b3df82491937d7bab4", "stakerAddress": "0x696f4402d7151fb49e52b629de3ce3098f3dda7721a7425c000b4f26653709e3", "stakes": [ { "stakeId": "0x5d920b8fca6a6043d898ab1a9a8ab167d8aa323fe2b9e76a27312f7f16e20a67", "amount": 1000000000, "status": "Pending" } ] } } ``` * `validatorAddress` — validator address. * `stakerAddress` — staker account address. * `stakes` — detailed information on each stake: * `stakeId` — identifier of the stake, which is required to perform a withdrawal later. * `amount` — amount of tokens to stake in MIST (1 SUI = 10⁹ MIST). * `status` — staking transaction status: * `pending` — stake has been submitted and is awaiting activation. Activation may take up to 12 hours depending on validator configuration. * `active` — stake is active and earning rewards. * `unstaked` — stake has been withdrawn. # Getting Started Source: https://docs.p2p.org/docs/staking-ton Stake on TON programmatically with the P2P.org Staking API. There are two ways to start staking on the TON network using the Staking API: * Stake individually with a validator via a single nominator pool * Stake along with multiple nominators via [Ton Whales pools](https://tonwhales.com/staking) > [!WARNING] > > **Action Required: Single Nominator Pools** > > This is an alternative type of the TON smart contract designed for validators that have enough self stake to validate by themselves without relying on third-party nominators stakes. > > The single nominator staking flow requires manual activation. Before you begin, please contact the [P2P team](/docs/contacts) to whitelist your wallet address. > > *Note: Attempting to stake without pre-registration will result in validation error.* For both flows, to start using the Staking API: 1. Create a staking request. 2. Sign and broadcast the staking transaction to the network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant Blockchain Client->>P2P API: Create stake transaction P2P API-->>Client: Unsigned transaction Client->>Client: Sign transaction locally Client->>Blockchain: Broadcast signed transaction Blockchain-->>Client: Transaction hash ``` **1. Create staking request** Depending on the type of your staking pool, send a POST request either to [/api/v1/ton/\{network}/staking/single-nominator/stake](/reference/ton-staking-single-nominator-stake) or to [/api​/v1​/ton​/\{network}​/staking​/ton-whales​/stake](/reference/ton-staking-ton-whales-stake). Example request (in the `testnet` network for a single nominator pool): ```bash curl theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/stake \ --header 'accept: application/json' \\ --header 'authorization: Bearer ' \\ --header 'content-type: application/json' \\ --data ' { "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", "amount": 20000000000, "walletVersion": "V4" }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/stake", { method: "POST", headers: { "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, body: JSON.stringify({ publicKey: "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", amount: 20000000000, walletVersion: "V4", }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/stake", headers={ "accept": "application/json", "authorization": "Bearer ", "content-type": "application/json", }, json={ "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", "amount": 20000000000, "walletVersion": "V4", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", "amount": 20000000000, "walletVersion": "V4", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/ton/testnet/staking/single-nominator/stake", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("authorization", "Bearer ") req.Header.Set("content-type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `publicKey` — public key of the nominator for the TON network. * `amount` — amount of tokens to stake in nanoGRAMs (1 GRAM = 10⁹ nanoGRAMs). Note that the minimum staking amount is not limited, but there is a maximum cap of 2 000 000 GRAM for each pool. * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain: * `V3R1` and `V3R2` — wallet V3. * `V4` — wallet V4; used by default. * `V5R1` — wallet V5. Example response: ```json theme={null} { "error": null, "result": { "unsignedTransaction": "b5ee9c7241010101003800006b000010000000000000000001000000039fedeab7a2b56b38f19f60b5b9f70b2f1ba2d89b9c5a756036c7cfad73571fb281887735940193456f7e", "walletVersion": "V4", "stakerAddress": "0QDZncytCDTPJylG1POFhqzeCLDFZNKhJ2v73lcsBNjQHMZx", "publicKey": "7031f1dcbe0f670daf4094d04ff9a7947bc4ac9174a7d470255d1a664e20b7c6", "amount": 2 } } ``` * `unsignedTransaction` — unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) in the hexadecimal format. Sign the transaction and submit it to the blockchain to create a staking request. * `poolAddress` — nominator pool address (for Ton Whales pools). * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. * `stakerAddress` — main account address of the bounceable (On TON, the bounceable address format protects users from erroneous transfers. If some issue happens during the transaction, the message will be “bounced” back to the sender and constitute the remainder of the original value of the transaction with the deduction of all transfer and gas fees. This ensures the sender doesn't lose their funds that were sent by accident to an address that cannot accept the transaction. This format is also the simplest and most readable, and it is used by regular users for standard transactions on the network.) type which keeps tokens. * `publicKey` — public key of the nominator for the TON network. * `amount` — amount of tokens to stake in TON. **2. Sign and broadcast transaction** [Sign and broadcast](/docs/signing-transaction-ton) the `unsignedTransaction` to the TON network. To check the transaction status, send a GET request to [/api/v1/ton/\{network}/transactions/status/\{address}/\{transactionHash}](/reference/ton-staking-transaction-status). Example request (in the `testnet` network for a single nominator pool): ```bash curl theme={null} curl --request GET \ --url https://api-test.p2p.org/api/v1/ton/testnet/transactions/status/{transactionHash} \ --header 'accept: application/json' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/ton/testnet/transactions/status/{transactionHash}", { method: "GET", headers: { "accept": "application/json", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/ton/testnet/transactions/status/{transactionHash}", headers={ "accept": "application/json", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/ton/testnet/transactions/status/{transactionHash}", nil) req.Header.Set("accept", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `address` — staker account address. * `transactionHash` — hash of the transaction. Example response: ```json theme={null} { "error": null, "result": { "address": "0QC1f6DghlW6w31D7GWiYt0dZvX1SR3sGAsto_AhdQRFBobh", "lt": "27726830000001", "prevTransactionHash": "6210303f3cfb630c349b3859d9e367a65a6772938c681774e2a315aa95c80224", "prevTransactionLt": "1234567890abcdef", "now": 1730905768, "outMessagesCount": 1, "oldStatus": "active", "endStatus": "active", "transactionHash": "2829e4bb8a7b8084040c731a07523d680ce30fecef12f8eec1e409f3c6077a5e" }, } ``` * `address` — staker account address. * `lt` — logical time of the last transaction created by this staker account. * `prevTransactionHash` — hash of the previous transaction. * `prevTransactionLt` — logical time of the previous transaction. * `now` — current time on the TON blockchain node. * `outMessagesCount` — count of output messages sent by the smart contract in the result of this transaction. * `oldStatus` — staker account status before transaction execution. * `endStatus` — staker account status after transaction execution. * `transactionHash` — hash of the transaction. # Getting Started Source: https://docs.p2p.org/docs/staking-tron Stake on TRON programmatically with the P2P.org Staking API. Staking on the TRON network using the Staking API consists of the following main steps: 1. Create a delegate request: freeze tokens to gain voting power. 2. Create a voting request to vote for the Super Representatives. After each step, sign and broadcast the transaction to the TRON network. [Get an authentication token](/docs/authentication) to start using Staking API. Request examples are provided using [cURL](https://curl.se/). ```mermaid theme={null} sequenceDiagram participant Client participant P2P API participant TRON Client->>P2P API: Create freeze (delegate) transaction P2P API-->>Client: Unsigned freeze transaction Client->>Client: Sign transaction locally Client->>TRON: Broadcast freeze transaction TRON-->>Client: Freeze confirmed Client->>P2P API: Create vote transaction P2P API-->>Client: Unsigned vote transaction Client->>Client: Sign transaction locally Client->>TRON: Broadcast vote transaction TRON-->>Client: Vote confirmed ``` **1. Create delegate request** To freeze tokens, send a POST request to [/api/v1/tron/\{network}/staking/delegate](/reference/tron-staking-delegate). Example request (for `testnet-nile` network): ```bash curl theme={null} curl --request POST \ --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/delegate' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 1000000, "resource": "BANDWIDTH" }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/delegate", { method: "POST", headers: { "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ delegatorAddress: "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", amount: 1000000, resource: "BANDWIDTH", }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/delegate", headers={ "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 1000000, "resource": "BANDWIDTH", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 1000000, "resource": "BANDWIDTH", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/delegate", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `delegatorAddress` — delegator account address. * `amount` — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN). Note that only TRX (SUN) can be delegated, since USDT (TRC-20) is not natively stakeable. * `resource` — type of resources to be used for processing the TRON transaction: * `BANDWIDTH` — for regular transactions on the TRON chain. * `ENERGY` — for using smart contracts or running DApps. Example response: ```json theme={null} { "error": null, "result": { "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 10000000, "resource": "BANDWIDTH", "unsignedTransaction": { "visible": false, "txID": "98c15dc006cbe2f978ea2f25940703bbafecd89161f92f54eaeb82691faf34ec", "raw_data_hex": "0a02ba6b2208475fc5c8083be91340989888aef3325a55083612510a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e747261637412190a1541700ca9ad5f162f9de000558ff04eef8f99dce7e8100170b8c384aef332", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41700ca9ad5f162f9de000558ff04eef8f99dce7e8", "frozen_balance": 1000000 }, "type_url": "type.googleapis.com/protocol.FreezeBalanceV2Contract" }, "type": "FreezeBalanceV2Contract" } ], "ref_block_bytes": "ba6b", "ref_block_hash": "475fc5c8083be913", "expiration": 1748953599000, "timestamp": 1748953539000 } }, "unsignedTransactionSerialized": "eyJ0eElEIjoidHJ4SWQifQ==", "createdAt": "2025-06-03T12:25:40.347Z", "voteAccount": "TH7Fe1W8CcLeqN4LGfqX1R9EpsnrJBQJji" } } ``` * `delegatorAddress` — delegator account address. * `amount` — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN). * `resource` — type of resources used for processing the freeze transaction: `BANDWIDTH` or `ENERGY`. * `unsignedTransaction` — original unsigned transaction object returned by tronWeb. * `visible` — internal SDK parameter; always set to `false`. * `txID` — hash of the transaction. * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format. * `raw_data` — full decoded transaction structure with all the fields and metadata: * `contract` — list of TRON contracts: * `parameter.type_url` — TRON protocol contract, e.g., `type.googleapis.com/protocol.FreezeBalanceV2Contract`. * `parameter.value.owner_address `— TRON account address in the hexadecimal format. * `parameter.value.frozen_balance` — amount of tokens used for voting in SUN (1 TRX = 10⁶ SUN). * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included. * `expiration` — timestamp of the transaction expiration in ms since last epoch. * `timestamp` — timestamp of the transaction in ms since last epoch. * `unsignedTransactionSerialized` — unsigned serialized transaction in Base64 encrypted format ready for signing. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `voteAccount` — address of the Super Representative for voting. **2. Sign and send transaction** Use `unsignedTransactionSerialized` to [sign and send](/docs/signing-transaction-tron) the signed transaction to the TRON network. **3. Create voting request** To vote for the P2P Super Representative using your frozen TRX, send a POST request to [/api/v1/tron/\{network}/staking/vote](/reference/tron-staking-vote). Example request (for `testnet-nile` network): ```bash curl theme={null} curl --request POST \ --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/vote' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "voteCount": 3 }' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/vote", { method: "POST", headers: { "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, body: JSON.stringify({ delegatorAddress: "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", voteCount: 3, }), } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.post( "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/vote", headers={ "accept": "application/json", "Authorization": "Bearer ", "Content-Type": "application/json", }, json={ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "voteCount": 3, }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { payload := map[string]interface{}{ "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "voteCount": 3, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api-test.p2p.org/api/v1/tron/testnet-nile/staking/vote", bytes.NewBuffer(body)) req.Header.Set("accept", "application/json") req.Header.Set("Authorization", "Bearer ") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `delegatorAddress` — delegator account address used for freezing tokens. * `voteCount` — number of votes to delegate to the default vote account; equal to the amount of frozen tokens. To delegate all available votes, specify 0. Example response: ```json theme={null} { "error": null, "result": { "delegatorAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "voteAccount": "TH7Fe1W8CcLeqN4LGfqX1R9EpsnrJBQJji", "voteCount": 3, "unsignedTransaction": { "visible": false, "txID": "a9283ebb983e932d40bc1fad0a34457acd9922875a27705d76afb2fc62ceb668", "raw_data_hex": "0a020e0c22087db974037137d39c4090bde5ccf3325a6a080412660a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412320a1541da53d324a354aa5924c7117caff3ead97910a5e112190a1541351b95e29c2514b7b8183cbc81a8e08c68e8833b100370b0e8e1ccf332", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1", "votes": [ { "vote_address": "41351b95e29c2514b7b8183cbc81a8e08c68e8833b", "vote_count": 3 } ] }, "type_url": "type.googleapis.com/protocol.VoteWitnessContract" }, "type": "VoteWitnessContract" } ], "ref_block_bytes": "0e0c", "ref_block_hash": "7db974037137d39c", "expiration": 1749018042000, "timestamp": 1749017982000 } } }, "unsignedTransactionSerialized": "eyJ0eElEIjoidHJ4SWQifQ==", "createdAt": "2025-06-04T06:19:42.228Z" } ``` * `delegatorAddress` — delegator account address used for freezing tokens. * `voteAccount` — vote account address of the Super Representative to receive the delegation. * `voteCount` — number of votes delegated to the vote account. * `unsignedTransaction` — original unsigned transaction object returned by tronWeb. * `visible` — internal SDK parameter; always set to `false`. * `txID` — hash of the voting transaction. * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format. * `raw_data` — full decoded transaction structure with all the fields and metadata: * `contract` — list of TRON contracts: * `parameter.type_url` — TRON network operation type, e.g., `type.googleapis.com/protocol.VoteWitnessContract`. * `parameter.value.owner_address `— account address performing the vote in the hexadecimal format. * `parameter.value.votes` — address of the Super Representative and the number of votes. * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included. * `expiration` — timestamp of the transaction expiration in ms since last epoch. * `timestamp` — timestamp of the transaction in ms since last epoch. * `unsignedTransactionSerialized` — unsigned serialized transaction in Base64 encrypted format ready for signing. * `createdAt` — timestamp of the transaction in the ISO 8601 format. **4. Sign and send transaction** Use `unsignedTransactionSerialized` to [sign and send](/docs/signing-transaction-tron) the signed transaction to the TRON network. ## Additional operations ### Get transaction status To check the transaction status by its hash, send a GET request to [/api/v1/tron/\{network}/transaction/\{transactionHash}/status](/reference/tron-transaction-status). Example request (for `testnet-nile` network): ```bash curl theme={null} curl --request GET \ --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/852180cff2cc870d0ff904cbf231d194e6a9d4276f309b016831bd0b1b2212d5/status' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/852180cff2cc870d0ff904cbf231d194e6a9d4276f309b016831bd0b1b2212d5/status", { method: "GET", headers: { "accept": "application/json", "Authorization": "Bearer ", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/852180cff2cc870d0ff904cbf231d194e6a9d4276f309b016831bd0b1b2212d5/status", headers={ "accept": "application/json", "Authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/tron/testnet-nile/transaction/852180cff2cc870d0ff904cbf231d194e6a9d4276f309b016831bd0b1b2212d5/status", nil) req.Header.Set("accept", "application/json") req.Header.Set("Authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `transactionHash` — hash of the transaction. Example response: ```json theme={null} { "error": null, "result": { "transactionHash": "852180cff2cc870d0ff904cbf231d194e6a9d4276f309b016831bd0b1b2212d5", "status": "CONFIRMED", "confirmed": true, "block": 72835612, "energyUsed": 15800, "createdAt": "2025-06-05T12:09:11.892Z" } } ``` * `transactionHash` — hash of the TRON transaction. * `status` — transaction status: `PENDING`, `CONFIRMED` or `FAILED`. * `confirmed` — boolean flag indicating whether the transaction has been included in a block. * `block` — unique identifier of the block in which the transaction has been included; `null` if the transaction has not been confirmed yet. * `energyUsed` — amount of energy points consumed by the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### Get account summary To track delegator account balances, frozen TRX, and voting details, send a GET request to [/api/v1/tron/\{network}/account/\{address}](/reference/tron-account-get). Example request (for `testnet-nile` network): ```bash curl theme={null} curl --request GET \ --url 'https://api-test.p2p.org/api/v1/tron/testnet-nile/account/TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r' \ --header 'accept: application/json' \ --header 'Authorization: Bearer ' ``` ```typescript TypeScript theme={null} const response = await fetch( "https://api-test.p2p.org/api/v1/tron/testnet-nile/account/TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r", { method: "GET", headers: { "accept": "application/json", "Authorization": "Bearer ", }, } ); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( "https://api-test.p2p.org/api/v1/tron/testnet-nile/account/TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r", headers={ "accept": "application/json", "Authorization": "Bearer ", }, ) print(response.json()) ``` ```go Go theme={null} package main import ( "fmt" "io" "net/http" ) func main() { req, _ := http.NewRequest("GET", "https://api-test.p2p.org/api/v1/tron/testnet-nile/account/TNDzfERDpxLDS2w1q6yaFC7pzqaSQ3Bg3r", nil) req.Header.Set("accept", "application/json") req.Header.Set("Authorization", "Bearer ") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() respBody, _ := io.ReadAll(resp.Body) fmt.Println(string(respBody)) } ``` * `address` — TRON account address. Example response: ```json theme={null} { "result": { "address": "TQ5N6Znhy92Yq2a4YDosMkbqygXgU5Ykh", "balance": 250000000, "availableVotes": 500, "usedVotes": 1500, "totalVotes": 2000, "votes": { "TLGQ9jXwWXsy8sxkXoXKVLfV7Qe64Q8Yh1": 1000, "TKTcsyw81V4WsqfK8AYx7zoXvD3QycjCkg": 500 }, "voteList": [ { "voteAddress": "TLGQ9jXwWXsy8sxkXoXKVLfV7Qe64Q8Yh1", "voteCount": 1000 }, { "voteAddress": "TKTcsyw81V4WsqfK8AYx7zoXvD3QycjCkg", "voteCount": 500 } ], "hasEnergyStake": true, "hasBandwidthStake": false, "createdAt": "2025-06-26T19:28:54.816Z", "netUsage": 432, "accountCreatedAt": "2023-09-15T07:20:35.000Z", "lastOperationAt": "2025-06-08T09:17:42.000Z" }, "error": {} } ``` * `address` — address of the TRON account in the base58 format. * `balance` — total amount of tokens in SUN staked by the account (1 TRX = 10⁶ SUN). * `availableVotes` — number of votes available to assign to the Super Representatives. * `usedVotes` — number of votes already used by this address. * `totalVotes` — total number of votes granted to this account based on the total amount of frozen TRX. * `votes` — list of key-value pairs: vote address and the vote count. * `voteList` — list of vote entries for this account: * `voteAddress` — vote account address of the Super Representative received the delegation. * `voteCount` — number of votes delegated to this vote address. * `hasEnergyStake` — boolean flag indicating if the account has frozen TRX for the `ENERGY` type of resources. * `hasBandwidthStake` — boolean flag indicating if the account has frozen TRX for the BANDWIDTH type of resources. * `createdAt` — timestamp of the report generation in the ISO 8601 format. * `netUsage` — total amount of bandwidth points consumed by the account. * `accountCreatedAt` — timestamp of the account creation in the ISO 8601 format. * `lastOperationAt` — timestamp of the last operation performed by the account in the ISO 8601 format. # Operational Notes Source: https://docs.p2p.org/docs/syncro-data-hyperliquid-operational-notes This section describes production behavior that clients should account for when integrating with Hyperliquid Data Stream. ## Ordering Within a single coin, order book diffs are delivered in the same order as they are produced by the node. Ordering is not guaranteed across different coins. Ordering is also not guaranteed across different stream types, including: * Blocks * Order book diffs * Mempool transactions * Metrics * Pings If a client needs to correlate events across streams, it should use timestamps. ## Reconnection Treat every disconnect as a full reset. Hyperliquid Data Stream does not support session resume. After reconnecting, the client should repeat the full connection sequence: ``` connect → esp → prime → subscribe to required coins and streams → continue reading frames ``` Example reconnect sequence: ```json JSON theme={null} {"method":"esp","version":1} {"method":"prime"} {"method":"subscribe","coin":"BTC"} {"method":"subscribe","stream":"mempool"} ``` Clients should not assume that previous subscriptions are preserved after reconnecting. ## No backfill Hyperliquid Data Stream is a live-only stream. Data emitted before a client connects is not replayed. Historical backfill is not part of this service. If a client disconnects, any data emitted during the disconnect window is missed. ## Clock skew The following timestamps are provided by the Hyperliquid node, not by Hyperliquid Data Stream: * `ts_ms` * `wall_ts_us` * `receive_ts_us` If the client’s local clock differs from the node clock, latency calculations against the local clock may look skewed. For latency analysis, prefer differences between server-stamped fields instead of comparing server timestamps against the local client clock. ## Backpressure Clients must continuously read from the WebSocket connection. If a client cannot keep up with the stream, the server may disconnect it. Block frames are strict. Missing a block frame disconnects the client immediately. Other frame types tolerate brief slowdowns, including: * Order frames * Metric frames * Ping frames * Error frames Persistent slowness still results in disconnection. | Close code | Reason | Cause | | - | - | - | | 1013 | `backpressure` | Client is not reading fast enough | | 1001 | `server shutting down` | Server restart or deploy | If the server closes the connection because of a restart or deploy, the client should reconnect after a short delay and repeat the full connection sequence. ## Clean shutdown A clean client-initiated close is safe. The recommended flow is: 1. Send a WebSocket Close frame. 2. Wait for the server’s Close response. 3. Close the local connection. ## Recommended client behavior Production clients should follow these rules: * Use binary mode for production. * Always send `esp` before `prime`. * Re-subscribe after every reconnect. * Read continuously to avoid backpressure. * Do not rely on session resume. * Do not expect historical replay. * Correlate cross-stream events using timestamps. * Use server-stamped timestamp differences for latency analysis. * Handle structured error codes programmatically. ## Recommended production sequence ``` 1. Connect to ws://: 2. Send {"method":"esp","version":1} 3. Send {"method":"prime"} 4. Subscribe to required coins 5. Subscribe to mempool, if needed and available 6. Continuously read and decode frames 7. On disconnect, reconnect and repeat from step 1 ``` Example: ```json JSON theme={null} {"method":"esp","version":1} {"method":"prime"} {"method":"subscribe","coin":"BTC"} {"method":"subscribe","stream":"mempool"} ``` This flow should be treated as the default integration pattern for production clients. # Overview Source: https://docs.p2p.org/docs/syncro-data-hyperliquid-overview Hyperliquid Data Stream is a low-latency WebSocket data service built on top of a Hyperliquid validator node. It provides real-time access to the node-level market and execution data through a single WebSocket connection. Clients can use the stream to receive: * Blocks applied by the node * Per-coin order book diffs * Mempool transactions, when enabled * Timing metrics * Low-latency ping frames * Server-side error events The service is designed for teams that need fast and reliable Hyperliquid data for execution systems, trading infrastructure, monitoring, research, and latency-sensitive workflows. ## How it works Hyperliquid Data Stream runs as a WebSocket service in front of a Hyperliquid node. Clients connect to the provided endpoint, subscribe to the required data streams, and receive real-time updates as soon as they are available from the node. The service supports two modes: | Mode | Purpose | Recommended use | | - | - | - | | JSON mode | Simple text-based order book diffs | Quick testing and inspection | | Binary mode | Blocks, orders, metrics, pings, and mempool data | Production integrations | JSON mode is useful for a quick smoke test. For production, use binary mode. ## Endpoint Hyperliquid Data Stream speaks WebSocket over plain TCP. ``` ws://: ``` The endpoint URL is provided during onboarding. **Important**: The service uses `ws://`, not `wss:/`. ## Access control Access is granted per source IP at the network layer. If a client’s egress IP changes, the new IP must be added to the allowlist. Otherwise, the TCP connection may hang or time out. ## Limits | Limit | Value | What happens if exceeded | | - | - | - | | Connections per source IP | 4 | A new connection is accepted and then immediately closed | | Read rate | See [Backpressure](/docs/syncro-data-hyperliquid-operational-notes#backpressure) section | Slow clients are disconnected | # Getting Started Source: https://docs.p2p.org/docs/syncro-data-hyperliquid-quick-start This section shows how to connect to Hyperliquid Data Stream and start receiving data. ## Quick inspection with JSON mode By default, the connection starts in JSON mode. In this mode, the server sends text frames with order book diffs for subscribed coins. Example: subscribe to BTC order book diffs. ```bash bash theme={null} # Using websocat: https://github.com/vi/websocat echo '{"method":"subscribe","coin":"BTC"}' \ | websocat ws://: ``` You should start receiving newline-delimited JSON order book diff events almost immediately. Example response: ```json JSON theme={null} {"coin":"BTC","time":"...","side":"A","px":"72223.0","sz":"0","oid":123,"user":"0x..."} {"coin":"BTC","time":"...","side":"B","px":"72182.0","sz":"0.3","oid":456,"user":"0x..."} ``` JSON mode only delivers order book diffs. It does not deliver: * Block frames * Ping frames * Timing metrics * Mempool transactions For production use, use binary mode. ## Production flow with binary mode Production clients should use the following connection sequence: 1. Connect to the WebSocket endpoint. 2. Send `esp` to upgrade to binary mode. 3. Send `prime` to enable pings, metrics, and server error events. 4. Subscribe to required coins or streams. 5. Read frames continuously. 6. On disconnect, reconnect and repeat the full sequence. Example sequence: ```json JSON theme={null} {"method":"esp","version":1} {"method":"prime"} {"method":"subscribe","coin":"BTC"} ``` To subscribe to the mempool stream: ```json JSON theme={null} {"method":"subscribe","stream":"mempool"} ``` The mempool stream may not be enabled on every Hyperliquid Data Stream instance. If it is not available, the server returns a non-disconnecting error. ## Rust client example A complete Rust client is available in the example client implementation. It connects to the stream, upgrades to binary mode, subscribes to one coin, and prints decoded frames. Run: ```rust Rust theme={null} cargo run --example client -- ws://: BTC ``` Required dependencies: ```rust Rust theme={null} [dependencies] tokio = { version = "1", features = ["full"] } tokio-tungstenite = "0.26" futures-util = "0.3" ``` Example connection sequence: ```rust Rust theme={null} let (ws, _) = connect_async(&url).await?; let (mut tx, mut rx) = ws.split(); // 1. Upgrade to binary protocol. tx.send(Message::Text( format!(r#"{{"method":"esp","version":{BINARY_VERSION}}}"#).into(), )) .await?; // 2. Enable prime streams: pings, metrics, and server errors. tx.send(Message::Text(r#"{"method":"prime"}"#.into())).await?; // 3. Subscribe to order book diffs for one coin. tx.send(Message::Text( format!(r#"{{"method":"subscribe","coin":"{coin}"}}"#).into(), )) .await?; ``` To add the mempool stream: ```rust Rust theme={null} tx.send(Message::Text( r#"{"method":"subscribe","stream":"mempool"}"#.into() )) .await?; ``` The read loop should continuously consume incoming frames and dispatch them by tag. # Protocol Reference Source: https://docs.p2p.org/docs/syncro-data-hyperliquid-reference Every client-to-server message is a JSON text frame with a required method field. Invalid JSON, missing required fields, or unknown methods may disconnect the client with a structured error. ## Client messages ### subscribe Subscribes the client to a coin or stream. Subscribe to order book diffs for a coin: ```json JSON theme={null} {"method":"subscribe","coin":"BTC"} ``` The `coin` value must be a non-empty string. Subscribing twice to the same coin is safe and idempotent. Subscribe to mempool transactions: ```json JSON theme={null} {"method":"subscribe","stream":"mempool"} ``` Currently, the only valid stream value is `mempool`. If the mempool stream is not enabled on the server, the server replies with a non-disconnecting `mempool_unavailable` error. ### unsubscribe Unsubscribes from a coin or stream. ```json JSON theme={null} {"method":"unsubscribe","coin":"BTC"} ``` ```json JSON theme={null} {"method":"unsubscribe","stream":"mempool"} ``` ### esp Upgrades the connection to binary protocol mode. ```json JSON theme={null} {"method":"esp","version":1} ``` The version field must match the server binary protocol version. Current binary protocol version: `1`. If the version does not match, the client is disconnected with the `version_mismatch` error. ### prime Enables additional binary streams after `esp`. ```json JSON theme={null} {"method":"prime"} ``` After `prime`, the client can receive: * Ping frames * Timing metrics * Server error events `prime` must be sent after `esp`. Calling `prime` before `esp` disconnects the client with the `not_esp` error. ### unprime Disables the additional prime streams. ```json JSON theme={null} {"method":"unprime"} ``` Like `prime`, this must be called after `esp`. ## JSON mode JSON mode is the default mode before `esp` is sent. In this mode, server-to-client frames are text frames containing newline-delimited JSON order book diffs. A single WebSocket frame may contain multiple JSON lines separated by `\n`. Example: ```json JSON theme={null} {"coin":"BTC","time":"...","side":"A","px":"72223.0","sz":"0","oid":123,"user":"0x..."} {"coin":"BTC","time":"...","side":"B","px":"72182.0","sz":"0.3","oid":456,"user":"0x..."} ``` JSON mode is intended for quick testing and inspection. For production integrations, use binary mode. ## Binary mode After `esp`, all server-to-client data frames are binary WebSocket frames. The first byte of every frame is a tag that identifies the frame type. All multi-byte integers are little-endian. | Tag | Type | Size | When it is received | | - | - | - | - | | 0 | Block | 33 bytes | After every block applied by the node | | 1 | TinyOrder | Variable | For each order book diff on a subscribed coin | | 2 | Metric | Variable | After every block, only after `prime` | | 3 | Ping | 9 bytes | Roughly every 5 ms, only after `prime` | | 4 | MempoolTx | Variable | For each mempool transaction, when subscribed | ## Block frame Tag: ``` 0 ``` Size: ``` 33 bytes ``` Block frames are emitted after every block applied by the node. Layout: ``` offset size field notes ──────────────────────────────────────────────────────────── 0 1 tag Always 0 1 8 ts_ms Block timestamp, ms since UNIX epoch 9 8 height Block height 17 8 wall_ts_us Node-local wall clock, µs since epoch 25 8 apply_duration_us Time spent applying the block ``` Node-side block latency can be calculated as: ``` wall_ts_us - (ts_ms * 1000) ``` ## TinyOrder frame Tag: ``` 1 ``` Size: ``` Variable ``` TinyOrder frames are emitted for order book diffs on subscribed coins. All strings are length-prefixed with a single u8 byte. The following fields are encoded as UTF-8 decimal strings and should be parsed as text: * `coin` * `price` * `qty` * `user` Layout: ``` offset size field ──────────────────────────────────────────────────────────── 0 1 tag = 1 1 8 oid, u64 little-endian 9 1 is_buyer, 1 = buy, 0 = sell 10 1 status, 1 = open, 0 = canceled 11 1 + N coin, for example "BTC" ... 1 + N price, for example "72223.0" ... 1 + N qty, for example "0.3" ... 1 + N user, hex address ``` Both opens and cancels arrive as TinyOrder frames. A full cancel is represented as: ``` status = 0 qty = "0" ``` Partial fills are not surfaced as separate events. Instead, the resting order quantity changes. ## MempoolTx frame Tag: ``` 4 ``` Size: ``` Variable ``` MempoolTx frames are emitted for mempool transactions when the client is subscribed to the mempool stream. These frames can be large because the payload is length-prefixed with a `u32`. Layout: ``` offset size field ──────────────────────────────────────────────────────────── 0 1 tag = 4 1 8 receive_ts_us, node first saw the tx, µs since epoch 9 32 tx_hash, raw 32-byte hash 41 4 payload_len, u32 little-endian 45 N payload, signed-action bundle as raw JSON ``` ## Error frames Errors are delivered as JSON text frames. Example: ```json JSON theme={null} {"channel":"errors","code":"","message":""} ``` The `code` field is a stable contract and can be used programmatically. The `message` field is intended for humans and may change. | Code | Meaning | Disconnects? | | - | - | - | | `invalid_json` | Text frame was not valid JSON | Yes | | `missing_method` | JSON frame had no `method` field | Yes | | `unknown_method` | Method value is not recognized | Yes | | `missing_param` | Required `coin`, `stream`, or `version` field is missing | Yes | | `empty_coin` | Subscribe was called with an empty coin string | No | | `unknown_stream` | Stream value is not supported | No | | `mempool_unavailable` | Mempool stream is not enabled on this server | No | | `version_mismatch` | `esp` version does not match the server version | Yes | | `not_esp` | `prime` or `unprime` was called before `esp` | Yes | After `prime`, clients may also receive informational server error events. These do not necessarily indicate a client-side issue. # Overview Source: https://docs.p2p.org/docs/syncro-data-sui-overview Syncro Sui Data Stream is a low-latency transaction streaming product that provides direct access to Sui network transaction flow in real time. The service allows external clients to observe transactions across multiple stages of their lifecycle — from initial network ingress through consensus ordering to final execution — and submit transactions directly into the network pipeline. The API is designed for latency-sensitive infrastructure, trading, analytics, and indexing workloads that require fast access to live transaction data before it becomes available through public RPC infrastructure. The `/v1/*` route family exposes WebSocket and HTTP endpoints for: * observing incoming transactions * monitoring consensus-ordered transactions * consuming post-execution transaction data and events * submitting transactions directly to the network All `/v1/*` payloads are serialized with BCS. Each WebSocket frame contains one complete BCS document with no additional envelope or framing layer. ## Route catalogue | Method | Path | Protocol | Payload (BCS-encoded) | | - | - | - | - | | GET | /v1/incoming | ws | `sui_types::transaction::Transaction` | | GET | /v1/accepted | ws | `consensus_core::block::SignedBlock` | | GET | /v1/pending | ws | `PendingTxStreamMessage` | | GET | /v1/executed | ws | `TxStreamMessage` | | POST | /v1/submit-tx | HTTP | request body: `Transaction`; response: `text/plain` | Server may send WebSocket `Ping` frames every \~30 s; respond with `Pong` (most client libraries do this automatically). Slow subscribers whose receive mailboxes stay full are dropped. # Stream Semantics Source: https://docs.p2p.org/docs/syncro-data-sui-stream-semantics ## Latency ordering For a transaction that this validator ends up seeing: ``` /v1/incoming ≈ /v1/accepted → /v1/pending → /v1/executed ``` * `/v1/incoming` fires the moment a client submits a transaction **directly to this validator** over the standard Sui gRPC endpoint, *before* the validator runs any validation or signature check. Frames may include transactions that are later rejected as invalid. * `/v1/accepted` fires at network ingress when any peer block arrives at this validator, *before* block verification. Each block carries many transactions; the same transaction may appear in multiple blocks (peers often re-propose). Frames may include transactions that never commit. * `/v1/pending` fires after consensus has ordered the transaction but before execution. One frame per ordered transaction. * `/v1/executed` fires after execution, carrying the full transaction data plus effects and events. ## /v1/incoming coverage `/v1/incoming` only emits transactions that arrive **at this validator’s own gRPC submit endpoint**. Most Sui clients submit to a single validator, so each individual validator sees only a fraction of network-wide transactions on this stream. The benefit is **latency**: it’s the earliest possible point of observation — the bytes are emitted before any deserialize/validate work runs. For complete coverage of all transactions reaching the network, subscribe to `/v1/accepted` as well. `/v1/accepted` sees every block proposed by every peer, so it eventually includes every transaction the network agrees on — at the cost of duplication and some phantom transactions. ## Reconciliation Frames on `/v1/incoming` and `/v1/accepted` are *speculative*: a transaction appearing there may be rejected later in the pipeline. If execution certainty matters, cross-reference by transaction digest against `/v1/pending` or `/v1/executed`. # Submission & Versioning Source: https://docs.p2p.org/docs/syncro-data-sui-submission-and-versioning ## POST /v1/submit-tx Submit a transaction directly to consensus. **Request**: * Method: POST * Body: raw BCS-encoded `Transaction` (same format as `/v1/incoming`’s frames). `Content-Type` is ignored. * Maximum body size: 256 KiB. **Response**: | Status | Body | Meaning | | - | - | - | | 200 | `ok` | Handed to consensus. Acceptance is pending and not guaranteed. | | 400 | `invalid BCS transaction` | The body did not decode as a BCS Transaction | | 500 | `transaction rejected` | Consensus refused the transaction | | 503 | `consensus not ready` | Validator booting; retry later | A 200 response means the validator forwarded the transaction to its consensus adapter — it does **not** guarantee the transaction will be included in a committed block. Confirm via `/v1/pending` (for ordering) or `/v1/executed` (for execution). ## Versioning policy * The `/v1/*` family is the supported, stable contract for external clients. * Future additive changes (new optional fields on serializable structs, new enum variants for system-only kinds) may land within `/v1/*` provided they preserve backward-compatible BCS deserialization for existing fields. * Breaking changes will be published under a new `/v2/*` prefix; `/v1/*` will continue to be served alongside for a documented transition window. * Each `/v1/*` route maintains its own independent subscriber pool. # Wire Formats & BCS Conventions Source: https://docs.p2p.org/docs/syncro-data-sui-wire-formats Wire formats and BCS conventions used by the Syncro Sui data endpoints. For every route below, two equivalent descriptions are given: * **Rust client**: code snippet assuming you depend on `sui-types` (and `consensus-core` for `/v1/accepted`). * **Raw BCS schema**: structural description for clients that cannot import Sui crates. The raw schemas reference sui-types primitives (`SenderSignedData`, `TransactionEffects`, `TransactionEvents`, etc.) which are themselves complex nested BCS types. The canonical authoritative definitions live in the Sui source tree under `crates/sui-types/src/`; many language ecosystems also ship Sui-SDK packages with type-equivalent decoders. ## BCS encoding conventions * Fields are emitted in struct-declaration order with no field names. * Fixed-size `[u8; N]` arrays serialize as `N` length-prefixed bytes — the length prefix is a ULEB128 byte (`0x20` for 32-byte digests). * `u8/u16/u32/u64` are little-endian. * `Vec` = ULEB128 length, then `length` consecutive `T` values. * `Option` = `0x00` (None) or `0x01 ` (Some). * Enums = ULEB128 variant index, then variant payload. * `String` = `Vec` (UTF-8 bytes with a length prefix). ## /v1/incoming — BCS Transaction Each WS frame is one BCS-encoded `sui_types::transaction::Transaction`, byte-identical to the bytes the submitting client sent to the validator’s gRPC endpoint. `Transaction` is `Envelope`. `EmptySignInfo` is a zero-sized unit struct, so the on-wire bytes equal a bare `SenderSignedData`. **Rust client**: ```bash bash theme={null} use sui_types::transaction::Transaction; let tx: Transaction = bcs::from_bytes(&frame)?; let digest = tx.digest(); // &TransactionDigest let sender = tx.transaction_data().sender(); // SuiAddress ``` **Raw BCS schema**: ```bash bash theme={null} Transaction := SenderSignedData SenderSignedData := Vec SenderSignedTransaction := { intent_message: IntentMessage, tx_signatures: Vec, } IntentMessage := { intent: Intent (3 bytes — scope, version, app_id, each u8), value: T, } ``` `TransactionData`, `GenericSignature`, etc. are defined in `sui-types/src/transaction.rs` and `sui-types/src/crypto.rs`. Most Sui SDKs already include decoders. ## /v1/accepted — BCS SignedBlock Each WS frame is one BCS-encoded `consensus_core::block::SignedBlock` — exactly the bytes the validator received on the wire from a peer. One block contains many transactions; each transaction inside is itself a BCS-encoded `ConsensusTransaction`. **Rust client (using consensus-core’s helper)**: ```bash bash theme={null} use sui_types::messages_consensus::ConsensusTransaction; use consensus_core::extract_transactions_from_signed_block_bytes; let raw_txs = extract_transactions_from_signed_block_bytes(&frame)?; for raw in raw_txs { let consensus_tx: ConsensusTransaction = bcs::from_bytes(&raw)?; if let Some(user_tx) = consensus_tx.kind.into_user_transaction() { let digest = user_tx.digest(); let sender_signed = user_tx.into_data(); // … your processing … } // else: system message, skip } ``` **Raw BCS schema**: ```bash bash theme={null} SignedBlock := { inner: Block, signature: Vec, // BCS Bytes — length-prefixed } Block := enum { 0x00: BlockV1, 0x01: BlockV2, } BlockV1 := { epoch: u64, round: u32, author: u32, // AuthorityIndex timestamp_ms: u64, ancestors: Vec, transactions: Vec, // user/system txs in the block commit_votes: Vec, misbehavior_reports: Vec, } BlockV2 := { epoch: u64, round: u32, author: u32, timestamp_ms: u64, ancestors: Vec, transactions: Vec, transaction_votes: Vec, // extra vs V1 commit_votes: Vec, misbehavior_reports: Vec, } ConsensusTx := { data: Vec, // BCS-encoded ConsensusTransaction (see below) } BlockRef := { round: u32, author: u32, digest: [u8; 32], // BCS: 0x20 prefix + 32 digest bytes } ConsensusTransaction := { tracking_id: [u8; 8], kind: ConsensusTransactionKind, } ConsensusTransactionKind := enum { // … many system-message variants — skip … UserTransaction(Transaction), // legacy V1 UserTransactionV2(TransactionWithClaims), // … more system variants — skip … } TransactionWithClaims := { tx: SenderSignedData, claims: Vec, } ``` The variant indices for `ConsensusTransactionKind` are stable; the exact index of `UserTransaction` and `UserTransactionV2` is defined in `sui-types/src/messages_consensus.rs`. Non-user variants can be skipped. For each `UserTransaction*` you encounter, the inner `SenderSignedData` is identical in shape to the `/v1/incoming` payload. `CommitVote, BlockTransactionVotes, MisbehaviorReport, TransactionClaim` are defined in `consensus-core/src/{block,commit}.rs` and `sui-types/src/messages_consensus.rs`. ## /v1/pending — BCS PendingTxStreamMessage ```bash bash theme={null} pub struct PendingTxStreamMessage { pub tx_digest: TransactionDigest, pub sender_signed_data: SenderSignedData, pub consensus_round: u64, pub timestamp_ms: u64, } ``` **Rust client**: ```javascript JavaScript theme={null} let msg: PendingTxStreamMessage = bcs::from_bytes(&frame)?; ``` **Raw BCS schema**: ```bash bash theme={null} PendingTxStreamMessage := { tx_digest: [u8; 32], // wire: 0x20 prefix + 32 bytes sender_signed_data: SenderSignedData, // same shape as /v1/incoming consensus_round: u64, timestamp_ms: u64, // milliseconds since unix epoch } ``` System transactions are filtered server-side and never appear on this stream. ## /v1/executed — BCS TxStreamMessage ```bash bash theme={null} pub struct TxStreamMessage { pub tx_digest: TransactionDigest, pub sender: SuiAddress, pub sender_signed_data: SenderSignedData, pub effects: TransactionEffects, pub events: TransactionEvents, pub timestamp_ms: u64, } ``` **Rust client**: ```javascript JavaScript theme={null} let msg: TxStreamMessage = bcs::from_bytes(&frame)?; ``` **Raw BCS schema**: ```bash bash theme={null} TxStreamMessage := { tx_digest: [u8; 32], sender: [u8; 32], // SuiAddress sender_signed_data: SenderSignedData, effects: TransactionEffects, // enum, versioned events: TransactionEvents, timestamp_ms: u64, } ``` `TransactionEffects` is a versioned enum (`V1 / V2`); BCS encodes the variant index as a ULEB128 byte followed by the variant payload. `TransactionEvents` is `Vec`. Both are defined in `sui-types/src/effects.rs`. System transactions are filtered server-side and never appear on this stream. # Optimizing Performance Source: https://docs.p2p.org/docs/syncro-sender-optimizing-performance In Syncro Sender by P2P.ORG, and serve different purposes. For best results, include both a tip and a priority fee in your transaction. | | Tips | Priority Fees | | - | - | - | | **Purpose** | Pay for Syncro Sender access | Pay Solana validators for scheduling priority | | **Recipient** | P2P.org tip accounts | Block-producing validator | | **Instruction** | `SystemProgram.transfer` to tip account | `ComputeBudgetInstruction.SetComputeUnitPrice` | | **Required?** | Yes (both endpoints) | No, but strongly recommended for competitive transactions | ## HTTP keep-alive and connection management Syncro Sender's server keep-alive timeout is **30 seconds**. Reuse connections to avoid TCP/TLS handshake overhead on every request. ## Retry strategy Syncro Sender's multi-channel delivery means a single `sendTransaction` call already routes through multiple channels. This provides built-in redundancy without client-side retries for delivery. ### When to retry | Response | Action | | - | - | | **HTTP 429** (rate limited) | Wait for `Retry-After` seconds, then retry | | **HTTP 400** (bad request) | Fix the request—do not retry | | **HTTP 500** (server error) | Retry with exponential backoff | | **Success** (signature returned) | Transaction was submitted; monitor for confirmation | | **Network error** | Retry with backoff | ### Safe to resubmit Solana is idempotent on transaction signatures — submitting the same signed transaction multiple times is safe. The network will only process it once. ## Best practices checklist * **Use `skipPreflight: true`** — preflight checks add latency; Syncro Sender handles delivery, not simulation * **Use base64 encoding** — this is the default and recommended encoding for transaction data * **Reuse HTTP connections** — enable keep-alive and connection pooling to reduce latency * **Add a priority fee** — set `ComputeUnitPrice` via `ComputeBudgetInstruction` for validator scheduling priority * **Include a sufficient tip** — required for both endpoints; ensure the tip meets the minimum * **Use a separate RPC for reads** — fetch blockhashes, simulate, and confirm transactions on a standard RPC endpoint, if you are using the public endpoint * **Handle rate limits gracefully** — respect `Retry-After` headers on 429 responses # Overview Source: https://docs.p2p.org/docs/syncro-sender-overview Deliver Solana transactions directly to validator leaders with higher priority using Stake-Weighted Quality of Service (SWQoS) Syncro Sender is a high-performance Solana transaction forwarding service by [P2P.ORG](https://p2p.org). It maximizes transaction landing probability through parallel, multi-channel delivery. ## Key benefits * **SWQoS (Stake-Weighted Quality of Service)**. Transactions are sent directly to validator leaders via staked TPU connections. Solana validators prioritize connections backed by stake, giving your transactions higher scheduling priority. * **Multi-channel delivery**. Every `sendTransaction` call is simultaneously routed through multiple channels. If one path fails, others still try to deliver. * **P2P.org validator infrastructure**. Backed by P2P.org's staked validators, providing genuine stake-weighted priority rather than simple RPC forwarding. ## Who is it for? * **HFT traders** — for time-sensitive strategies * **MEV searchers** — direct leader delivery for arbitrage and liquidation opportunities * **Liquidation bots** — reliable, priority transaction submission for DeFi liquidations * **DeFi applications** — higher landing rates for swaps, order placement, and protocol interactions * **Anyone** needing low-latency, high-priority Solana transaction submission ## How it works 1. The client sends a JSON-RPC `sendTransaction` request to the Syncro Sender endpoint. 2. The request is validated via tip verification (both endpoints) or tips + API key authentication (private endpoint). 3. The transaction is forwarded simultaneously through all enabled channels (parallel routing). 4. Staked TPU connections send the transaction directly to the current and upcoming validator leaders. # Pricing, Rate Limits & Support Source: https://docs.p2p.org/docs/syncro-sender-pricing-rate-limits ## Plans | | Public (Tip-Based) | Private (API Key) | | - | - | - | | **Tip requirement** | Required (minimum 200,000 lamports) | Required (minimum 150,000 lamports) | | **Authentication** | Tip required in transaction | API key + tip in transaction | | **Endpoint** | `/public` | `/` or `/rpc` | | **Supported methods** | `sendTransaction` only | All Solana RPC methods | | **Default rate limit** | 1 TPS per IP | 50 TPS per client (custom for dedicated) | **Tip accounts:** ``` BPZrtYhdoAhiHWV5EgGLoV7bZFbMamBZurGDq4DmST8v 7D5pdbkV75Sr73M1YFNZwXMed6DenwkdfbJwVWrX6drQ ELpn2NryEW4B3psG36eSjF45YcGMQpGGuu9J2AgAccbV FnckAPC9PitnRpGZM2M4WLwb3w9odRLJ7EDRZDngjvd6 3ZnDTgvVfwzqwWoqAUmDkgVtXvXqjmeb5t9zxD5pMbmv 3SLDFcdCzMbcFNguZhzmV4zqEAUvcPoKY13akpE4Tq1p 48tT6LJqrsoFrLpzZSHkjGdGTWtsJ1PvjgWZjh8qF1RK 7GM9fpVMHHcrK4cgzfVdzJvjiy1bSyfwSYzhxvgbfVLg CBd8GE3ffMJKf3iCCcNNBEifMxH1WpgtTzRnXPxxbjGE ``` ## Rate limits ### How it works * **Algorithm:** Fixed 1-second window counter * **Private endpoint:** Rate limited per client * **Public endpoint:** Rate limited per source IP address ### Default limits | Endpoint | Default TPS | Customizable? | | - | - | - | | Public | 1 per IP | No | | Private | 50 per client | Yes (per client) | ### Rate limit response When the limit is exceeded, you receive an HTTP **429** response with rate limit headers: ```bash bash theme={null} HTTP/1.1 429 Too Many Requests X-RateLimit-Limit: 10 X-RateLimit-Remaining: 0 Retry-After: 1 Content-Type: application/json ``` ```json JSON theme={null} { "jsonrpc": "2.0", "error": { "code": -32005, "message": "Rate limit exceeded" }, "id": 1 } ``` Wait for the number of seconds indicated by `Retry-After` before sending the next request. ## FAQ ### What encoding should I use for transactions? **Base64** (recommended). Always pass `{"encoding": "base64"}` in the params. The transaction bytes should be the serialized, signed transaction encoded as a base64 string. ### Can I use Syncro Sender for read-only RPC calls? Yes, on **private endpoints** when this capability is enabled on your client profile. This proxies standard Solana RPC methods (e.g., `getBalance`, `getTransaction`, `getSlot`) through Syncro Sender's RPC backend. ### What happens if my tip is too low? You'll receive an error response with code `-32602`: ```json JSON theme={null} { "jsonrpc": "2.0", "error": { "code": -32602, "message": "Insufficient tip: provided 50000 lamports, required 200000 lamports" }, "id": 1 } ``` The error message includes both the amount you provided and the required minimum, so you can adjust accordingly. ### How do I check if my transaction landed? Use any standard Solana RPC's `getSignatureStatuses` method: Syncro Sender handles **delivery** — it sends your transaction to validator leaders through multiple channels. Confirmation tracking should be done separately. ## Contact & support * Telegram: [support.p2p.org](http://support.p2p.org/) * Email [support@p2p.org](mailto:support@p2p.org) # Getting Started Source: https://docs.p2p.org/docs/syncro-sender-quick-start ## Syncro — Endpoint Configuration **An API key is required to unlock the full rate**. Without an API key, these endpoints serve public traffic at **1 RPS**. With an API key, you get the dedicated rate of **50 RPS**. To get an API key, request access through the [Syncro Sender page](https://www.p2p.org/products/syncro-solana-transaction-sender) on [P2P.ORG](https://www.p2p.org/), and our team will contact you to arrange setup. ### HTTP Endpoints * Amsterdam — [http://ams3.sender.syncro.p2p.org:8080](http://ams3.sender.syncro.p2p.org:8080) * Frankfurt — [http://fra.sender.syncro.p2p.org:8080](http://fra.sender.syncro.p2p.org:8080) * Washington, DC — [http://us.sender.syncro.p2p.org:8080](http://us.sender.syncro.p2p.org:8080)​ ### QUIK Endpoints * Amsterdam — [http://ams3.sender.syncro.p2p.org:8090](http://ams3.sender.syncro.p2p.org:8090) * Frankfurt — [http://fra.sender.syncro.p2p.org:8090](http://fra.sender.syncro.p2p.org:8090) * Washington, DC — [http://us.sender.syncro.p2p.org:8090](http://us.sender.syncro.p2p.org:8090) Available to authorized clients only. To get access, create a key pair and send your public key to the P2P team. ## Sending a transaction via public endpoint The public endpoint requires no API key. Instead, include a **System Program transfer** to one of the tip accounts in your transaction. **Tip accounts:** ``` BPZrtYhdoAhiHWV5EgGLoV7bZFbMamBZurGDq4DmST8v 7D5pdbkV75Sr73M1YFNZwXMed6DenwkdfbJwVWrX6drQ ELpn2NryEW4B3psG36eSjF45YcGMQpGGuu9J2AgAccbV FnckAPC9PitnRpGZM2M4WLwb3w9odRLJ7EDRZDngjvd6 3ZnDTgvVfwzqwWoqAUmDkgVtXvXqjmeb5t9zxD5pMbmv 3SLDFcdCzMbcFNguZhzmV4zqEAUvcPoKY13akpE4Tq1p 48tT6LJqrsoFrLpzZSHkjGdGTWtsJ1PvjgWZjh8qF1RK 7GM9fpVMHHcrK4cgzfVdzJvjiy1bSyfwSYzhxvgbfVLg CBd8GE3ffMJKf3iCCcNNBEifMxH1WpgtTzRnXPxxbjGE ``` The minimum tip is 200,000 lamports on public endpoints and 150,000 lamports on private endpoints. If the tip is missing or insufficient, an error is returned: * **Missing tip:** `"Missing tip: no transfer to tip accounts found"` (code `-32602`) * **Insufficient tip:** `"Insufficient tip: provided X lamports, required Y lamports"` (code `-32602`) How to add a tip to your transaction: ```javascript JavaScript theme={null} transaction.addInstruction(SystemProgram.transfer(yourPublicKey, 'BPZrtYhdoAhiHWV5EgGLoV7bZFbMamBZurGDq4DmST8v', 100000)); ``` Example request ([cURL](https://curl.se/)): ```bash bash theme={null} curl -X POST https://sfls.l2.p2p.org/public \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "sendTransaction", "params": ["", {"encoding": "base64"}] }' ``` > **Note:** The transaction itself must contain a tip instruction to a tip account. No `Authorization` header is needed. Example response: ```json JSON theme={null} { "jsonrpc": "2.0", "result": "", "id": 1 } ``` ## Sending a transaction via private endpoint Contact the P2P.org team to get your API key and client profile: [t.me/P2Pstaking](http://t.me/P2Pstaking). Syncro Sender supports two authentication headers via private endpoint. If both are present, `Authorization: Bearer` takes priority. | Header | Format | Priority | | - | - | - | | `Authorization` | `Bearer ` | 1 (preferred) | | `X-Api-Key` | `` | 2 (fallback) | Example request: ```bash bash theme={null} curl -X POST https://sfls.l2.p2p.org \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "sendTransaction", "params": ["", {"encoding": "base64"}] }' ``` Example response: ```json JSON theme={null} { "jsonrpc": "2.0", "result": "", "id": 1 } ``` ## Error codes | Code | Name | HTTP Status | Description | | - | - | - | - | | `-32700` | PARSE\_ERROR | 400 | Malformed JSON-RPC request body | | `-32600` | INVALID\_REQUEST | 400 / 403 | Invalid request structure or authentication failure | | `-32601` | METHOD\_NOT\_FOUND | 200 | Unsupported method (e.g., non-`sendTransaction` on public endpoint) | | `-32602` | INVALID\_PARAMS | 200 / 400 | Invalid parameters, missing tip, or insufficient tip amount | | `-32603` | INTERNAL\_ERROR | 500 | Server-side processing error | | `-32000` | SERVER\_ERROR | 500 | General server error | | `-32005` | RATE\_LIMIT | 429 | Rate limit exceeded | Error response format: ```json JSON theme={null} { "jsonrpc": "2.0", "result": null, "error": { "code": -32005, "message": "Rate limit exceeded" }, "id": 1 } ``` ## Rate limit headers If the rate limit is hit (HTTP 429), the response includes these headers: | Header | Description | | - | - | | `X-RateLimit-Limit` | Maximum requests per second for your client | | `X-RateLimit-Remaining` | Remaining requests in the current 1-second window | | `Retry-After` | Seconds until the rate limit window resets (minimum 1) | # Tezos Transaction Signing Source: https://docs.p2p.org/docs/tezos-transaction-signing Sign and broadcast Tezos transactions built with the P2P.org Unified API. To sign and broadcast the transaction to the Tezos network, follow these steps: 1. Prepare unsigned transaction (A transaction that must be signed and broadcasted to the blockchain network.) as a hex-encoded string. You obtain this from the `unsignedTransactionData` field in the Unified API staking/unstaking response. 2. Sign the transaction using the following code: ```javascript theme={null} import { InMemorySigner } from '@taquito/signer'; const MNEMONIC = ""; const UNSIGNED_TX = ""; async function main() { // Create a signer instance from mnemonic const signer = await InMemorySigner.fromMnemonic({ mnemonic: MNEMONIC }); // Sign the unsigned transaction (hex string) const signed = await signer.sign(UNSIGNED_TX, new Uint8Array([3])); // The result contains: bytes, sig, prefixSig, sbytes console.log("✅ Signed Tezos Tx (JSON):"); console.log(JSON.stringify(signed, null, 2)); } main().catch(console.error); ``` Upon successful execution, the script prints the signed transaction as a JSON object, ready to be broadcasted: ```bash theme={null} ✅ Signed Tezos Tx (JSON): { "bytes": "...", "sig": "...", "prefixSig": "...", "sbytes": "..." } ``` 3. Broadcast the transaction to the Tezos network by sending a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). # Aptos Source: https://docs.p2p.org/docs/unified-api-aptos Unified API + Aptos Integration Workflow In the following guide, the integration process for the `aptos` chain is covered. The Aptos integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Aptos-specific details** > > * `chain` — always set to `aptos` for Aptos-related requests. > * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal operations. > * `amount`— amount of tokens in Octas (1 APT = 10⁸ Octas). > * `extra.gas` — optional settings for gas management. > * `signature` — delegator account signature, required for broadcasting transactions. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "aptos", "network": "testnet", "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "amount": 11, "extra":{ "gas": { "unitPrice": 102, "maxGasLimit": 1234 } } }' ``` * `chain` — blockchain network, always set to `aptos` for Aptos-related requests. * `network` — environment in which the transaction is processed: `mainnet` or `testnet`. * `stakerAddress` — 0x-prefixed Aptos account address, initiating the staking transaction. * `amount` — amount of tokens to stake in Octas (1 APT = 10⁸ Octas). Note that minimum staking amount for testing is 11 APT, and on `mainnet`, no less than 1 000 000 APT delegation to the validator is required. * `extra` — additional parameters: * `gas`— additional parameters for gas management: * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction. * `maxGasLimit` — maximum gas limit for the transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 1100000000, "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "unsignedTransactionData": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad8800000000000000000200000000000000000000000000000000000000000000000000000000000000010f64656c65676174696f6e5f706f6f6c096164645f7374616b650002207a2ddb6af66beb0d9987c6c9010cb9053454f067e16775a8ecf19961195c3d280800ab904100000000400d0300000000006400000000000000bd192087970100000200", "createdAt": "2025-06-19T06:38:37.373Z" } } ``` * `amount` — amount of tokens to stake in Octas (1 APT = 10⁸ Octas). * `stakerAddress` — staking account address receiving the staked tokens. * `unsignedTransactionData` — unsigned transaction in Base64 or hex-encoded format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in ISO 8601 format. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Aptos-specific signing logic. To broadcast the signed transaction to the Aptos network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "aptos", "network": "testnet", "signedTransaction": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad8800000000000000000200000000000000000000000000000000000000000000000000000000000000010f64656c65676174696f6e5f706f6f6c096164645f7374616b650002207a2ddb6af66beb0d9987c6c9010cb9053454f067e16775a8ecf19961195c3d280800ab904100000000400d0300000000006400000000000000bd192087970100000200", "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "extra": { "signature": "0x00204a7d68bc540b902995941b77373cd378f39b0e0ebff42566e03774b0ad2285e940cb030ea54fa24986712ffb5c941f3950a2bf1087b2e588c6c3daa08689b5668fbe469a76351101275f694f1ec45cc7d433e103825e55d20ded63cbbcbe344d01" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the staking transaction. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `extra`— additional parameters * `signature` — delegator signature of the transaction externally produced via the signing code. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "pending", "extraData": { "gas": { "maxGasLimit": 200000, "unitPrice": 100, "used": null }, "createdAt": "2025-06-19T06:56:50.979Z", "transactionHash": "0x3051a37fdb7a3e6aa8fc0429d2896dff53c36d6da8144e438aa3ba9d9cb60810", "senderAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88" } } } ``` * `status` — transaction status: `pending`, `success`, or `failed`. * `extraData` — additional transaction details: * `gas` — computational effort required to execute the transaction, measured in gas units. * `maxGasLimit` — maximum gas limit for the transaction. * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction. * `used` — amount of gas spent for the transaction. * `createdAt` — timestamp of the transaction in ISO 8601 format. * `transactionHash` — hash of the transaction. * `senderAddress` — transaction sender address. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction) Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "aptos", "network": "testnet", "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "extra":{ "amount": 1000000000, "gas": { "unitPrice": 100, "maxGasLimit": 1000 } } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the unstaking transaction. * `extra` — additional parameters: * `amount` — amount of tokens to unlock in Octas (1 APT = 10⁸ Octas). * `gas` — additional parameters for gas management: * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction. * `maxGasLimit` — maximum gas limit for the transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "unsignedTransactionData": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad8801000000000000000200000000000000000000000000000000000000000000000000000000000000010f64656c65676174696f6e5f706f6f6c06756e6c6f636b0002207a2ddb6af66beb0d9987c6c9010cb9053454f067e16775a8ecf19961195c3d280800ca9a3b00000000e803000000000000640000000000000018e5bf87970100000200", "createdAt": "2025-06-19T09:33:09.655Z", "extraData": { "amount": 1000000000 } } } ``` * `stakerAddress` — account address initiating the unstaking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 or hex-encoded format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in ISO 8601 format. * `extraData` — additional transaction details: * `amount` — amount of tokens to unlock in Octas. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Aptos-specific signing logic. ### 3. Create withdrawal request > [!NOTE] > > Note that it takes up to 30 days to unlock tokens on Aptos network. During this waiting period, unlocked tokens continue earning rewards. Withdrawal is only available after the unlocking period ends. Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "aptos", "network": "testnet", "stakerAddress": "0x2588942932015ae61b7e9b77d41f8ed053dde2b341ccaca57bf6a6ecb4fa511a", "extra":{ "amount": 99, "gas": { "unitPrice": 100, "maxGasLimit": 1000 } } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the withdrawal transaction. * `extra` — additional parameters: * `amount` — amount of tokens to withdraw in Octas. * `gas` — additional parameters for gas management: * `unitPrice` — price per unit of gas in Octas for processing the Aptos transaction. * `maxGasLimit` — maximum gas limit for the transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "unsignedTransactionData": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad8802000000000000000200000000000000000000000000000000000000000000000000000000000000010f64656c65676174696f6e5f706f6f6c0877697468647261770002207a2ddb6af66beb0d9987c6c9010cb9053454f067e16775a8ecf19961195c3d28086300000000000000e80300000000000064000000000000007f06f587970100000200", "createdAt": "2025-06-19T10:31:11.615Z", "extraData": { "amount": 99 } } } ``` * `stakerAddress` — account address initiating the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in Base64 or hex-encoded format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in ISO 8601 format. * `extraData` — additional transaction details: * `amount` — amount of tokens to withdraw in Octas. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Aptos-specific signing logic. # Cardano Source: https://docs.p2p.org/docs/unified-api-cardano Unified API + Cardano Integration Workflow This guide explains how to integrate the `cardano` chain using the Unified API. The Cardano integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Cardano-specific details** > > * `chain` — always set to `cardano` for Cardano-related requests. > * `network` — environment in which the transaction is processed: `mainnet` only. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in ADA. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "cardano", "network": "mainnet", "stakerAddress": "addr1q847hfazcye3f4g4f4fwf6l386tud6lp6lqvfawzvcartzvg73xawnxm8wvflhpt8kkm5kg4nlv8a0fx6ezxgv6r2nrqcl6wxm", "amount": 5 }' ``` * `chain` — blockchain network, always set to `cardano` for Cardano-related requests. * `network` — environment in which the transaction is processed: `mainnet` only. * `stakerAddress` — Cardano account address initiating the staking transaction. * `amount` — amount of tokens to stake in ADA, minimum amount is 5 ADA. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 5, "stakerAddress": "addr1q847hfazcye3f4g4f4fwf6l386tud6lp6lqvfawzvcartzvg73xawnxm8wvflhpt8kkm5kg4nlv8a0fx6ezxgv6r2nrqcl6wxm", "unsignedTransactionData": "84a400d9010281825820a7aec4e68399fd4668ac034cccc3fbb726a40fac88f0e5fd74be702ce2f2d93a00018182583901ebeba7a2c13314d5154d52e4ebf13e97c6ebe1d7c0c4f5c2663a358988f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c61a003517dd021a0002a96104d901028282008200581c88f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c683028200581c88f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c6581cc29c92f8319150962650bc8a5e24d918491e8a7b3ac43525afe76baaa0f5f6", "createdAt": "2025-05-15T20:23:20.088Z", "extraData": { "transactionId": "2de012ab-72d8-4971-a570-9771f3530fca", "stakeId": "b3d6c077-a59b-4585-a0df-85ae16c0d3af", "gasEstimate": { "amount": "0.165149000000000000", "gasLimit": "" } } } } ``` * `amount` — amount of tokens to stake in ADA. * `stakerAddress` — account address initiating the staking transaction. * `unsignedTransactionData` — unsigned transaction in CBOR, Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the transaction within this staking session. * `stakeId` — unique identifier of the staking request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated fee in ADA for processing the transaction. * `gasLimit` — maximum gas limit for the transaction; can be left empty or ignored, since it is not used in Cardano and reserved for compatibility only. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction. To broadcast the signed transaction to the Cardano network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "cardano", "network": "mainnet", "signedTransaction": "84a400d9010281825820a7aec4e68399fd4668ac034cccc3fbb726a40fac88f0e5fd74be702ce2f2d93a00018182583901ebeba7a2c13314d5154d52e4ebf13e97c6ebe1d7c0c4f5c2663a358988f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c61a003517dd021a0002a96104d901028282008200581c88f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c683028200581c88f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c6581cc29c92f8319150962650bc8a5e24d918491e8a7b3ac43525afe76baaa1008282582020c22b2dbf4eacea4eb791bd9606806bd3428fc336ddcc42f316a55dbfc1aa2f584094b1c1a9c804b8355abd57e8a496bfef1bf42a5d6b3f1377b6d5d9c3cc443e790f0cbcd34ea347801a51a79ca79a4e0cf2d6925383e707c0a7c4246614101f09825820197e920a7fe4ab16264c847f748d15ec82b0cdc126a12373aa20f0bf154aa23458408603bd62494828461177ba2c0ad96ec6b071b7f4c89e3b9c013c50e1027d7b04d49e91168f31d7a9f12f333c566a27f1bc6ed53a4ab5be2aef523751e2fa5507f5f6", "stakerAddress": "addr1q847hfazcye3f4g4f4fwf6l386tud6lp6lqvfawzvcartzvg73xawnxm8wvflhpt8kkm5kg4nlv8a0fx6ezxgv6r2nrqcl6wxm", "extra": { "transactionId": "2de012ab-72d8-4971-a570-9771f3530fca" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — staking account address receiving the staked tokens. * `extra` — additional request parameters: * `transactionId` — unique identifier of the transaction within this staking session. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "transactionHash": "0a98464fa4eb52c666a03f8f9f1673db7a905c32e475e1e76f33ad0af506b6f9" } } } ``` * `extraData` — additional transaction details: * `transactionHash` — hash of the block in which the transaction has been included. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "cardano", "network": "mainnet", "stakerAddress": "addr1q847hfazcye3f4g4f4fwf6l386tud6lp6lqvfawzvcartzvg73xawnxm8wvflhpt8kkm5kg4nlv8a0fx6ezxgv6r2nrqcl6wxm", "extra": { "amount": 5 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional parameters: * `amount` — amount of tokens to withdraw in ADA. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 5, "stakerAddress": "addr1q847hfazcye3f4g4f4fwf6l386tud6lp6lqvfawzvcartzvg73xawnxm8wvflhpt8kkm5kg4nlv8a0fx6ezxgv6r2nrqcl6wxm", "unsignedTransactionData": "84a400d90102818258200a98464fa4eb52c666a03f8f9f1673db7a905c32e475e1e76f33ad0af506b6f900018182583901ebeba7a2c13314d5154d52e4ebf13e97c6ebe1d7c0c4f5c2663a358988f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c61a0050fdfc021a00029e6104d901028182018200581c88f44dd74cdb3b989fdc2b3dadba59159fd87ebd26d64464334354c6a0f5f6", "createdAt": "2025-05-15T20:24:32.851Z", "extraData": { "transactionId": "ce8f7141-114a-4f72-b2ae-155edbf8da43", "stakeId": "23b263c3-3994-442b-8f18-d73b568ecf12", "gasEstimate": { "amount": "0.171617000000000000", "gasLimit": "" } } } } ``` * `amount` — amount of tokens to withdraw in ADA. * `stakerAddress` — account address initiated the staking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the transaction within this withdrawal session. * `stakeId` — unique identifier of the withdrawal request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated fee for processing the transaction in ADA. * `gasLimit` — maximum gas limit for the transaction; can be left empty or ignored, since it is not used in Cardano and reserved for compatibility only. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Cardano-specific signing logic. # Celestia Source: https://docs.p2p.org/docs/unified-api-celestia Unified API + Celestia Integration Workflow In the following guide, the integration process for the `celestia` chain is covered. The Celestia integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Celestia-specific details** > > * `chain` — always set to `celestia` for Celestia-related requests. > * `network` — environment in which the transaction is processed: `celestia-mainnet-beta` or `celestia-mocha-testnet`. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in TIA (in uTIA internally). ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `celestia-mocha-testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "celestia", "network": "celestia-mocha-testnet", "stakerAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d", "amount": 1 }' ``` * `chain` — blockchain network, always set to `celestia` for Celestia-related requests. * `network` — environment in which the transaction is processed: `celestia-mainnet-beta` or `celestia-mocha-testnet`. * `stakerAddress` — account address initiating the staking transaction. * `amount` — amount of tokens to stake in TIA. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 1, "unsignedTransactionData": { "messages": [ { "typeUrl": "/cosmos.staking.v1beta1.MsgDelegate", "value": { "delegatorAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d", "validatorAddress": "celestiavaloper1amm0umxqxxw8j2q60x78xs32s089606sdmvx92", "amount": { "denom": "utia", "amount": "1000000" } } } ], "fee": { "amount": [ { "amount": "6500", "denom": "utia" } ], "gas": "260000" }, "memo": "", "encodedBody": "0aa1010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465127a0a2f63656c657374696131746d7070363333766633376436376c716e797578773561386c76766461716b737639686c3864123663656c657374696176616c6f70657231616d6d30756d7871787877386a32713630783738787333327330383936303673646d767839321a0f0a0475746961120731303030303030", "encodedAuthInfo": "12120a0c0a047574696112043635303010a0ef0f", "messageHash": "a6997d57f6e1b7dc63d6b0ff619195960fc0e9d44518932b5d5505a75715a3e5" }, "createdAt": "2025-03-26T12:06:09.392Z", "extraData": { "currency": "tia", "validatorAddress": "celestiavaloper1amm0umxqxxw8j2q60x78xs32s089606sdmvx92", "stashAccountAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d", "rewardDestinationAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d" } } } ``` * `amount` — amount of tokens to stake in TIA. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `messages` — transaction messages for each staking operation. * `typeUrl` — Celestia network operation type. * `value` — message payload, encoded in the hexadecimal format.- `delegatorAddress` — account address initiating the delegation. * `validatorAddress` — validator address receiving the delegation. * `amount.amount` — amount of tokens to stake. * `amount.denom` — currency of tokens, always set to `utia` (1 TIA = 10⁶ uTIA). * `fee` — fee charged for processing the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `tia`, `utia`, or `mtia`. * `gas` — amount of gas spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. * `messageHash` — hash of the transaction message. * `createdAt` — timestamp of the transaction in ISO 8601 format. * `extraData` — additional transaction details: * `currency` — TIA, Celestia native staking token. * `validatorAddress` — validator address to which tokens are delegated. * `stashAccountAddress` — account address initiating the staking transaction. * `rewardDestinationAddress` — account address receiving the staking rewards; `stashAccountAddress` by default. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Celestia-specific signing logic. To broadcast the signed transaction to the Celestia network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request (for `celestia-mocha-testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "celestia", "network": "celestia-mocha-testnet", "stakerAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d", "signedTransaction": "0aa4010aa1010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465127a0a2f63656c657374696131746d7070363333766633376436376c716e797578773561386c76766461716b737639686c3864123663656c657374696176616c6f70657231616d6d30756d7871787877386a32713630783738787333327330383936303673646d767839321a0f0a047574696112073130303030303012640a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030b155e1a5773bfae8759223f986febc4094328de05f79924363cc6887ffd9aed12040a02080112120a0c0a047574696112043635303010a0ef0f1a40ac6ddd90b1ceffcd099cd0dea54db06506b6c346b4e175ec68ae7d694fadd38123dce739dd047ca2dcac656534e2cde42a183412cb3431e89abf6be69de00d58" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — Celestia account address initiating the staking transaction. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "success", "extraData": { "blockId": 5360497, "fee": 0.0065, "gas": { "used": 151375, "wanted": 260000 }, "transactionHash": "B5752ED7CA92428E85FAA496E024966F03CD6CEB6E32513BF7550F5C772A3A38" } } } ``` * `status` — transaction status: `pending`, `success`, or `failed`. * `extraData` — additional transaction details: * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in TIA charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit available to consume for the transaction. * `transactionHash` — hash of the transaction. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request (for `celestia-mocha-testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "celestia", "network": "celestia-mocha-testnet", "stakerAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d", "extra": { "amount": 1 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional parameters: * `amount` — amount of tokens to unstake in TIA. Example response: ```json JSON theme={null} { "error": null, "result": { "unsignedTransactionData": { "messages": [ { "typeUrl": "/cosmos.staking.v1beta1.MsgUndelegate", "value": { "delegatorAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d", "validatorAddress": "celestiavaloper1amm0umxqxxw8j2q60x78xs32s089606sdmvx92", "amount": { "denom": "utia", "amount": "1000000" } } } ], "fee": { "amount": [ { "amount": "4960", "denom": "utia" } ], "gas": "198384" }, "memo": "", "encodedBody": "0aa3010a252f636f736d6f732e7374616b696e672e763162657461312e4d7367556e64656c6567617465127a0a2f63656c657374696131746d7070363333766633376436376c716e797578773561386c76766461716b737639686c3864123663656c657374696176616c6f70657231616d6d30756d7871787877386a32713630783738787333327330383936303673646d767839321a0f0a0475746961120731303030303030", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030b155e1a5773bfae8759223f986febc4094328de05f79924363cc6887ffd9aed12040a020801180112120a0c0a047574696112043439363010f08d0c", "messageHash": "3605ad63721f3759336806506ffb2e36c662dd63b699ad6c746d39e8dbeb98b6" }, "createdAt": "2025-03-26T12:08:27.392Z", "extraData": { "amount": 1, "currency": "tia", "validatorAddress": "celestiavaloper1amm0umxqxxw8j2q60x78xs32s089606sdmvx92", "stashAccountAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d", "rewardDestinationAddress": "celestia1tmpp633vf37d67lqnyuxw5a8lvvdaqksv9hl8d" } } } ``` * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the unstaking transaction. * `messages` — transaction messages for each staking operation. * `typeUrl` — network operation type. * `delegatorAddress` — delegator address. * `validatorAddress` — validator address. * `amount` — amount of tokens to unstake. * `denom` — currency of tokens, always set to `utia` (1 TIA = 10⁶ uTIA). * `fee` — fee charged for processing the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `tia`, `utia`, or `mtia`. * `gas` — amount of gas spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. * `messageHash` — hash of the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `amount` — amount of tokens to unstake in TIA. * `currency` — currency of tokens: `tia`, `utia`, or `mtia`. * `validatorAddress` — validator address from which tokens are delegated. * `stashAccountAddress` — staking account address keeping the staked tokens. * `rewardDestinationAddress` — rewards destination account address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Celestia-specific signing logic. # Cosmos Source: https://docs.p2p.org/docs/unified-api-cosmos Unified API + Cosmos Integration Workflow In the following guide, the integration process for the `cosmos` chain is covered. The Cosmos integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Cosmos-specific details** > > * `chain` — always set to `cosmos` for Cosmos-related requests. > * `network` — environment in which the transaction is processed: `cosmoshub-4` only. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in ATOM (in uATOM internally). ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "cosmos", "network": "cosmoshub-4", "stakerAddress": "cosmos1tmpp633vf37d67lqnyuxw5a8lvvdaqksa0x0aq", "amount": "0.0042" }' ``` * `chain` — blockchain network, always set to `cosmos` for Cosmos-related requests. * `network` — environment in which the transaction is processed: `cosmoshub-4` only. * `stakerAddress` — account address initiating the staking transaction. * `amount` — amount of tokens to stake in ATOM. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 0.0042, "stakerAddress": "cosmos1tmpp633vf37d67lqnyuxw5a8lvvdaqksa0x0aq", "unsignedTransactionData": { "messages": [ { "typeUrl": "/cosmos.staking.v1beta1.MsgUndelegate", "value": { "delegatorAddress": "cosmos1tmpp633vf37d67lqnyuxw5a8lvvdaqksa0x0aq", "validatorAddress": "cosmosvaloper132juzk0gdmwuxvx4phug7m3ymyatxlh9734g4w", "amount": { "denom": "uatom", "amount": "4000" } } } ], "fee": { "amount": [ { "amount": "14672", "denom": "uatom" } ], "gas": "586847" }, "memo": "", "encodedBody": "0a9d010a252f636f736d6f732e7374616b696e672e763162657461312e4d7367556e64656c656761746512740a2d636f736d6f7331746d7070363333766633376436376c716e797578773561386c76766461716b736130783061711234636f736d6f7376616c6f7065723133326a757a6b3067646d77757876783470687567376d33796d796174786c68393733346734771a0d0a057561746f6d120434303030", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030b155e1a5773bfae8759223f986febc4094328de05f79924363cc6887ffd9aed12040a020801180212140a0e0a057561746f6d1205313436373210dfe823", "messageHash": "cd63647dbc65aaae6a6fd925df121ffde799eadb665784a3a465993207024ec5" }, "createdAt": "2025-03-31T08:02:36.633Z", "extraData": { "currency": "atom", "validatorAddress": "cosmosvaloper132juzk0gdmwuxvx4phug7m3ymyatxlh9734g4w", "rewardDestinationAddress": "cosmos1k664uhuyzpwss3y45fc0zzamcr3ujpeww33ruu" } } } ``` * `amount` — amount of tokens to stake in ATOM. * `stakerAddress` — account address initiating the staking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `messages` — transaction messages for each staking operation. * `typeUrl` — Cosmos network operation type. * `value` — message payload, encoded in the hexadecimal format. * `delegatorAddress` — account address initiating the delegation. * `validatorAddress` — validator address receiving the delegation. * `amount.amount` — amount of tokens to stake. * `amount.denom` — currency of tokens, always set to `uatom` (1 ATOM = 10⁶ uATOM). * `fee` — fee charged for processing the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `atom`, `uatom`, or `matom`. * `gas` — amount of gas spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. * `messageHash` — hash of the transaction message. * `createdAt` — timestamp of the transaction in ISO 8601 format. * `extraData` — additional transaction details: * `currency` — ATOM, Cosmos native staking token. * `validatorAddress` — validator address to which tokens are delegated. * `rewardDestinationAddress` — account address receiving the staking rewards. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Cosmos-specific signing logic. To broadcast the signed transaction to the Cosmos network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "cosmos", "network": "cosmoshub-4", "stakerAddress": "cosmos1tmpp633vf37d67lqnyuxw5a8lvvdaqksa0x0aq", "signedTransaction": "0aa6010aa3010a252f636f736d6f732e7374616b696e672e763162657461312e4d7367556e64656c6567617465127a0a2f63656c657374696131746d7070363333766633376436376c716e797578773561386c76766461716b737639686c3864123663656c657374696176616c6f70657231616d6d30756d7871787877386a32713630783738787333327330383936303673646d767839321a0f0a047574696112073130303030303012660a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030b155e1a5773bfae8759223f986febc4094328de05f79924363cc6887ffd9aed12040a020801180112120a0c0a047574696112043439363010f08d0c1a40b704538dadc6a1de4d7c881a1454ca75245f2651b35347062b9246543d2f7eb016bc897eeeeac37702ddaf6697d92b75cd659b4be46103a6da0cf3407dc0d73b" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — Cosmos account address initiating the staking transaction. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } } ``` * `status` — transaction status: `pending`, `success`, or `failed`. * `extraData` — additional transaction details: * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in ATOM charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit available to consume for the transaction. * `transactionHash` — hash of the transaction. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "cosmos", "network": "cosmoshub-4", "stakerAddress": "cosmos1tmpp633vf37d67lqnyuxw5a8lvvdaqksa0x0aq", "extra": { "amount": 0.0042 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional request parameters: * `amount` — amount of tokens to unstake in ATOM. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 0.0042, "stakerAddress": "cosmos1tmpp633vf37d67lqnyuxw5a8lvvdaqksa0x0aq", "unsignedTransactionData": { "messages": [ { "typeUrl": "/cosmos.staking.v1beta1.MsgUndelegate", "value": { "delegatorAddress": "cosmos1tmpp633vf37d67lqnyuxw5a8lvvdaqksa0x0aq", "validatorAddress": "cosmosvaloper132juzk0gdmwuxvx4phug7m3ymyatxlh9734g4w", "amount": { "denom": "uatom", "amount": "4000" } } } ], "fee": { "amount": [ { "amount": "14672", "denom": "uatom" } ], "gas": "586847" }, "memo": "", "encodedBody": "0a9d010a252f636f736d6f732e7374616b696e672e763162657461312e4d7367556e64656c656761746512740a2d636f736d6f7331746d7070363333766633376436376c716e797578773561386c76766461716b736130783061711234636f736d6f7376616c6f7065723133326a757a6b3067646d77757876783470687567376d33796d796174786c68393733346734771a0d0a057561746f6d120434303030", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030b155e1a5773bfae8759223f986febc4094328de05f79924363cc6887ffd9aed12040a020801180212140a0e0a057561746f6d1205313436373210dfe823", "messageHash": "cd63647dbc65aaae6a6fd925df121ffde799eadb665784a3a465993207024ec5" }, "createdAt": "2025-03-27T07:16:58.337Z", "extraData": { "currency": "atom", "validatorAddress": "cosmosvaloper132juzk0gdmwuxvx4phug7m3ymyatxlh9734g4w", "rewardDestinationAddress": "cosmos1y9wefmlpm0djkt8sseeveke0httfukg2a60g0r" } } } ``` * `amount` — amount of tokens to unstake in ATOM. * `stakerAddress` — staking account address keeping the staked tokens. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the unstaking transaction. * `messages` — transaction messages for each staking operation. * `typeUrl` — Cosmos network operation type. * `delegatorAddress` — delegator address. * `validatorAddress` — validator address. * `amount` — amount of tokens to unstake. * `denom` — currency of tokens, always set to `uatom` (1 ATOM = 10⁶ uATOM). * `fee` — fee charged for processing the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `atom`, `uatom`, or `matom`. * `gas` — amount of gas spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. * `messageHash` — hash of the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `amount` — amount of tokens to unstake in ATOM. * `currency` — currency of tokens: `atom`, `uatom`, or `matom`. * `validatorAddress` — validator address from which tokens are delegated. * `rewardDestinationAddress` — rewards destination account address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Cosmos-specific signing logic. # Ethereum Source: https://docs.p2p.org/docs/unified-api-ethereum Unified API + Ethereum Integration Workflow In the following guide, the integration process for the `eth-ssv` chain is covered. The Ethereum SSV On-Chain integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Ethereum-specific details** > > * `chain`— always set to `eth_ssv` for Ethereum-related requests. > * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "eth_ssv", "network": "testnet", "stakerAddress": "0x136c861fC99d1624155F5FC8A06BAC79eD8547b1", "amount": 32, "extra": { "withdrawalAddress": "0x136c861fC99d1624155F5FC8A06BAC79eD8547b1", "amountPerValidator": "32000000000", "withdrawalCredentialsType": "0x02" } }' ``` * `chain`— blockchain network, always set to `eth_ssv` for Ethereum-related requests. * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. * `stakerAddress` — account address initiating the staking transaction. * `amount` — amount of tokens to stake in ETH. * `extra`— additional parameters: * `withdrawalAddress`— withdrawal address for the validators. * `amountPerValidator`— amount of tokens to stake in Gwei per validator. * `withdrawalCredentialsType`— withdrawal credentials preferred format: `0x01` or `0x02`. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": "32000000000000000000", "stakerAddress": "0x136c861fC99d1624155F5FC8A06BAC79eD8547b1", "unsignedTransactionData": "0x02f9023882426880830f42408463aeabb88398968094e9dfc1850110dadf68402ec6ad2b9bdfb79807338901bc16d674ec800000b90204746bd1000100000000000000000000003202b5b0602274197ccb22b8c02cec9539990c7c000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000251c0000000000000000000000003202b5b0602274197ccb22b8c02cec9539990c7c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e8ffb2afa84510d1814e8d74478b71041c42db7fe128144fdd7a268bf448ba856345ad5b70b23bae824295c393fa1df1d3dcc203112022ca0cfe23b069877d20ea1e5dd64fffec475f7b0d0200182525b28bf76e1e6110ba0db5edd87b39799b7d01bceefe4af93f0a94fac12291a9f0b5b093fb11c220581de0ff2e20f126105918e2b27ed42c9bccda8e949d0bc0ff8be8c4a57741db21c30ff2fefdce7ecf8722ea53db9800d6612c4f0a81a54334b6ab08f52dd6c28f5f363dd5a59a1bab46e2a2fc30bf2c83ae388fa15e0faf4a3d2da85b1b8a180b77906286eaf4443d9e4825a7df8a7cf940000000000000000000000000000000000000000000000000c0", "extraData": { "to": "0xE9DfC1850110DadF68402Ec6AD2B9bDfB7980733", "gasLimit": "10000000", "data": "0x746bd1000100000000000000000000003202b5b0602274197ccb22b8c02cec9539990c7c000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000251c0000000000000000000000003202b5b0602274197ccb22b8c02cec9539990c7c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e8ffb2afa84510d1814e8d74478b71041c42db7fe128144fdd7a268bf448ba856345ad5b70b23bae824295c393fa1df1d3dcc203112022ca0cfe23b069877d20ea1e5dd64fffec475f7b0d0200182525b28bf76e1e6110ba0db5edd87b39799b7d01bceefe4af93f0a94fac12291a9f0b5b093fb11c220581de0ff2e20f126105918e2b27ed42c9bccda8e949d0bc0ff8be8c4a57741db21c30ff2fefdce7ecf8722ea53db9800d6612c4f0a81a54334b6ab08f52dd6c28f5f363dd5a59a1bab46e2a2fc30bf2c83ae388fa15e0faf4a3d2da85b1b8a180b77906286eaf4443d9e4825a7df8a7cf940000000000000000000000000000000000000000000000000", "chainId": 560048, "type": 2, "maxFeePerGas": "1672391608", "maxPriorityFeePerGas": "1000000" } } } ``` * `amount` — amount of tokens to stake denominated in Gwei (1 ETH = 10⁻⁹ Gwei) * `stakerAddress` — staking account address receiving the staked tokens. * `unsignedTransactionData` — raw transaction hex string. To be signed and broadcasted. * `extraData` — additional transaction details: * `to` — recipient address for this transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction, following the Ethereum-specific signing logic. To broadcast the signed transaction to the Ethereum network, send a POST request to [/api/v1/eth/transactions](/reference/broadcast-eth-transaction). ```bash bash theme={null} curl --request POST \ --url 'https://api-test.p2p.org/api/v1/unified/transaction/broadcast' \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data '{ "chain": "eth_ssv", "network": "testnet", "signedTransaction": "0x02f9...", "stakerAddress": "0xeE6FFB3fEf95AdA9b4FA606C2Ef90A31D37b6AdB" }' ``` * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. * `signedTransaction`— signed transaction which needs to be broadcast to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "pending", "extraData": { "broadcastedAt": "2026-03-02T07:34:18.278Z", "transactionHash": "0x27b0cb18f0001e9d10aea41a4bcf5cb8e77d97d1b48d7319d21aea7250cea12a", "gas": {} } } } ``` * `status` — transaction status: `pending`, `success`. * `extraData` — additional transaction details: * `broadcastedAt`— time of transaction being broadcasted. * `transactionHash`— hash of the transaction. * `gas`— gas consumed to broadcast transaction. ## Unstaking flow ### 1. Create withdrawal request Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "eth_ssv", "network": "testnet", "stakerAddress": "0x136c861fC99d1624155F5FC8A06BAC79eD8547b1", "extra": { "publicKeys": [ "0x88D461F02A8CBD2B81E39A98318E11724C6CDAA05A7AE8AD318AD29989AB693034209B37B7150BCE00D268163F58360D" ], "withdrawalAddress": "0x136c861fC99d1624155F5FC8A06BAC79eD8547b1" } }' ``` * `chain`— blockchain network. * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional request parameters: * `publicKeys` — list of validators public keys. * `withdrawalAddress`— withdrawal address for the validators. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "list": [ { "serializeTx": "0x02f901ae82426880830f4240830f432c83989680947d5a8de7e3721f6692d88a8d30b9c927fffcdbb480b9018432afd02f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003083340b237f8f07cc3569b94d66e1c1616c5d96ec1f57c75bb81d824eead70f1aa4ffae2dbb32b7aebe8e6bc9dc40eb9c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000050d000000000000000000000000000000000000000000000000000000000000051000000000000000000000000000000000000000000000000000000000000005130000000000000000000000000000000000000000000000000000000000000516c0", "to": "0x7D5a8De7E3721F6692d88A8D30B9C927fffcDBb4", "gasLimit": "10000000", "data": "0x32afd02f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003083340b237f8f07cc3569b94d66e1c1616c5d96ec1f57c75bb81d824eead70f1aa4ffae2dbb32b7aebe8e6bc9dc40eb9c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000050d000000000000000000000000000000000000000000000000000000000000051000000000000000000000000000000000000000000000000000000000000005130000000000000000000000000000000000000000000000000000000000000516", "value": "0", "chainId": 560048, "type": 2, "maxFeePerGas": "1000236", "maxPriorityFeePerGas": "1000000" } ] } } } ``` * `serializeTx` — raw transaction hex string. To be signed and broadcasted. * `to` — recipient address for this transaction. * `gasLimit` — maximum gas limit for this block. * `data` — transaction data. * `value` — transaction value. * `chainId` — chain ID this transaction is authorized on, as specified by EIP-155. * `type` — EIP-2718 type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ### 2. Sign and send transaction Use `serializeTx` to [sign and send](/docs/unified-api-signing-transaction) the transaction via the `stakerAddress` used at deposit, following the Ethereum-specific signing logic. ## Smart contracts [Mainnet](https://etherscan.io/address/0x7F12A9904bA021AE3ecE106e10f476b7AfBd830C) `0x7F12A9904bA021AE3ecE106e10f476b7AfBd830C` [Hoodi](https://hoodi.etherscan.io/address/0xb7576038C090355625469af1eE9F1F0d22bb0e65) `0xb7576038C090355625469af1eE9F1F0d22bb0e65` [Source](https://github.com/p2p-org/p2p-ssv-proxy/blob/v3.1-audited/src/p2pSsvProxyFactory/P2pSsvProxyFactory.sol) [Audit](https://github.com/mixbytes/audits_public/tree/master/P2P.org/SSV%20Integration%20Diff%20Audit%20\(v1\)) # Getting Started Source: https://docs.p2p.org/docs/unified-api-getting-started The Unified API is designed to simplify and standardize interactions across all supported networks. For both staking and unstaking, the process follows a consistent and straightforward flow, ensuring seamless integration for all networks. > [!NOTE] > > This article describes how the Unified API process works in general. > > To see the detailed staking guides for specific chains and networks, refer to the [Networks Supported](/docs/unified-api-networks) section. *** Each network integration supports three key operations: * `stake`: Initiate a staking transaction to delegate the assets * `unstake`: Initiate an unstaking transaction, beginning the process of withdrawing the assets * `withdraw`: Complete the process by withdrawing the unstaked assets to the wallet For each operation, the Unified API returns an unsigned transaction. Thus, the common flow consists of the following steps: 1. **Transaction Preparation**: The API generates a raw unsigned transaction for `stake`, `unstake`, or `withdraw` operation. 2. **Transaction Signing**: The user signs the transaction using the preferred method of signing. P2P.ORG also provides separate, detailed transaction signing instructions for various networks. 3. **Transaction Broadcasting**: The user uses the Unified API’s dedicated `broadcast` method to submit the signed transaction to the network. ## How it works Below, a high-level diagram of the process is provided. ![](https://mintcdn.com/p2p0rg/u_Gj36lEV3_7ct-Y/images/docs/unified-api-diagram.svg?fit=max\&auto=format\&n=u_Gj36lEV3_7ct-Y\&q=85\&s=4b37635a494dc3fb012217c94c6e62b3) 1. The user initiates an operation (`stake`, `unstake`, or `withdraw`) by sending a request to the client system. 2. Client system issues a POST request to the Unified API, specifying one of four supported actions: stake, send transaction, unstake, or withdraw. 3. The Unified API adapter receives the request, validates the parameters and forwards it to the appropriate network-specific API in the required format. 4. The network-specific API processes the request and returns a raw response to the Unified API adapter. 5. The Unified API adapter processes the raw response, transforming it into a standardized unified format to ensure consistent structure across all supported networks. ## General flow **Staking**: 1. Create a staking transaction by sending a POST request to [/api/v1/unified/staking/stake/](/reference/unified-create-stake-transaction). 2. Sign the transaction, using the [chain-specific signing logic](/docs/unified-api-signing-transaction) . 3. Broadcast the signed transaction to the network by sending a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). **Unstaking**: 1. Create an unstaking transaction by sending a POST request to [/api/v1/unified/staking/unstake/](/reference/unified-create-unstake-transaction). 2. Sign and send the unsigned transaction the same way as for staking flow. 3. Create a withdrawal transaction by sending a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). 4. Sign and send the unsigned transaction to the network. > [!NOTE] > > **Note that requests contain network-specific details** > > While the general process remains consistent, there is the distinction between networks lying in the specific POST request parameters required. > > The chain and network mapping table can be found in [Overview](/docs/unified-api-overview). To start using the Unified API, [get an authentication token](/docs/authentication) and see the integration guides in the [Networks](/docs/unified-api-networks) section. # Hyperliquid Source: https://docs.p2p.org/docs/unified-api-hyperliquid Unified API + Hyperliquid Integration Workflow In the following guide, the integration process for the `hyperliquid` chain is covered. The Hyperliquid integration aligns with the general Unified API process but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Hyperliquid-specific details** > > * `chain` — always set to `hyperliquid` for Hyperliquid-related requests. > * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. > * `stakerAddress` — 0x-prefixed account address initiating delegation, undelegation, or withdrawal operations. > * `amount`— amount of tokens in HYPE. > * `signature` — delegator account signature, required for broadcasting transactions. ## Staking flow ### 1. Create staking request To delegate HYPE tokens from the staking balance to the P2P validator, send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Note that delegations have a lock-up period of 1 day, which means that delegations can be partially or fully undelegated only after this period expiration. Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "hyperliquid", "network": "testnet", "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "amount": 10 }' ``` * `chain`— blockchain network, always set to `hyperliquid` for Hyperliquid-related requests. * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. * `stakerAddress` — 0x-prefixed account address initiating the delegate transaction. * `amount` — amount of tokens to delegate in HYPE. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 10, "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "unsignedTransactionData": "eyJhY3Rpb24iOnsidHlwZSI6InRva2VuRGVsZWdhdGUiLCJoeXBlcmxpcXVpZENoYWluIjoiVGVzdG5ldCIsInNpZ25hdHVyZUNoYWluSWQiOiIweDY2ZWVlIiwid2VpIjoxMDAwMDAwMCwibm9uY2UiOjE3NTUwOTQ3MTQ1OTMsInZhbGlkYXRvciI6IjB4YTAxMmI5MDQwZDgzYzVjYmFkOWU2ZWE3M2M1MjUwMjdiNzU1ZuU5NiIsImlzVW5kZWxlZ2F0ZSI6ZmFsc2V9LCJub25jZSI6MTc1NTA5NDcxNDU5Mywic2lnbmF0dXJlIjp7fX0=", "createdAt": "2025-08-01T00:00:00.000Z" } } ``` * `amount` — amount of tokens to delegate in HYPE. * `stakerAddress` — staking account address receiving the delegated tokens. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Hyperliquid-specific signing logic. To broadcast the signed transaction to the Hyperliquid network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "hyperliquid", "network": "testnet", "signedTransaction": "eyJhY3Rpb24iOnsidHlwZSI6InRva2VuRGVsZWdhdGUiLCJoeXBlcmxpcXVpZENoYWluIjoiVGVzdG5ldCIsInNpZ25hdHVyZUNoYWluSWQiOiIweDY2ZWVlIiwid2VpIjoxMDAwMDAwMCwibm9uY2UiOjE3NTUwOTQ3MTQ1OTMsInZhbGlkYXRvciI6IjB4YTAxMmI5MDQwZDgzYzVjYmFkOWU2ZWE3M2M1MjUwMjdiNzU1ZuU5NiIsImlzVW5kZWxlZ2F0ZSI6ZmFsc2V9LCJub25jZSI6MTc1NTA5NDcxNDU5Mywic2lnbmF0dXJlIjp7fX0=", "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88" }' ``` * `chain`— blockchain network. * `network` — environment in which the transaction is processed. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — account address initiated the delegate transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "success" } } ``` * `status` — transaction status: `success`, `pending` or `failed`. ## Unstaking flow ### 1. Create unstaking request To undelegate the HYPE tokens from the P2P validator to the staking balance, send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "hyperliquid", "network": "testnet", "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "extra":{ "amount": 10 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — 0x-prefixed account address initiated the delegate transaction. * `extra` — additional parameters: * `amount` — amount of tokens to undelegate in HYPE. Example response: ```json JSON theme={null} { "error": null, "result": { "unsignedTransactionData": "eyJhY3Rpb24iOnsidHlwZSI6InRva2VuRGVsZWdhdGUiLCJoeXBlcmxpcXVpZENoYWluIjoiVGVzdG5ldCIsInZhbGlkYXRvciI6IjB4YTAxMmI5MDQwZDgzYzVjYmFkOWU2ZWE3M2M1MjUwMjdiNzU1ZjU5NiIsImlzVW5kZWxlZ2F0ZSI6dHJ1ZSwic2lnbmF0dXJlQ2hhaW5JZCI6IjB4NjZlZWUiLCJ3ZWkjOjEwMDAwMDAwLCJub25jZSI6MTc1NDQ3MjU5NDQyMX0sIm5vbmNlIjoxNzU0NDcyNTk0NDIxLCJzaWduYXR1cmUiOnt9fQ==", "createdAt": "2025-08-06T09:29:54.168Z", "extraData": { "amount": 10 } } } ``` * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `amount` — amount of tokens to undelegate in HYPE. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Hyperliquid-specific signing logic. ### 3. Create withdrawal request > [!NOTE] > > Note that it takes 7 days to withdraw tokens from the staking balance to the spot balance on Hyperliquid network. Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "hyperliquid", "network": "testnet", "stakerAddress": "0x2588942932015ae61b7e9b77d41f8ed053dde2b341ccaca57bf6a6ecb4fa511a", "extra":{ "amount": 10 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the delegate transaction. * `extra` — additional parameters: * `amount` — amount of tokens to withdraw in HYPE. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad88", "unsignedTransactionData": "0x717b869e7c8d0d29a5065073df84513d373df54ae7ff85775979c9c9f4d2ad8802000000000000000200000000000000000000000000000000000000000000000000000000000000010f64656c65676174696f6e5f706f6f6c0877697468647261770002207a2ddb6af66beb0d9987c6c9010cb9053454f067e16775a8ecf19961195c3d28086300000000000000e80300000000000064000000000000007f06f587970100000200", "createdAt": "2025-06-19T10:31:11.615Z", "extraData": { "amount": 10 } } } ``` * `stakerAddress` — account address initiating the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `amount` — amount of tokens to withdraw in HYPE. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Hyperliquid-specific signing logic. # Monad Source: https://docs.p2p.org/docs/unified-api-monad Unified API + Monad Integration Workflow In the following guide, the integration process for the `monad` chain is covered. The Monad integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Monad-specific details** > > * `chain` — always set to `monad` for Monad-related requests. > * `network` — environment in which the transaction is processed: `mainnet` or `testnet` (testnet). > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `extra.amount` — amount of tokens in Wei (1 MON = 10¹⁸ Wei); the root-level `amount` field is not used. > > The Unified API flow only supports stake, unstake, and withdraw operations. Compound and claim rewards operations are available via the [direct Monad API](/reference/monad) integration. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "monad", "network": "mainnet", "stakerAddress": "0x1234567890abcdef1234567890abcdef12345678", "amount": 1, "extra": { "amount": "1000000000000000000", "gas": { "maxPricePerGas": "50000000000", "priorityPricePerGas": "2000000000" } } }' ``` * `chain` — blockchain network, always set to `monad` for Monad-related requests. * `network` — environment in which the transaction is processed: `mainnet` or `testnet` for testnet. * `stakerAddress` — account address initiating the staking transaction. * `amount` — not used, any value is ignored; see the `extra.amount` field. * `extra` — additional parameters: * `amount` — amount of tokens to delegate in Wei (1 MON = 10¹⁸ Wei). * `gas` — computational effort required to execute the transaction measured in gas units (optional). If not specified, the values will be set due to the network load. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. Example response: ```json JSON theme={null} { "amount": 0, "stakerAddress": "0x1234567890abcdef1234567890abcdef12345678", "unsignedTransactionData": "0x02f8...", "createdAt": "2026-03-06T12:00:00.000Z", "extraData": { "gas": { "gasLimit": "100000", "maxPricePerGas": "50000000000", "priorityPricePerGas": "2000000000" }, "validatorId": 1, "amount": "1000000000000000000" } } ``` * `amount` — always set to 0 for Monad; the real stake amount is provided in the `extra.amount` field. * `stakerAddress` — account address initiating the staking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `createdAt` — timestamp of the transaction in ISO 8601 format. * `extraData` — additional transaction details: * `gas` — computational effort required to execute the transaction measured in gas units: * `gasLimit` — maximum gas limit for the transaction. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. * `validatorId` — ID of the validator to which tokens are delegated. * `amount` — amount of tokens to delegate in Wei (1 MON = 10¹⁸ Wei). ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Monad-specific signing logic. To broadcast the signed transaction to the Monad network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "monad", "network": "mainnet", "stakerAddress": "0x1234567890abcdef1234567890abcdef12345678", "signedTransaction": "0x02f87a82..." }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — Monad account address initiating the staking transaction. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "status": "broadcasted", "extraData": { "transactionHash": "0xabc123...", "broadcastedAt": "2026-03-06T12:01:00.000Z" } } ``` * `status` — transaction status: `pending`, `broadcasted`, or `failed`. * `extraData` — additional transaction details: * `transactionHash` — hash of the transaction. * `broadcastedAt` — timestamp of the transaction in the ISO 8601 format. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "monad", "network": "mainnet", "stakerAddress": "0x1234567890abcdef1234567890abcdef12345678", "extra": { "amount": "500000000000000000", "gas": { "maxPricePerGas": "50000000000", "priorityPricePerGas": "2000000000" } } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional parameters: * `amount` — amount of tokens to unstake in Wei (1 MON = 10¹⁸ Wei). * `gas` — computational effort required to execute the transaction measured in gas units (optional). If not specified, the values will be set due to the network load. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. Example response: ```json JSON theme={null} { "stakerAddress": "0x1234567890abcdef1234567890abcdef12345678", "unsignedTransactionData": "0x02f8...", "createdAt": "2026-03-06T12:00:00.000Z", "extraData": { "gas": { "gasLimit": "120000", "maxPricePerGas": "50000000000", "priorityPricePerGas": "2000000000" }, "validatorId": 1, "withdrawId": 3, "amount": "500000000000000000" } } ``` * `stakerAddress` — account address initiated the staking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the unstaking transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `gas` — computational effort required to execute the transaction measured in gas units: * `gasLimit` — maximum gas limit for the transaction. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. * `validatorId` — ID of the validator to which tokens are delegated. * `withdrawId` — identifier of the withdrawal request represented as an integer between 0 and 255; required for the withdrawal operation. * `amount` — amount of tokens to unstake in Wei (1 MON = 10¹⁸ Wei). ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Monad-specific signing logic. ### 3. Create withdrawal request Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "monad", "network": "mainnet", "stakerAddress": "0x1234567890abcdef1234567890abcdef12345678", "extra": { "withdrawId": 3, "gas": { "maxPricePerGas": "50000000000", "priorityPricePerGas": "2000000000" } } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the withdrawal transaction. * `extra` — additional parameters: * `withdrawId` — identifier of the withdrawal request from the previous unstake response. * `gas` — computational effort required to execute the transaction measured in gas units (optional). If not specified, the values will be set due to the network load. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. Example response: ```json JSON theme={null} { "stakerAddress": "0x1234567890abcdef1234567890abcdef12345678", "unsignedTransactionData": "0x02f8...", "createdAt": "2026-03-06T12:00:00.000Z", "extraData": { "gas": { "gasLimit": "80000", "maxPricePerGas": "50000000000", "priorityPricePerGas": "2000000000" }, "validatorId": 1, "withdrawId": 3 } } ``` * `stakerAddress` — account address initiated the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `gas` — computational effort required to execute the transaction measured in gas units: * `gasLimit` — maximum gas limit for the transaction. * `priorityPricePerGas` — price per unit of gas in Wei, which is added to the EIP-1559 block's base fee. This added fee is used to incentivize validators to prioritize this transaction. * `maxPricePerGas` — maximum price per unit of gas this transaction will pay for the combined EIP-1559 block's base fee and this transaction's priority fee in Wei. * `validatorId` — ID of the validator from which the tokens are undelegated. * `withdrawId` — identifier of the withdrawal request. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Monad-specific signing logic. # Near Source: https://docs.p2p.org/docs/unified-api-near Unified API + Near Integration Workflow In the following guide, the integration process for the `near` chain is covered. The Near integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Near-specific details** > > * `chain` — always set to `near` for Near-related requests. > * `network` — environment in which the transaction is processed: `mainnet` only. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in NEAR. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "near", "network": "mainnet", "stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040", "amount": "1" }' ``` * `chain` — blockchain network, always set to `near` for Near-related requests. * `network` — environment in which the transaction is processed: `mainnet` only. * `stakerAddress` — Near implicit account address initiating the staking transaction. * `amount` — amount of tokens to stake in NEAR. Minimum amount is 1 NEAR. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 1, "stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040", "unsignedTransactionData": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc0400f146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e6561723bf366edf6cf4e3890d95360b8fbc35cb7a2290076a0aa1224c256efbeb4caf30100000002110000006465706f7369745f616e645f7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d0000000000a1edccce1bc2d3000000000000", "createdAt": "2025-02-19T21:48:10.228Z", "extraData": { "transactionId": "548f7bce-6e03-411d-9118-2d59a021f177", "stakeId": "e0081662-8a9c-47b5-9c26-45320b8ce951", "gasEstimate": { "amount": "0.025000000000000000", "gasLimit": "50000000000000" } } } } ``` * `amount` — amount of tokens to stake in NEAR. * `stakerAddress` — staking account address receiving the staked tokens. * `unsignedTransactionData` — unsigned transaction in hexadecimal (hex) encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the transaction within this staking session. * `stakeId` — unique identifier for the staking request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated transaction fee in NEAR. * `gasLimit` — maximum gas limit for processing the transaction in yoctoNEAR (1 NEAR = 10¹⁸ yoctoNEAR). ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction. To broadcast the signed transaction to the Near network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "near", "network": "mainnet", "signedTransaction": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc04012146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e6561728c7d5ee5f77c298039c9ccd944ebb6218a7a036737c12356e75ef912662509870100000002110000006465706f7369745f616e645f7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d0000000000a1edccce1bc2d300000000000000ebc276fccd41088080c127999bd78cc5ecfbb8ce6282638b5cd19e3f465bd402c8cf30f8e5b4aa4fccae9f81d8340862d4748b102e4e2621533e9f788a793705", "stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040", "extra": { "transactionId": "548f7bce-6e03-411d-9118-2d59a021f177" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `signedTransaction` — signed transaction in hexadecimal (hex) encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — staking account address receiving the staked tokens. * `extra` — additional parameters: * `transactionId` — unique identifier of the staking transaction, obtained from the previous step. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "transactionHash": "HvnL1nyej4cCJnUbeghqWdxeVFkXdDjroA4yN6zcHv9f" } } } ``` * `extraData` — additional transaction details: * `transactionHash` — hash of the block in which the transaction has been included. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "near", "network": "mainnet", "stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040", "extra": { "amount": "1" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional parameters: * `amount` — amount of tokens to withdraw in NEAR. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": "1", "stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040", "unsignedTransactionData": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc0400b146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e656172afa6fb301707310d7c898f7c9f83fc8bc91be960e3a286145afe416f8c418942010000000207000000756e7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d000000000000000000000000000000000000", "createdAt": "2025-02-10T22:36:14.547Z", "extraData": { "transactionId": "69f8b6f1-8b36-4429-843c-90107cfb5bfb", "stakeId": "6f102d59-b479-4a87-905b-7572b904bb01", "gasEstimate": { "amount": "0.025000000000000000", "gasLimit": "50000000000000" } } } } ``` * `amount` — amount of tokens to withdraw in NEAR. * `stakerAddress` — account address initiated the staking transaction. * `unsignedTransactionData` — unsigned transaction in hexadecimal (hex) encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the transaction within this withdrawal session. * `stakeId` — unique identifier of the withdrawal request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated transaction fee in NEAR. * `gasLimit` — maximum gas limit for processing the transaction in yoctoNEAR (1 NEAR = 10¹⁸ yoctoNEAR). ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Near-specific signing logic. ### 3. Create withdrawal request > [!NOTE] > > Note that the withdrawal is available only after the unstaking period, which lasts for 4 epochs (\~72 hours). Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "near", "network": "mainnet", "stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the withdrawal transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": "1", "stakerAddress": "c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc040", "unsignedTransactionData": "400000006339636434396461346662336361646535343264363235666139303961633434336537376131636231306530323837646636633562386466376534636330343000c9cd49da4fb3cade542d625fa909ac443e77a1cb10e0287df6c5b8df7e4cc0400b146f9cac7e0000130000007032702d6f72672e706f6f6c76312e6e656172afa6fb301707310d7c898f7c9f83fc8bc91be960e3a286145afe416f8c418942010000000207000000756e7374616b65260000007b22616d6f756e74223a2231303030303030303030303030303030303030303030303030227d00203d88792d000000000000000000000000000000000000", "createdAt": "2025-02-10T22:36:14.547Z", "extraData": { "transactionId": "69f8b6f1-8b36-4429-843c-90107cfb5bfb", "stakeId": "6f102d59-b479-4a87-905b-7572b904bb01", "gasEstimate": { "amount": "0.025000000000000000", "gasLimit": "50000000000000" } } } } ``` * `amount` — amount of tokens to withdraw in NEAR. * `stakerAddress` — account address initiated the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in hexadecimal (hex) encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the transaction within this withdrawal session. * `stakeId` — unique identifier of the withdrawal request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated transaction fee in NEAR. * `gasLimit` — maximum gas limit for processing the transaction in yoctoNEAR (1 NEAR = 10¹⁸ yoctoNEAR). ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Near-specific signing logic. # Chains Supported Source: https://docs.p2p.org/docs/unified-api-networks The table below summarizes all networks supported in the Unified API and the parameters to be used in the staking endpoints. | Protocol | Chain ID | Network for mainnet | Network for testnet | | - | - | - | - | | [Aptos](/docs/unified-api-aptos) | `aptos` | `mainnet` | `testnet` | | [Cardano](/docs/unified-api-cardano) | `cardano` | `mainnet` | – | | [Celestia](/docs/unified-api-celestia) | `celestia` | `celestia-mainnet-beta` | `celestia-mocha-testnet` | | [Cosmos ATOM](/docs/unified-api-cosmos) | `cosmos` | `cosmoshub-4` | – | | [Ethereum](/docs/unified-api-ethereum) | `eth_ssv` | `mainnet` | `testnet` (Hoodi) | | [Hyperliquid](/docs/unified-api-hyperliquid)\* | `hyperliquid` | `mainnet` | `testnet` | | [Kusama](/docs/unified-api-polkadot) | `polkadot` | - | `kusama` | | [Monad](/docs/unified-api-monad) | `monad` | `mainnet` | `testnet` | | [Near](/docs/unified-api-near) | `near` | `mainnet` | – | | [Polkadot](/docs/unified-api-polkadot) | `polkadot` | `mainnet` | `westend` (Westend) | | [Polygon](/docs/unified-api-polygon) | `polygon` | `mainnet` | – | | [Sei](/docs/unified-api-sei) | `sei` | `pacific-1` | `atlantic-2` | | [Sui](/docs/unified-api-sui) | `sui` | `mainnet` | `testnet` | | [Solana](/docs/unified-api-solana) | `solana` | `mainnet-beta` | `testnet` (Testnet) | | [Story Protocol](/docs/unified-api-story-protocol) | `story` | `mainnet` | `aeneid` | | [Tezos](/docs/unified-api-tezos) | `xtz` | `mainnet` | – | | [TON](/docs/unified-api-ton) | `ton_whales` | `mainnet` (TON Whales) | `testnet` (TON Whales) | | [TRON](/docs/unified-api-tron) | `tron` | `mainnet` | `testnet-nile` | ## Testing and production environments We provide two distinct endpoints for testing and production environments: * Production: \<[https://api.p2p.org](https://api.p2p.org)> * Testing: \<[https://api-test.p2p.org](https://api-test.p2p.org)> # Overview Source: https://docs.p2p.org/docs/unified-api-overview The Unified API provides a standardized platform to manage staking, transaction broadcasting, and unstaking across multiple blockchain networks. Its modular architecture simplifies integrations, enabling quick support for new networks. Connect once, and you’re ready to interact with all supported networks. This modular flow ensures that users can seamlessly integrate both existing and future supported networks, as they will maintain a consistent structure. ## Overview of Unified API [Unified API overview](https://www.youtube.com/embed/ArNldTRVmlc) ## Key features * **Seamless Cross-Network Compatibility**. Streamline operations with a unified request/response format and consistent staking workflows across all the existing and future supported networks. * **Fewer Integrations**. By consolidating a number of Staking APIs into a single one, Unified API allows reducing the diversity of integrations to accommodate tech stacks. * **Coverage**. The Unified API supports the following chains: Solana, TON, Avail, and Ethereum (SSV). We are expanding this initial list to meet the clients' growing demands, with up to 30 chains available via one API endpoint. [Get an authentication token](/docs/authentication) to start using Unified API. ## Supported chains and networks See all [Networks Supported](/docs/unified-api-networks). # Polkadot Source: https://docs.p2p.org/docs/unified-api-polkadot Unified API + Polkadot Integration Workflow In the following guide, the integration process for the `polkadot` chain is covered. The Polkadot integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Polkadot-specific details** > > * `chain` — always set to `polkadot` for Polkadot-related requests. > * `network` — environment in which the transaction is processed: `kusama` ,`westend` or `mainnet`. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens for bond operations. DOT is used for the main network, KSM for Kusama, and WND for Westend. ## Staking flow ### 1. Create bonding request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `westend` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "polkadot", "network": "westend", "stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "amount": "1" }' ``` * `chain` — blockchain network, always set to `polkadot` for Polkadot-related requests. * `network` — environment in which the transaction is processed: `kusama` , `westend` or `mainnet`. * `stakerAddress` — account address initiating the bonding transaction. * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `extraData` — additional parameters: * `stashAccountAddress` — not needed for this step. required only for step (2) nomination request. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 1, "createdAt": "2025-03-07T07:10:20.966Z", "extraData": { "unsignedTransaction": "0xa8040600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e", "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "rewardDestinationType": "account", "rewardDestination": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ" } } } ``` * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `stashAccountAddress` — main stash account (On Polkadot and Avail, this is an account that holds funds bonded for staking, but delegates all staking functions to a staking proxy account. You may actively participate in staking with a stash private key kept in a cold wallet like Ledger, meaning it stays offline all the time. Having a staking proxy will allow you to sign all staking-related transactions with the proxy instead of using your Ledger device. This will allow you to avoid carrying around your Ledger device just to sign staking-related transactions, and to keep the transaction history of your stash clean.) address which keeps tokens for bonding. * `rewardDestinationType` — type of receiving the rewards: * `staked` — rewards will be sent to the stash account (On Polkadot and Avail, this is an account that holds funds bonded for staking, but delegates all staking functions to a staking proxy account. You may actively participate in staking with a stash private key kept in a cold wallet like Ledger, meaning it stays offline all the time. Having a staking proxy will allow you to sign all staking-related transactions with the proxy instead of using your Ledger device. This will allow you to avoid carrying around your Ledger device just to sign staking-related transactions, and to keep the transaction history of your stash clean.) and added to the current bond (compounding rewards). * `stash` — rewards will be sent to the stash account (On Polkadot and Avail, this is an account that holds funds bonded for staking, but delegates all staking functions to a staking proxy account. You may actively participate in staking with a stash private key kept in a cold wallet like Ledger, meaning it stays offline all the time. Having a staking proxy will allow you to sign all staking-related transactions with the proxy instead of using your Ledger device. This will allow you to avoid carrying around your Ledger device just to sign staking-related transactions, and to keep the transaction history of your stash clean.) as a transferrable balance (not compounding rewards). * `controller` — rewards will be sent to the controller account. * `account` — default; rewards will be sent to any account specified as a transferrable balance. * `rewardDestination` — rewards destination account address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Polkadot-specific signing logic. To broadcast the signed transaction to the Polkadot network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "polkadot", "network": "westend", "stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "signedTransaction": "0x410284007427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e01f214ddb36378b5f5927b06028eccfe284d9cb736f8552e301cc09c2006998b098f84bf6386a201aa952fe298dd5f0c5fb6f03fc7b9f7efafd87b6ee321500b8e450340000600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the bonding transaction. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "success", "extraData": { "network": "westend", "signedTransaction": "0x450284007427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e011c38a0ce7dad52c9500843dddb52645bc790891c61963a454dcb79cbc3e0545fcc64d1fcbebea0769392248dc3d34e60568452ebbe44bd0f876ecae73a8eae8915012000000600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e", "blockHash": "0x5cffd50711d3de0a896687ce2939313dd00491edc820d3abeaefe6a997be3a4f", "blockId": 25052458, "extrinsicId": 2, "transactionHash": "0xb5546fbfb7221c358d8e593cc094430a884a9f41b765003674b59aaf16d0f5f2", "signerAccount": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "data": { "args": { "value": "1,000,000,000,000", "payee": { "Account": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ" } }, "method": "bond", "section": "staking" }, "createdAt": "2025-03-07T03:57:30.386Z" } } } ``` * `status` — transaction status: `pending`, `success` or `failed`. * `extraData` — additional transaction details: * `network` — environment in which the transaction is processed. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `blockHash` — block hash in which the transaction has been included. * `blockId` — unique block identifier. * `extrinsicId` — unique extrinsic (On Polkadot and Avail, a SCALE encoded array consisting of a version number, signature, and varying data types indicating the resulting runtime function to be called, including the parameters required for that function to be executed. These state changes are invoked from the outside world, i.e., they are not part of the system itself. Extrinsics can take two forms, “inherents” and “transactions”.) identifier. * `transactionHash` — signed transaction in the hexadecimal format. * `signerAccount` — account that signed the transaction. * `data` is the list of data fields to be used to construct the bonding transaction. * `args.value` — amount of tokens to bond. * `args.payee` — type of receiving the rewards: * `staked` — rewards will be sent to the stash account and added to the current bond (compounding rewards). * `stash` — rewards will be sent to the stash account as a transferable balance (not compounding rewards). * `controller` — rewards will be sent to the controller account. * `account` — default; rewards will be sent to any account specified as a transferrable balance. * `args.payee.Account` — account address initiated the bonding transaction. * `method` — operation type. * `section` — endpoint section type. `createdAt` — timestamp of the transaction in the ISO 8601 format. ### 3. Create nomination request > [!WARNING] > > **Note: Accessing High-APR Nodes** > > To benefit from P2P.org’s high-APR validators on Polkadot (DOT), you must attach the **P2P.org proxy** to your account. These private validators require explicit approval and cannot be nominated via standard methods. Ensure the proxy is attached during your integration flow to unlock the enhanced staking rewards. > > Contact our [team](/docs/contacts) for dedicated assistance. Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `westend` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "polkadot", "network": "westend", "stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "amount": "1", "extra": { "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the bonding transaction. * `amount` — amount of tokens to bond. DOT is used for the main network, KSM for Kusama, and WND for Westend. * `extraData` — additional parameters: * `stashAccountAddress` — main stash account address which keeps tokens for bonding. Example response: ```json JSON theme={null} { "error": null, "result": { "createdAt": "2025-03-07T03:59:22.666Z", "extraData": { "unsignedTransaction": "0x19010406050800be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f00fe65717dad0447d715f660a0a58411de509b42e6efb8375f562f58a554d5860e", "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "targets": [ "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", "5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc" ] } } } ``` * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `targets` — validators selected in the [targets](https://polkadot.js.org/apps/#/staking/targets). ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polkadot-specific signing logic. ## Unstaking flow ### 1. Create unbonding request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request (for `westend` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "polkadot", "network": "westend", "stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ" "extra": { "amount": 1 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the bonding transaction. * `extra` — additional parameters: * `amount` — amount of tokens to unbond. DOT for mainnet, KSM for Kusama and WND for Westend. Example response: ```json JSON theme={null} { "error": null, "result": { "createdAt": "2025-03-07T04:02:18.033Z", "extraData": { "unsignedTransaction": "0x24040602070010a5d4e8", "stashAccountAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "amount": 1 } } } ``` * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `stashAccountAddress` — main stash account address which keeps tokens for bonding. * `amount` — amount of tokens to unbond. DOT is used for the main network, KSM for Kusama, and WND for Westend. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polkadot-specific signing logic. ### 3. Create withdrawal request > [!NOTE] > > Note that the withdrawal is available only after the unbonding period. It takes 7 days (28 eras) to unbond on Kusama, 28 days (28 eras) on Polkadot, and 12 hours (2 eras) on Westend. Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request (for `westend` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "polkadot", "network": "westend", "stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the unbonding transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "5Eh1C69jwNgBPtp2oKxJ7Zy5dS6LJn3XZ6CJHPwcAB2iFpZQ", "unsignedTransactionData": "0x1c04060300000000", "createdAt": "2025-03-07T04:30:47.854Z", "extraData": {} } } ``` * `stakerAddress` — account address initiating the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polkadot-specific signing logic. # Polygon Source: https://docs.p2p.org/docs/unified-api-polygon Unified API + Polygon Integration Workflow In the following guide, the integration process for the `polygon` chain is covered. The Polygon integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. > [!WARNING] > > Polygon staking is only supported on **mainnet**. There is no testnet support for Polygon. Always set `network` to `mainnet` for all Polygon requests. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Polygon-specific details** > > * `chain` — always set to `polygon` for Polygon-related requests. > * `network` — environment in which the transaction is processed. Must always be set to `mainnet`. > * `stakerAddress` — Ethereum-compatible account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in MATIC. ## Staking flow ### 1. Approve token management > Note that the flow uses transactions of type 2 (EIP-1559). Staking, unstaking, and withdrawal operations require interaction with smart contracts via prepared transactions. Approve transferring your MATIC tokens to the staking contract by sending a POST request to [/api/v1/polygon/staking/approve](/reference/polygon-staking-approve). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/polygon/staking/approve \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data ' { "amount": "1000000000000000000", "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21" }' ``` * `amount` — amount of tokens in POL to approve staking operations. * `stakerAddress` — staker account address providing approval. Example response: ```json JSON theme={null} { "error": null, "result": { "serializeTx": "0x02f86c0180830e57e084b6687a7c830f424094455e53cbb86018ac2b8092fdcd39d8444affc3f680b844095ea7b3000000000000000000000000455e53cbb86018ac2b8092fdcd39d8444affc3f60000000000000000000000000000000000000000000000000de0b6b3a7640000c0", "to": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6", "gasLimit": "1000000", "data": "0x095ea7b3...", "value": "0", "chainId": 137, "type": 2, "maxFeePerGas": "3060300412", "maxPriorityFeePerGas": "940000" } } ``` * `serializeTx` — serialized unsigned transaction ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) format). * `to` — recipient contract address for approval. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for the transaction. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137. * `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ### 2. Sign and send transaction Use `serializeTx` to [sign](/docs/unified-api-signing-transaction) the transaction using the Polygon-specific signing logic. To broadcast the signed transaction to the Polygon network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data ' { "chain": "polygon", "network": "mainnet", "signedTransaction": "", "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21" }' ``` * `chain` — blockchain network, always set to `polygon` for Polygon-related requests. * `network` — must always be set to `mainnet`. Polygon does not support testnet. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — staker account address initiating the staking transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "transactionHash": "0x2423921ace5d44e1df4f61a966917b738ae1dd3eaad085efc6eef4275e454088", "signedTransaction": "", "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21", "sentAt": "2025-04-23T17:21:11.991Z" } } } ``` * `extraData` — additional transaction details: * `transactionHash` — hash of the broadcasted approval transaction. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — staking account address initiating the delegate transaction. * `sentAt` — timestamp of the transaction in the ISO 8601 format. ### 3. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data ' { "chain": "polygon", "network": "mainnet", "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21", "amount": "1" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staker account address initiating the staking transaction. * `amount` — amount of tokens to delegate in MATIC. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21", "unsignedTransactionData": "0x02f86c0180830e57e084a51c350e830f42409415c2b3adca66e26b6f230b4023f52a285b7f999580b8446ab150710000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000c0", "extraData": { "to": "0x15C2b3AdcA66E26B6F230b4023f52a285b7f9995", "gasLimit": "1000000", "data": "0x6ab15071...", "value": "0", "chainId": 137, "type": 2, "maxFeePerGas": "2770089230", "maxPriorityFeePerGas": "940000" } } } ``` * `stakerAddress` — staker account address initiated the delegate transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `extraData` — additional transaction details: * `to` — recipient contract address for approval. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for the transaction. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137. * `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polygon-specific signing logic. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data ' { "chain": "polygon", "network": "mainnet", "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21", "extra": { "amount": "1" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staker account address initiating the undelegate transaction. * `extra` — additional parameters: * `amount` — amount of tokens to undelegate in MATIC. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21", "unsignedTransactionData": "0x02f86c0180830e57e084a8c1ba86830f42409415c2b3adca66e26b6f230b4023f52a285b7f999580b844c83ec04d...", "extraData": { "to": "0x15C2b3AdcA66E26B6F230b4023f52a285b7f9995", "gasLimit": "1000000", "data": "0xc83ec04d...", "value": "0", "chainId": 137, "type": 2, "maxFeePerGas": "2831268486", "maxPriorityFeePerGas": "940000" } } } ``` * `stakerAddress` — staker account address initiated the undelegate transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `extraData` — additional transaction details: * `to` — recipient contract address for approval. * `gasLimit` — maximum gas limit for the transaction. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137. * `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polygon-specific signing logic. ### 3. Create withdrawal request > [!NOTE] > > Note that it takes up to 3-4 days to prepare your tokens for unstaking as Polygon uses a system of checkpoints (On Polygon, a means of measure for the undelegate period. 1 checkpoint takes approximately 3 hours. However, some checkpoints could be delayed due to congestion on Ethereum. This period applies to the originally delegated amount and re-delegated amounts. It does not apply to any rewards that were not re-delegated.). The average undelegate period on Polygon is 80 checkpoints. Withdrawal is only available after the undelegate period ends. Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data ' { "chain": "polygon", "network": "mainnet", "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staker account address initiating the withdrawal transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "0x368F823e4dfe271dc820f4Ea14689917bf8e4a21", "unsignedTransactionData": "0x02f86c0180830e57e084a51c350e830f42409415c2b3adca66e26b6f230b4023f52a285b7f999580b8444e71d92d...", "extraData": { "to": "0x15C2b3AdcA66E26B6F230b4023f52a285b7f9995", "gasLimit": "1000000", "data": "0x4e71d92d...", "value": "0", "chainId": 137, "type": 2, "maxFeePerGas": "2770089230", "maxPriorityFeePerGas": "940000" } } } ``` * `stakerAddress` — staker account address initiated the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `extraData` — additional transaction details: * `to` — recipient contract address for approval. * `gasLimit` — maximum gas limit for the transaction. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). Polygon chain ID for `mainnet` is 137. * `type` — [EIP-1559](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Polygon-specific signing logic. # Sei Source: https://docs.p2p.org/docs/unified-api-sei Unified API + Sei Integration Workflow In the following guide, the integration process for the `sei` chain is covered. The Sei integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Sei-specific details** > > * `chain` — always set to `sei` for Sei-related requests. > * `network` — environment in which the transaction is processed: `pacific-1` or `atlantic-2`. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in SEI. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `pacific-1` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "sei", "network": "pacific-1", "stakerAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp", "amount": 0.1, "extra": { "memo": "memo" } }' ``` * `chain` — blockchain network, always set to `sei` for Sei-related requests. * `network` — environment in which the transaction is processed: `pacific-1` or `atlantic-2`. * `stakerAddress` — account address initiating the staking transaction. * `amount` — amount of tokens to stake in SEI, minimum amount is 0.1. * `extra` — additional parameters: * `memo` — arbitrary text data to add to the transactions. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 0.1, "stakerAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp", "unsignedTransactionData": { "messages": [ { "typeUrl": "/sei.staking.v1beta1.MsgDelegate", "value": { "delegatorAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp", "validatorAddress": "seivaloper1qmpxlswwk42wya67t7zsaawf3vur03cuevss0h", "amount": { "denom": "usei", "amount": "100000" } } } ], "fee": { "amount": [ { "amount": "4851", "denom": "usei" } ], "gas": "194020" }, "memo": "abc", "encodedBody": "0a96010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465126f0a2a7365693138667a67767a79336830713634367771326e777a34327a72743578737279757366386a6d6d70123173656976616c6f70657231716d70786c7377776b3432777961363774377a736161776633767572303363756576737330681a0e0a047573656912063130303030301203616263", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103c0caf89df9997994f61207d69c755060aeadf9cbf1ba3ea3fa9117bdb304414e12040a020801180612120a0c0a047573656912043438353110e4eb0b", "messageHash": "ef6f9484c2aaf4d27b9b1354e2a52491869f5250746976fcaba3c30f8437ac03" }, "createdAt": "2025-03-06T12:53:02.657Z", "extraData": { "currency": "sei", "validatorAddress": "seivaloper1qmpxlswwk42wya67t7zsaawf3vur03cuevss0h", "rewardDestinationAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp" } } } ``` * `amount` — amount of tokens to stake in SEI. * `stakerAddress` — staking account address receiving the staked tokens. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. It contains the list of data fields to be used to construct the staking transactions: * `messages`: * `typeUrl` — Sei network operation type. * `delegatorAddress` — delegator address. * `validatorAddress` — validator address. * `amount` — amount of tokens to stake. * `denom` — currency of tokens: * `sei` — SEI native staking token. * `usei` — 1 SEI = 10⁶ uSEI. * `msei` — 1 SEI = 10³ mSEI. * `fee` — fee charged for processing the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `sei`, `usei`, or `msei`. * `gas` — amount of gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. * `messageHash` — hash of the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `currency` — currency of tokens: `sei`, `usei`, or `msei`. * `validatorAddress` — validator address to which tokens are delegated. * `rewardDestinationAddress` — reward destination account address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction. To broadcast the signed transaction to the Sei network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request (for `pacific-1` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "sei", "network": "pacific-1", "stakerAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp", "amount": 0.1, "signedTransaction": "0a9e010a96010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c6567617465126f0a2a7365693138667a67767a79336830713634367771326e777a34327a72743578737279757366386a6d6d70123173656976616c6f70657231716d70786c7377776b3432777961363774377a736161776633767572303363756576737330681a0e0a04757365691206313030303030120361626312660a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103c0caf89df9997994f61207d69c755060aeadf9cbf1ba3ea3fa9117bdb304414e12040a020801180612120a0c0a047573656912043438353110e4eb0b1a4012ce8717390c205ea7fc800c1d0aeacc260d558906f2825756cdef24a13daaae57256b6a8b1085ae8af77f8c9a59a83933b9f5a456e5d563f9048ab1bb691036" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staking account address receiving the staked tokens. * `amount` — amount of tokens to stake in SEI. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "success", "extraData": { "blockId": 135190135, "fee": 0.004850999999999999, "gas": { "used": 160707, "wanted": 194020 }, "transactionHash": "76EDCE98041DFA42615DEA1BF483AD4752D2C389B8B312DFEB4F5171F7F57BBD" } } } ``` * `status` — transaction status: `pending`, `success` or `failed`. * `extraData` — additional transaction details: * `blockId` — unique identifier of the block in which the transaction has been included. * `fee` — total fee in SEI charged for processing the transaction. * `gas` — computational effort required to execute the transaction, measured in gas units. * `used` — amount of gas spent for the transaction. * `wanted` — maximum gas limit available to consume for the transaction. * `transactionHash` — hash of the transaction. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request (for `pacific-1` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "sei", "network": "pacific-1", "stakerAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp" "extra": { "amount": 0.1 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional parameters: * `amount` — amount of tokens to unstake in SEI, minimum amount is 0.1 SEI. Example response: ```json JSON theme={null} { "error": null, "result": { "unsignedTransactionData": { "messages": [ { "typeUrl": "/sei.staking.v1beta1.MsgUndelegate", "value": { "delegatorAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp", "validatorAddress": "seivaloper1qmpxlswwk42wya67t7zsaawf3vur03cuevss0h", "amount": { "denom": "usei", "amount": "100000" } } } ], "fee": { "amount": [ { "amount": "5222", "denom": "usei" } ], "gas": "208859" }, "memo": "", "encodedBody": "0a98010a252f636f736d6f732e7374616b696e672e763162657461312e4d7367556e64656c6567617465126f0a2a7365693138667a67767a79336830713634367771326e777a34327a72743578737279757366386a6d6d70123173656976616c6f70657231716d70786c7377776b3432777961363774377a736161776633767572303363756576737330681a0e0a04757365691206313030303030", "encodedAuthInfo": "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103c0caf89df9997994f61207d69c755060aeadf9cbf1ba3ea3fa9117bdb304414e12040a020801180712120a0c0a047573656912043532323210dbdf0c", "messageHash": "eb685b1e4f0c8fe5fb9c44ec83bc58ca5351756b28a78ec32efa8df7c736f77b" }, "createdAt": "2025-03-06T12:55:03.838Z", "extraData": { "amount": 0.1, "currency": "sei", "validatorAddress": "seivaloper1qmpxlswwk42wya67t7zsaawf3vur03cuevss0h", "stashAccountAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp", "rewardDestinationAddress": "sei18fzgvzy3h0q646wq2nwz42zrt5xsryusf8jmmp" } } } ``` * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. It is the list of data fields to be used to construct the staking transactions. * `messages`: * `typeUrl` — Sei network operation type. * `delegatorAddress` — delegator address. * `validatorAddress` — validator address. * `amount` — amount of tokens to unstake. * `denom` — currency of tokens: * `sei` — SEI native staking token. * `usei` — 1 SEI = 10⁶ uSEI. * `msei` — 1 SEI = 10³ mSEI. * `fee` — fee charged for processing the transaction. * `amount` — amount of tokens. * `denom` — currency of tokens: `sei`, `usei`, or `msei`. * `gas` — amount of gas spent for the transaction. * `memo` — arbitrary text data to add to the transactions. * `encodedBody` — processable transaction data encoded in the hexadecimal format. * `encodedAuthInfo` — authorization data, including fee, encoded in the hexadecimal format. * `messageHash` — hash of the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `amount` — amount of tokens to unstake in SEI. * `currency` — currency of tokens: `sei`, `usei`, or `msei`. * `validatorAddress` — validator address from which tokens are delegated. * `stashAccountAddress` — staking account address keeping the staked tokens. * `rewardDestinationAddress` — rewards destination account address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Sei-specific signing logic. # Sign and Broadcast Transaction Source: https://docs.p2p.org/docs/unified-api-signing-transaction In the Unified API, transaction signing logic varies depending on the specific blockchain network. Nevertheless, a unified method to broadcast a signed transaction to the network is used. To sign and broadcast a transaction to the Unified API supported network, follow these steps: 1. Prepare unsigned transactions in Base64 encrypted or hex-encoded format (`unsignedTransactionData` by default). 2. Sign the transaction using the [Signer SDK](/docs/signer-sdk-overview), configured to the specific protocol. 3. Broadcast the signed transaction to the network by sending a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request (for `solana` chain and `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "solana", "network": "testnet", "stakerAddress": "9FfyCk9kqgfpg1gYMw8rhksZcAg4JiD9xhuMvkFVdjQY", "signedTransaction": "AdtQhLeM0eOMdV7rvagYx3V8mra6CMaiVgeNTcgTds8ltjDUwJi3LMGhZ+Txqj26nJMJa7MxFWe5lmIxAnjKsQUBAAIEep+wazhVDEf2XiuHusgypzGMGyd4WaFZ6lzpHIypRJ3qFo72gQoaoUsCAJcUGGTQGdOONNYMBdVbIhEKwGitMwah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAABojzQ55lMuIXx6AWTccH48p4L12JlvUuCfHkOik1nJLAECAwEDAAQFAAAA" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staking account address keeping the staked tokens. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response (for `solana` chain and `testnet` network): ```json JSON theme={null} { "error": null, "result": { "extraData": { "transactionId": "2Bno5j3tex8VmcCR2M6JQnjtPxDuqAvSAUjSDpd6gaasRfEQeoWH9MRQdU7ANNtFFbG9UQAGByG1UwPS1qersmyd", "slot": 307375529, "signerAccounts": [ "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "6GtymMn8cDTy3xHH9AitwP6skbKvBkD53XBE2xSu1tCR", "11111111111111111111111111111111", "A93XLdBKfc4pwEMAvdFeyxnF6HauN5erNDFbUsemWiaB", "Stake11111111111111111111111111111111111111", "StakeConfig11111111111111111111111111111111", "SysvarC1ock11111111111111111111111111111111", "SysvarRent111111111111111111111111111111111", "SysvarStakeHistory1111111111111111111111111" ], "createdAt": "2024-12-17T19:41:27.450Z" } } } ``` * `extraData` — additional transaction details specific to the network: * `transactionId` — block hash in which the transaction has been included. * `slot` — period of time during which each leader collects transactions and creates a block in the Solana network. * `signerAccounts` — account addresses that signed the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. # Solana Source: https://docs.p2p.org/docs/unified-api-solana Unified API + Solana Integration Workflow In the following guide, the integration process for the `solana` chain is covered. The Solana integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Solana-specific details** > > * `chain`— always set to `solana` for Solana-related requests. > > * `network`— environment in which the transaction is processed: `testnet` or `mainnet-beta`. > > * `stakerAddress`— account address initiating staking, unstaking or withdrawal transactions. It also serves as: > > * `feePayer` — account address that will pay the fee for the transaction. > * `fromPublicKey` — account address from which the staking account will be created. > * `stakeAuthority` — account address that can perform staking operations with the staking account. > * `withdrawAuthority` — account address that can perform staking operations with the staking account. If not specified, permissions will be taken from the `fromPublicKey` parameter. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "solana", "network": "testnet", "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "amount": "1002282880" }' ``` * `chain` — blockchain network, always set to `solana` for Solana-related requests. * `network` — environment in which the transaction is processed: `testnet` or `mainnet-beta`. * `stakerAddress` — staking account address receiving the staked tokens. * `amount` — amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). Min amount is 1002282880. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 1002282880, "stakerAddress": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo", "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcJgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAh8iugT4hbb/uMDOx66iyC43XvE2dwUsI1HUUjzs6IbAGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAah2BelAgULaAeR5s5tuI4eW3FQ9h/GeQpOtNEAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGSxcUSGMyUw9SvF/WNruCJuh/UTj29mKAAAAAAan1RcZNYTQ/u2bs0MdEyBr5UQoG1e4VmzFN1/0AAAAHKEjIcCxFWx4HvZBQrHANtq0grHucq4V1OVMlBvalFQDAgIAAXQDAAAAgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cAYAAAAAAAAAEZiVWJmK1A0UzRLK1h5V3pTRXBjaHc9PYCfvTsAAAAAyAAAAAAAAAAGodgXkTdUKpg0N73+KnqyVX9TXIp4citopJ3AAAAAAAQCAQd0AAAAAIFjhdI9y2XfP9n3vsVrYeYhb33RJ6UQWfZbtPp0o+nAgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBgEDBggFAAQCAAAA", "createdAt": "2024-12-17T19:40:29.176Z", "extraData": { "network": "testnet", "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "fromPublicKey": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "voteAccount": "A93XLdBKfc4pwEMAvdFeyxnF6HauN5erNDFbUsemWiaB" } } } ``` * `amount` — amount of tokens to stake in lamports (1 SOL = 10⁹ lamports). * `stakerAddress` — staking account address receiving the staked tokens. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `network` — environment in which the transaction is processed. * `feePayer` — account address that will pay the fee for the transaction. * `fromPublicKey` — account address from which the staking account will be created. * `stakeAuthority` — account address that can perform staking operations with the staking account. * `withdrawAuthority` — account address that can perform withdrawal operations with the staking account. If not specified, rights will be taken from the `fromPublicKey` parameter. * `voteAccount` — vote account address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction. To broadcast the signed transaction to the Solana network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "solana", "network": "testnet", "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "signedTransaction": "AdtQhLeM0eOMdV7rvagYx3V8mra6CMaiVgeNTcgTds8ltjDUwJi3LMGhZ+Txqj26nJMJa7MxFWe5lmIxAnjKsQUBAAIEep+wazhVDEf2XiuHusgypzGMGyd4WaFZ6lzpHIypRJ3qFo72gQoaoUsCAJcUGGTQGdOONNYMBdVbIhEKwGitMwah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAABojzQ55lMuIXx6AWTccH48p4L12JlvUuCfHkOik1nJLAECAwEDAAQFAAAA" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staking account address receiving the staked tokens. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "transactionId": "2Bno5j3tex8VmcCR2M6JQnjtPxDuqAvSAUjSDpd6gaasRfEQeoWH9MRQdU7ANNtFFbG9UQAGByG1UwPS1qersmyd", "slot": 307375529, "signerAccounts": [ "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "6GtymMn8cDTy3xHH9AitwP6skbKvBkD53XBE2xSu1tCR", "11111111111111111111111111111111", "A93XLdBKfc4pwEMAvdFeyxnF6HauN5erNDFbUsemWiaB", "Stake11111111111111111111111111111111111111", "StakeConfig11111111111111111111111111111111", "SysvarC1ock11111111111111111111111111111111", "SysvarRent111111111111111111111111111111111", "SysvarStakeHistory1111111111111111111111111" ], "createdAt": "2024-12-17T19:41:27.450Z" } } } ``` * `extraData` — additional transaction details: * `transactionId` — block hash in which the transaction has been included. * `slot` — period of time during which each leader collects transactions and creates a block in the Solana network. * `signerAccounts` — account addresses that signed the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "solana", "network": "testnet", "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "extra": { "amount": "1002282880", "stakeAccount": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiated the staking transaction. * `extra` — additional parameters: * `amount` — amount of tokens to unstake in lamports (1 SOL = 10⁹ lamports). Min amount is 1002282880. * `stakeAccount` — account address that keeps tokens. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo", "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAIEgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAC6Oo3oUHKupolPnHZ0RH2ZxtrEHm8tk2Qp2iW0vfhHhgECAwEDAAQFAAAA", "createdAt": "2024-12-17T19:46:06.403Z", "extraData": { "network": "testnet", "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "stakeAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw" } } } ``` * `stakerAddress` — staking account address initiating the unstake transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `network` — environment in which the transaction is processed. * `feePayer` — account address that will pay the fee for the transaction. * `stakeAuthority` — account address that can perform staking operations with the staking account. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Solana-specific signing logic. ### 3. Create withdrawal request > [!NOTE] > > Note that the withdrawal is available only after the unstaking period of 1 epoch (\~72 hours). Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "solana", "network": "testnet", "stakerAddress": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "extra": { "amount": "1002282880", "stakeAccount": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the withdrawal transaction. * `extra` — additional parameters: * `amount` — amount of tokens to withdraw in lamports (1 SOL = 10⁹ lamports). Min amount is 1002282880. * `stakeAccount` — account address that keeps tokens. Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "AymQ9qoDXMg4G9RcyjB5AFiXXim1NtnCjcMzL7f4NYLo", "unsignedTransactionData": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAMFgWOF0j3LZd8/2fe+xWth5iFvfdEnpRBZ9lu0+nSj6cBOXOtVnnzgdQsGlzC2Y3c6ptktzhYaKKHNw0Bi1oHf4gah2BeRN1QqmDQ3vf4qerJVf1NcinhyK2ikncAAAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAGp9UXGTWE0P7tm7NDHRMga+VEKBtXuFZsxTdf9AAAAPOAx5l5F5rUaY7eB6UQVXzEi9E6HWzj9Mg5vRAcUMlcAQIFAQADBAAMBAAAAICfvTsAAAAA", "createdAt": "2024-12-17T19:49:22.476Z", "extraData": { "network": "testnet", "feePayer": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "withdrawAuthority": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "recipient": "9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw", "amount": 1002282880 } } } ``` * `stakerAddress` — staking account address initiated the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `network` — environment in which the transaction is processed. * `feePayer` — account address that will pay the fee for the transaction. * `withdrawAuthority` — account address that can perform withdrawal operations with the staking account. * `recipient` — account address to which tokens will be sent. * `amount` — amount of tokens to withdraw in lamports (1 SOL = 10⁹ lamports). ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Solana-specific signing logic # Story Protocol Source: https://docs.p2p.org/docs/unified-api-story-protocol Unified API + Story Protocol Integration Workflow In the following guide, the integration process for the `story` chain is covered. The Story Protocol integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Story-specific details** > > * `chain` — always set to `story` for Story-related requests. > * `network` — environment in which the transaction is processed: `mainnet` or `aeneid`(testnet). > * `stakerAddress` — Ethereum account address of the user initiating staking, unstaking or withdrawal operations, which keeps the Story blockchain tokens. > * `amount` — amount of tokens in IP. > * `extra.stakingPeriod` — staking period duration. > * `extra.tokenType`— token source type. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `aeneid` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "story", "network": "aeneid", "stakerAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", "amount": 1024, "extra": { "stakingPeriod": "FLEXIBLE", "gas": { "maxFeePerGas": 10, "maxPriorityFeePerGas": 1, "gasLimit": 21000 } } }' ``` * `chain` — blockchain network, always set to `story` for Story-related requests. * `network` — environment in which the transaction is processed: `mainnet` or `aeneid`(testnet). * `stakerAddress` — staking account address receiving the staked tokens. * `amount`— amount of tokens to stake in IP. Minimum stake amount is **1024 IP**. * `extra` — additional parameters: * `stakingPeriod` — staking period duration: * `FLEXIBLE` — no lock-up; funds can be withdrawn at any time. * `SHORT` — 90 days of the lock-up period. * `MEDIUM` — 360 days of the lock-up period. * `LONG` — 540 days of the lock-up period. * `gas`— additional parameters for gas management: * `maxFeePerGas`— maximum fee per gas (in Gwei). * `maxPriorityFeePerGas`— maximum priority fee to incentivize transaction. * `gasLimit`— maximum gas units to be consumed. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": "1024", "stakerAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", "unsignedTransactionData": "0xf86f808504a817c80082520894...", "extraData": { "stakingPeriod": "FLEXIBLE", "gas": { "maxFeePerGas": 10, "maxPriorityFeePerGas": 1, "gasLimit": 21000 } } } } ``` * `amount` — amount of tokens to stake in IP. * `stakerAddress` — account address initiating the staking transaction. * `unsignedTransactionData` — serialized unsigned transaction in the hexadecimal format (RLP-encoded). * `extraData` — additional transaction details: * `stakingPeriod` — staking period duration: `FLEXIBLE`, `SHORT`, `MEDIUM` or `LONG`. * `gas`— additional parameters for gas management: * `maxFeePerGas`— maximum fee per gas (in Gwei). * `maxPriorityFeePerGas`— maximum priority fee to incentivize transaction. * `gasLimit`— maximum gas units to be consumed. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction Use following the Story-specific signing logic. To broadcast the signed transaction to the Story network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "story", "network": "aeneid", "signedTransaction": "0xf86f82012a8504a817c80082520894...", "stakerAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c" }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — account address initiating the staking transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": {} } } ``` ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-withdraw-transaction). Example request (for`mainnet`network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "story", "network": "aeneid", "stakerAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", "extra": { "amount": "1024", "delegationId": 0, "gas": { "maxFeePerGas": 10 } } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staking account address initiated the staking transaction. * `extra` — additional parameters: * `amount`— amount of tokens to unstake in IP. * `delegationId`— identifier of the stake, required to perform a unstake. * `gas`— additional parameters for gas management: * `maxFeePerGas`— maximum fee per gas (in Gwei). Example response: ```json JSON theme={null} { "error": null, "result": { "stakerAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c", "unsignedTransactionData": "0xf8a9808504a817c800830186a094...", "extraData": {} } } ``` * `stakerAddress` — account address initiating the unstaking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 or hex-encoded format. Sign the transaction and submit it to the blockchain to perform the called action. * `extraData` — additional transaction details ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Story-specific signing logic. # Sui Source: https://docs.p2p.org/docs/unified-api-sui Unified API + Sui Integration Workflow In the following guide, the integration process for the `sui` chain is covered. The Sui integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Sui-specific details** > > * `chain` — always set to `sui` for Sui-related requests. > * `network` — environment in which the transaction is processed: `testnet` or `mainnet`. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in MIST (1 SUI = 10⁹ MIST). ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `testnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "sui", "network": "testnet", "stakerAddress": "0xe6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6", "amount": 1000000000 }' ``` * `chain` — blockchain network, always set to `sui` for Sui-related requests. * `network` — environment in which the transaction is processed: `mainnet` or `testnet`. * `stakerAddress` — `0x`-prefixed account address initiating the staking transaction. * `amount` — amount of tokens to stake in MIST (1 SUI = 10⁹ MIST). Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 1000000000, "stakerAddress": "5DHyW8yCpJEAzFm1jyk5qbNXicd3Dg1tyNAEcPVLjTBCQEgG", "unsignedTransactionData": "0x550104010208...", "extraData": { "targets": ["5G6Zhgm59oujA5UW8wMu4XHFP59uenjC2xp1zshyrWVa638J"], "rewardDestinationType": "account", "rewardDestination": "5DHyW8yCpJEAzFm1jyk5qbNXicd3Dg1tyNAEcPVLjTBCQEgG", "createdAt": "2024-12-19T11:51:03.477Z" } } } ``` * `amount` — amount of tokens to stake in MIST. * `stakerAddress` — account address initiating the staking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `extraData` — additional transaction details: * `targets` — addresses of the validators selected in the targets. * `rewardDestinationType` — rewards destination type: * `staked` — rewards will be sent to the stash account and added to the current bond (compounding rewards). * `stash` — rewards will be sent to the stash account as a transferrable balance (not compounding rewards). * `account` — rewards will be sent to any account specified as a transferrable balance. * `rewardDestination` — rewards destination account address. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the Sui-specific signing logic. To broadcast the signed transaction to the Sui network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "chain": "sui", "network": "testnet", "stakerAddress": "0xe6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6", "signedTransaction": "signature", "extra": { "unsignedTransaction": "0x000003000800ca9a3b00000000010100000000000000000000000000000000000000000000000000000000000000050100000000000000010020ab4fb3eeaa7b0ab4f91eedab33adf140c6750e60ca5e44b3df82491937d7bab4020200010100000000000000000000000000000000000000000000000000000000000000000000030a7375695f73797374656d11726571756573745f6164645f7374616b6500030101000200000102002c0def86e107ae6ca6a610b4188bb3c2802c30350ac01817be6a02d2a247faf5012a009f3cd4188b8363f5d6a9af5875a0ac663abd1c1bd706be6036d7c51d548d4400001800000000209f43be7aae4cb75d3995057ba075a5cfdc55c3fe6a6cfab5f034309807f5f6072c0def86e107ae6ca6a610b4188bb3c2802c30350ac01817be6a02d2a247faf5e803000000000000809698000000000000" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the staking transaction. * `signedTransaction` — signature produced for the `unsignedTransactionData`. * `extra` — additional parameters: * `unsignedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "transactionDigest": "9ugm8p16MZtDGuMz6uHq7cPJw9GY6mYaZqtyeyx1FJiD" } } } ``` * `extraData` — additional transaction details: * `transactionDigest` — transaction hash to check the transaction in Sui explorers. ## Unstaking flow ### 1. Create withdrawal request Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-unstake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "sui", "network": "testnet", "stakerAddress": "0xe6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6", "extra": { "stakeId": "0x5d920b8fca6a6043d898ab1a9a8ab167d8aa323fe2b9e76a27312f7f16e20a67" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — account address initiating the withdrawal transaction. * `extra`— additional parameters: * `stakeId`— identifier of the stake, required to perform a withdrawal. Example response: ```json JSON theme={null} { "error": null, "result": { "unsignedTransactionData": "0x000002010100000000000000000000000000000000000000000000000000000000000000050100000000000000010100421468e81f68bcce235e4d95e6bb318d7ed9a7f223edd4080f2c2c7fcc5ea6840f97531a0000000020300486c82d75f9d990e1238453677a9ef0f62104723a5bcbd7a9a300a07c7afc010000000000000000000000000000000000000000000000000000000000000000030a7375695f73797374656d16726571756573745f77697468647261775f7374616b650002010000010100e6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b601639ace0ef7601462aa3ee0babfccfdbd7972e30cb6b0990546b9678ff347b8fa9c955e1a00000000206fa50de99c02fd418f1df30f18f918f74d165eea343164ac39d98c2dbb1424f9e6c15e4ad58571dcad63aba77c5c03823074642512082ded0e8256ef73c406b6e803000000000000809698000000000000" } } ``` * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Sui-specific signing logic. # Tezos Source: https://docs.p2p.org/docs/unified-api-tezos Unified API + Tezos Integration Workflow In the following guide, the integration process for the `xtz` chain is covered. The Tezos integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key Tezos-specific details** > > * `chain` — always set to `xtz` for Tezos-related requests. > * `network` — environment in which the transaction is processed: `mainnet` only. > * `stakerAddress` — Tezos account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in XTZ. ## Staking flow ### 1. Create reveal request If you have not performed any operations on this account before, create a reveal request by sending a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `mainnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "xtz", "network": "mainnet", "stakerAddress": "tz1Nfu7TmHj7GWARYHrxdVZ75BgcHwUnr3PM", "amount": "5", "extra": { "operationType": "reveal", "additionalAddresses": { "tezosPubKey": "edpkvUh57bdTwgaHBE9bYVPLRv3myqzoD8RLsiRNnQs5TxvhdLswQ9" } } }' ``` * `chain` — blockchain network, always set to `xtz` for Tezos-related requests. * `network` — environment in which the transaction is processed: `mainnet` only. * `stakerAddress` — Tezos account address initiating the reveal transaction. * `amount` — amount of tokens to reveal in XTZ. * `extra` — additional parameters. * `operationType` — type of operation; set to `reveal` for new accounts. * `additionalAddresses`— additional network addresses: * `tezosPubKey` — staker public key. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 5, "stakerAddress": "tz1Nfu7TmHj7GWARYHrxdVZ75BgcHwUnr3PM", "unsignedTransactionData": "5d601c0133d2cba0c9345fb5...", "createdAt": "2025-06-03T23:36:22.450Z", "extraData": { "transactionId": "c23982ec-07aa-426b-a867-013cdacbd281", "stakeId": "7ba5b6c6-e0e3-481c-8388-57ea3d15cacc", "gasEstimate": { "amount": "0.000279000000000000", "gasLimit": "" } } } } ``` * `amount` — amount of tokens to reveal in XTZ. * `stakerAddress` — Tezos account address initiating the transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the reveal transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the reveal transaction. * `stakeId` — unique identifier of the staking request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated fee in XTZ for processing the transaction. * `gasLimit` — maximum gas limit for the transaction; option can be left empty or ignored, since it is not used in Tezos and reserved for compatibility only. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction. To broadcast the signed transaction to the Tezos network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "xtz", "network": "mainnet", "signedTransaction": "{\"bytes\":\"024c70799bc16c1c95db0091ef51441bd6b8d2bf105a4a17793c776d530f82a16e002142e1ae4c4456b6f3742dd6510ea6dc7d2c11f48c029bf5ad4fa8010000\",\"sig\":\"sigWhmkraxYHSmd1SQS156Y1MvuBBzZ9sK9qFjiGoRDufGpEL6kXRyjmDx4rbGcUzzNatCUWipLvs7cQATocmqDFdVxjJ4n8\",\"prefixSig\":\"edsigtgXEsuorpDdogCRha2vHVJeSg1GvXnjuXX1UScoQEFgE84GhFRM4ppTs7TD4hxBLp8MpQ2WBBYptMCCfTm7oQJhbqPj5AJ\",\"sbytes\":\"024c70799bc16c1c95db0091ef51441bd6b8d2bf105a4a17793c776d530f82a16e002142e1ae4c4456b6f3742dd6510ea6dc7d2c11f48c029bf5ad4fa8010000429d6cadd75dcbc026097e94d90e6145bf477e9bd8a1ffa2948b81509f522ff1f30148bf227c6d83b1c3d98e9cd8f8e71177152b6dca938fe82da73bfaac8603\"}", "stakerAddress": "tz1Nfu7TmHj7GWARYHrxdVZ75BgcHwUnr3PM", "extra": { "transactionId": "7977e904-e9bb-43d8-9c09-83812a15e8a8" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `signedTransaction` — signed transaction as a JSON string, including `bytes`, `sig`, `prefixSig`, and `sbytes` fields, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — Tezos account address initiating the transaction. * `extra` — additional request parameters: * `transactionId` — unique identifier of the reveal transaction. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "transactionHash": "oo3mw16oJqrBair2s31dvDhKjTXjKNcRPjJthKKN1qMnvjE7eCz" } } } ``` * `extraData` — additional transaction details: * `transactionHash` — transaction hash on the Tezos network, which can be tracked in [tzkt.io](tzkt.io) explorer. ### 3. Create staking request > Note that Tezos accounts can have only 1 delegation at a time. Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "xtz", "network": "mainnet", "stakerAddress": "tz1Nfu7TmHj7GWARYHrxdVZ75BgcHwUnr3PM", "amount": "5", "extra": { "additionalAddresses": { "tezosPubKey": "edpkvUh57bdTwgaHBE9bYVPLRv3myqzoD8RLsiRNnQs5TxvhdLswQ9" } } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — Tezos account address initiating the transaction. * `amount` — amount of tokens to delegate in XTZ. Minimum amount is 5 XTZ. * `extra` — additional parameters. * `additionalAddresses`— additional network addresses: * `tezosPubKey` — staker public key; required for non-revealed accounts. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 5, "stakerAddress": "tz1Nfu7TmHj7GWARYHrxdVZ75BgcHwUnr3PM", "unsignedTransactionData": "74aec234a40c4adfe6d68c5dbd104d04f0804e0e...", "createdAt": "2025-06-03T23:36:36.439Z", "extraData": { "transactionId": "0a471c05-0714-4249-a4a0-e83d4a648fc0", "stakeId": "d7ac3d47-d2ee-4704-8c5c-ea174ef7bc0b", "gasEstimate": { "amount": "0.000279000000000000", "gasLimit": "" } } } } ``` * `amount` — amount of tokens to stake in XTZ. * `stakerAddress` — Tezos account address initiating the staking transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the transaction within this staking session. * `stakeId` — unique identifier of the staking request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated fee in XTZ for processing the transaction. * `gasLimit` — maximum gas limit for the transaction; can be left empty or ignored, since it is not used in Tezos and reserved for compatibility only. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Tezos-specific signing logic. ## Unstaking flow ### 1. Create unstaking request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "xtz", "network": "mainnet", "stakerAddress": "tz1Nfu7TmHj7GWARYHrxdVZ75BgcHwUnr3PM", "extra": { "amount": 5 } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — Tezos account address initiating the transaction. * `extra`— additional parameters: * `amount` — amount of tokens to unstake in XTZ. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": 5, "stakerAddress": "tz1Nfu7TmHj7GWARYHrxdVZ75BgcHwUnr3PM", "unsignedTransactionData": "024c70799bc16c1c95db0091ef51441bd6b8d2bf105a4a17793c776d530f82a1...", "createdAt": "2025-06-05T12:09:40.751Z", "extraData": { "transactionId": "b2757302-8e89-4227-a841-461936ccd971", "stakeId": "a78b76b6-e866-4dd3-9a7d-3a89f5937ec7", "gasEstimate": { "amount": "0.000248000000000000", "gasLimit": "" } } } } ``` * `amount` — amount of XTZ to be unstaked. * `stakerAddress` — Tezos account address initiating the transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `extraData` — additional transaction details: * `transactionId` — unique identifier of the transaction within this unstaking session. * `stakeId` — unique identifier of the unstaking request. * `gasEstimate` — estimated gas usage details: * `amount` — estimated fee in XTZ for processing the transaction. * `gasLimit` — maximum gas limit for the transaction; can be left empty or ignored, since it is not used in Tezos and reserved for compatibility only. ### 2. Sign and send transaction > Note that the withdrawal is available only after the unstaking period of 4 days ends. Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the Tezos-specific signing logic. # TON Source: https://docs.p2p.org/docs/unified-api-ton Unified API + TON Integration Workflow In the following guide, the integration process for the `ton_whales` chain is covered. The TON integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key TON-specific details** > > * `chain` — always set to `ton_whales` for TON-related requests. > * `network` — environment in which the transaction is processed: `mainnet` or `testnet`. > * `stakerAddress` — account address initiating staking, unstaking or withdrawal transactions. > * `amount` — amount of tokens in nanoGRAMs (1 GRAM= 10⁹ nanoGRAMs). > * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet for staking operations. > * `publicKey` — public key of the nominator for the TON network. ## Staking flow ### 1. Create staking request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `mainnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "ton_whales", "network": "mainnet", "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE", "amount": "5000000000", "extra": { "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d", "walletVersion": "V3R1" } }' ``` * `chain` — blockchain network, always set to `ton_whales` for TON-related requests. * `network` — environment in which the transaction is processed: `mainnet` or `testnet`. * `stakerAddress` — staking account address receiving the staked tokens. * `amount` — amount of tokens to stake in nanoGRAMs (1 GRAM = 10⁹ nanoGRAMs). * `extra` — additional parameters: * `publicKey` — public key of the nominator for the TON network. * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": "5000000000", "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE", "unsignedTransactionData": "b5ee9c7241010201005c00011a29a9a3176761922b0000000f0301009462001b0eecbed3c3c21725606281a98dfb0152db86a09eb434df3d75fd862d8466e723b9aca00000000000000000000000000000da803efd00000193d519d3184773594005012a05f200a7846cb2", "extraData": { "seqno": 15, "walletVersion": "V3R1", "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d", "poolAddress": "kQA2Hdl9p4eELkrAxQNTG_YCpbcNQT1oab566_sMWwjNztst" } } } ``` * `amount` — amount of tokens to stake in nanoGRAMs (1 GRAM= 10⁹ nanoGRAMs). * `stakerAddress` — staking account address receiving the staked tokens. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `extraData` — additional transaction details: * `seqno` — [sequence number](https://docs.ton.org/v3/guidelines/smart-contracts/howto/wallet#replay-protection---seqno) of the message. * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. * `publicKey` — public key of the nominator for the TON network. * `poolAddress` — TON Whales pool address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction. To broadcast the signed transaction to the TON network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "ton_whales", "network": "mainnet", "signedTransaction": "710f0456d675c0715bcdcbce5ab4fc5ad8e00cccaa3bd40fe59329cfe33c7089901bffa9c412bcd502c9f751f15de93abb297599c0dadb4f247eaeea72a2a003", "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE", "extra": { "unsignedTransaction": "b5ee9c7241010201005a00011c29a9a317ffffffff00000000000301008d62001b0eecbed3c3c21725606281a98dfb0152db86a09eb434df3d75fd862d8466e7280d09dc3000000000000000000000000000007bcd1fef00000193e11e3d975012a05f2008b7558aef", "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d", "walletVersion": "V3R1" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. * `stakerAddress` — staking account address receiving the staked tokens. * `extra` — additional parameters: * `unsignedTransaction` — unsigned transaction in Base64 encrypted format. * `publicKey` — public key of the nominator for the TON network. * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. Example response: ```json JSON theme={null} { "error": null, "result": { "extraData": { "messageHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" } } } ``` * `messageHash`— hash of the transaction. ## Unstaking flow ### 1. Create withdrawal request Send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request (for `mainnet` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "ton_whales", "network": "mainnet", "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE", "extra": { "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d", "amount": "5000000000", "walletVersion": "V3R1" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — staking account address initiating the withdrawal transaction. * `extra` — additional request parameters: * `publicKey` — public key of the nominator for the TON network. * `amount` — amount of tokens to withdraw in nanoGRAMs (1 GRAM = 10⁹ nanoGRAMs). * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. Example response: ```json JSON theme={null} { "error": null, "result": { "amount": "5000000000", "stakerAddress": "0QDLFn0rX92mwLFL5bMAkamPxvjM_2k4SHDi4VEQG4Jk8rCE", "unsignedTransactionData": "b5ee9c7241010201005c00011a29a9a3176761922b0000000f0301009462001b0eecbed3c3c21725606281a98dfb0152db86a09eb434df3d75fd862d8466e723b9aca00000000000000000000000000000da803efd00000193d519d3184773594005012a05f200a7846cb2", "extraData": { "seqno": 15, "walletVersion": "V3R1", "publicKey": "dbc17009994431c741d22396f71ebb220951c2d2a643e0c17e63125d9acae32d", "poolAddress": "kQA2Hdl9p4eELkrAxQNTG_YCpbcNQT1oab566_sMWwjNztst" } } } ``` * `amount` — amount of tokens to withdraw in nanoGRAMs (1 GRAM = 10⁹ nanoGRAMs). * `stakerAddress` — account address initiating the withdrawal transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. Sign the transaction and submit it to the blockchain to perform the called action. * `extraData` — additional transaction details: * `seqno` — [sequence number](https://docs.ton.org/v3/guidelines/smart-contracts/howto/wallet#replay-protection---seqno) of the message. * `walletVersion` — [version of the smart contract](https://docs.ton.org/participate/wallets/contracts) used by the wallet in the TON blockchain. * `publicKey` — public key of the nominator for the TON network. * `poolAddress` — TON Whales pool address. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the TON-specific signing logic. # TRON Source: https://docs.p2p.org/docs/unified-api-tron Unified API + TRON Integration Workflow In the following guide, the integration process for the `tron` chain is covered. TRON integration aligns with the general [Unified API process](/docs/unified-api-getting-started) but with network-specific parameters. [Get an authentication token](/docs/authentication) to start using the Unified API. Request examples are provided using [cURL](https://curl.se/). > To check the integration guides for other chains, refer to the [Networks Supported](/docs/unified-api-networks) section. > [!NOTE] > > **Key TRON-specific details** > > * `chain` — always set to `tron` for TRON-related requests. > * `network` — environment in which the transaction is processed: `mainnet` or`testnet-nile`. > * `stakerAddress` — TRON account address initiating staking, voting or withdrawal transactions. > * `amount` — amount of tokens in SUN (1 TRX = 10⁶ SUN). Note that only TRX (SUN) can be staked, since USDT (TRC-20) is not natively stakeable. ## Staking flow > [!WARNING] > > **Important: `stake` Endpoint Dual Behavior** > > The `stake` endpoint performs either a freeze or a vote, selected by `extra.isDelegation`. Note that `amount` means **SUN** when freezing and number of **votes** when voting. ### 1. Create freezing request Send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `testnet-nile` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "tron", "network": "testnet-nile", "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 1000000, "extra": { "isDelegation": true, "resource": "BANDWIDTH" } }' ``` * `chain` — blockchain network, always set to `tron` for TRON-related requests. * `network` — environment in which the transaction is processed: `mainnet` or`testnet-nile`. * `stakerAddress` — TRON account address initiating the freeze transaction. * `amount` — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN). Note that only TRX (SUN) can be staked, since USDT (TRC-20) is not natively stakeable. * `extra` — additional parameters: * `isDelegation` — toggle between self-staking `false` and resource delegation `true`. * `false` — (Default) Self-staking. `amount` used for **vote** path. * `true` — Resource delegation. `amount` used for **freeze** path. * `resource` — type of resources to be used for processing the TRON transaction`BANDWIDTH` or `ENERGY`. Example response: ```json JSON theme={null} { "amount": 1000000, "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "unsignedTransactionData": { "visible": false, "txID": "5fa8e694866ba0ecfcbf4d4932552ad7f9a198fccc30b5d0b4a1564a986cec8a", "raw_data_hex": "0a02ed712208bed86bc0563959f54088abb9edfa325a57083612530a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121b0a1541da53d324a354aa5924c7117caff3ead97910a5e110c0843d70a8d6b5edfa32", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1", "frozen_balance": 1000000 }, "type_url": "type.googleapis.com/protocol.FreezeBalanceV2Contract" }, "type": "FreezeBalanceV2Contract" } ], "ref_block_bytes": "ed71", "ref_block_hash": "bed86bc0563959f5", "expiration": 1750965573000, "timestamp": 1750965513000 } }, "extraData": { "resource": "BANDWIDTH", "voteAccount": "TNo9M6V8AcyMhfU7KzNRvXpT4i9zM1zF82", "unsignedTransactionSerialized": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD..." }, "createdAt": "2025-06-26T19:18:33.983Z" } ``` * `amount` — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN). Note that only TRX (SUN) can be staked, since USDT (TRC-20) is not natively stakeable. * `stakerAddress` — TRON account address initiating the freeze transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `visible` — internal SDK parameter; always set to `false`. * `txID` — hash of the freeze transaction. * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format. * `raw_data` — full decoded transaction structure with all the fields and metadata: * `contract` — list of TRON contracts: * `parameter.value.owner_address `— TRON account address initiated the transaction in the hexadecimal format. * `parameter.value.frozen_balance` — amount of tokens to freeze in SUN (1 TRX = 10⁶ SUN). * `parameter.type_url` — TRON network operation type, e.g., `type.googleapis.com/protocol.FreezeBalanceV2Contract`. * `type` — TRON protocol contract type * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included. * `expiration` — timestamp of the transaction expiration in ms since last epoch. * `timestamp` — timestamp of the transaction in ms since last epoch. * `extraData` — additional transaction details: * `resource` — type of resources to be used for processing the TRON transaction`BANDWIDTH` or `ENERGY`. * `voteAccount` — address of the Super Representative to vote for. * `unsignedTransactionSerialized` — unsigned serialized transaction in Base64 encrypted format ready for signing. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign](/docs/unified-api-signing-transaction) the transaction using the TRON-specific signing logic. To broadcast the signed transaction to the TRON network, send a POST request to [/api/v1/unified/transaction/broadcast](/reference/unified-transaction-send). Example request (for `testnet-nile` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "tron", "network": "testnet-nile", "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "signedTransaction": "0x410284007427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e01f214ddb36378b5f5927b06028eccfe284d9cb736f8552e301cc09c2006998b098f84bf6386a201aa952fe298dd5f0c5fb6f03fc7b9f7efafd87b6ee321500b8e450340000600070010a5d4e8037427a7dee592c47c6875266357ee7afd763ddfdf6bd1634e410b7335fc38331e" }' ``` * `chain` — blockchain network, always set to `tron`. * `network` — environment in which the transaction is processed. * `stakerAddress` — TRON account address initiated the transaction. * `signedTransaction` — signed transaction in Base64 encrypted format, which contains all transaction details (e.g., accounts, instructions, and signatures) required to broadcast the transaction to the network. Example response: ```json JSON theme={null} { "error": null, "result": { "status": "PENDING", "extraData": { "transactionHash": "71e64f4fca71012b4ee5a40c90eed269875e4a796011e42f46358da68f758a34", "createdAt": "2025-06-26T19:25:13.712Z", "network": "testnet-nile", "senderAddress": "41da53d324a354aa5924c7117caff3ead97910a5e1", "block": null, "gas": { "bandwidthUsed": 0, "energyUsed": 0 } } } } ``` * `status` — transaction status: `pending`, `success` or `failed`. * `extraData` — additional transaction details: * `transactionHash` — hash of the transaction. * `createdAt` — timestamp of the transaction in the ISO 8601 format. * `network` — environment in which the transaction is processed. * `senderAddress` — TRON account address in the hexadecimal format. * `block` — block number in which the transaction has been included; `null` if the transaction has not been confirmed yet. * `gas` — gas usage details: * `bandwidthUsed` — number of bandwidth points consumed for processing the TRON transaction. * `energyUsed` — amount of energy in ms representing the time spent during an execution of a smart contract. ### 3. Create voting request To vote for a Super Representative after freezing TRX tokens, send a POST request to [/api/v1/unified/staking/stake](/reference/unified-create-stake-transaction). Example request (for `testnet-nile` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/stake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "tron", "network": "testnet-nile", "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "amount": 1, "extra": { "isDelegation": false } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — TRON account address initiating the voting transaction. * `amount` — number of votes. * `extra` — additional request parameters: * `isDelegation` — toggle between self-staking `false` and resource delegation `true`. * `false` — (Default) Self-staking. `amount` used for **vote** path. * `true` — Resource delegation. `amount` used for **freeze** path. Example response: ```json JSON theme={null} { "amount": 1000000, "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "unsignedTransactionData": { "visible": false, "txID": "c07e64f57ebb6ae191404b1c693aa46f80789aceacbfd8cc17a7c85c0c8c5559", "raw_data_hex": "0a02ee182208eb04b8cce7cc51534090f5d7edfa325a6a080412660a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e747261637412320a1541da53d324a354aa5924c7117caff3ead97910a5e112190a1541351b95e29c2514b7b8183cbc81a8e08c68e8833b100370b0a0d4edfa32", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1", "votes": [ { "vote_address": "41351b95e29c2514b7b8183cbc81a8e08c68e8833b", "vote_count": 1 } ] }, "type_url": "type.googleapis.com/protocol.VoteWitnessContract" }, "type": "VoteWitnessContract" } ], "ref_block_bytes": "ee18", "ref_block_hash": "eb04b8cce7cc5153", "expiration": 1750966074000, "timestamp": 1750966014000 } }, "extraData": { "voteAccount": "TNo9M6V8AcyMhfU7KzNRvXpT4i9zM1zF82", "voteCount": 1, "unsignedTransactionSerialized": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD..." }, "createdAt": "2025-06-26T19:26:54.816Z" } ``` * `amount` — amount of frozen tokens used for voting in SUN (1 TRX = 10⁶ SUN). * `stakerAddress` — TRON account address initiated the unfreeze transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `visible` — internal SDK parameter; always set to `false`. * `txID` — hash of the voting transaction. * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format. * `raw_data` — full decoded transaction structure with all the fields and metadata: * `contract` — list of TRON contracts: * `parameter.value.owner_address `— TRON account address in the hexadecimal format. * `parameter.value.votes.vote_address` — address of the Super Representative to vote for. * `parameter.value.votes.vote_count` — number of votes. * `parameter.type_url` — TRON network operation type, e.g., `type.googleapis.com/protocol.VoteWitnessContract`. * `type` — TRON protocol contract type * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included. * `expiration` — timestamp of the transaction expiration in ms since last epoch. * `timestamp` — timestamp of the transaction in ms since last epoch. * `extraData` — additional transaction details: * `amount` — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN). * `resource`— type of resources used for processing the freeze transaction:`BANDWIDTH` or `ENERGY`. * `voteAccount`— address of the Super Representative to vote for. * `unsignedTransactionSerialized`— unsigned serialized transaction in Base64 encrypted format ready for signing. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the TRON-specific signing logic. ## Unstaking flow ### 1. Create unfreezing request Send a POST request to [/api/v1/unified/staking/unstake](/reference/unified-create-unstake-transaction). Example request (for `testnet-nile` network): ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/unstake \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "tron", "network": "testnet-nile", "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "extra": { "amount": 1000000, "resource": "BANDWIDTH" } }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — TRON account address initiating the unfreeze transaction. * `extra` — additional parameters: * `amount` — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN). * `resource` — type of resources used for processing the freeze transaction:`BANDWIDTH` or `ENERGY`. Example response: ```json JSON theme={null} { "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "unsignedTransactionData": { "visible": false, "txID": "88ae21d037e6f6696dbf9643d9941a38a32997972b25c34177d853e070868f70", "raw_data_hex": "0a02ed712208bed86bc0563959f54088abb9edfa325a57083612530a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121b0a1541da53d324a354aa5924c7117caff3ead97910a5e110c0843d70a8d6b5edfa32", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1", "unfreeze_balance": 1000000, "resource": "BANDWIDTH" }, "type_url": "type.googleapis.com/protocol.UnfreezeBalanceV2Contract" }, "type": "UnfreezeBalanceV2Contract" } ], "ref_block_bytes": "ed71", "ref_block_hash": "bed86bc0563959f5", "expiration": 1750965513000, "timestamp": 1750965573000 } }, "extraData": { "amount": 1000000, "resource": "BANDWIDTH", "voteAccount": "TNo9M6V8AcyMhfU7KzNRvXpT4i9zM1zF82", "unsignedTransactionSerialized": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD..." }, "createdAt": "2025-06-26T19:26:54.816Z" } ``` * `stakerAddress` — TRON account address initiated the unfreeze transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `visible` — internal SDK parameter; always set to `false`. * `txID` — hash of the unfreeze transaction. * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format. * `raw_data` — full decoded transaction structure with all the fields and metadata: * `contract` — list of TRON contracts: * `parameter.type_url` — TRON network operation type, e.g., `type.googleapis.com/protocol.FreezeBalanceV2Contract`. * `parameter.value.owner_address `— TRON account address in the hexadecimal format. * `parameter.value.frozen_balance` — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN). * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included. * `expiration` — timestamp of the transaction expiration in ms since last epoch. * `timestamp` — timestamp of the transaction in ms since last epoch. * `extraData` — additional transaction details: * `amount` — amount of tokens to unfreeze in SUN (1 TRX = 10⁶ SUN). * `resource`— type of resources used for processing the freeze transaction:`BANDWIDTH` or `ENERGY`. * `voteAccount`— address of the Super Representative to vote for. * `unsignedTransactionSerialized`— unsigned serialized transaction in Base64 encrypted format ready for signing. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### 2. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the TRON-specific signing logic. ### 3. Create withdrawal request To initiate the token withdrawal, send a POST request to [/api/v1/unified/staking/withdraw](/reference/unified-create-withdraw-transaction). Example request: ```bash bash theme={null} curl --request POST \ --url https://api-test.p2p.org/api/v1/unified/staking/withdraw \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ' \ --data '{ "chain": "tron", "network": "testnet-nile", "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", }' ``` * `chain` — blockchain network. * `network` — environment in which the transaction is processed. * `stakerAddress` — TRON account address initiating the unfreeze transaction. Example response: ```json JSON theme={null} { "stakerAddress": "TVscj8F6wPZ92d1smGYjH9heZR1MaEcE9u", "unsignedTransactionData": { "visible": false, "txID": "c1516c840a85c0d0f027a2842970b1fa72f604e9d48977eded8b4a59e9596bd3", "raw_data_hex": "0a025e9c2208c8eb8a95e3fd058640bfb1aebfcd335a5a083812560a3b747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f746864726177457870697265556e667265657a65436f6e747261637412170a15414b167d9a29108763f3794cdb295a8c0b60b21b9370df899cbfcd33", "raw_data": { "contract": [ { "parameter": { "value": { "owner_address": "41da53d324a354aa5924c7117caff3ead97910a5e1" }, "type_url": "type.googleapis.com/protocol.WithdrawExpireUnfreezeContract" }, "type": "WithdrawExpireUnfreezeContract" } ], "ref_block_bytes": "5e9c", "ref_block_hash": "c8eb8a95e3fd0586", "expiration": 1773149067455, "timestamp": 1773148767455 } }, "extraData": { "unsignedTransactionSerialized": "eyJ2a..." }, "createdAt": "2026-03-10T13:19:27.087Z" } ``` * `stakerAddress` — TRON account address initiated the unfreeze transaction. * `unsignedTransactionData` — unsigned transaction in Base64 encrypted format. The object contains the list of data fields to be used to construct the staking transaction. * `visible` — internal SDK parameter; always set to `false`. * `txID` — hash of the unfreeze transaction. * `raw_data_hex` — raw payload of the unsigned transaction in the hexadecimal format. * `raw_data` — full decoded transaction structure with all the fields and metadata: * `contract` — list of TRON contracts: * `parameter.type_url` — TRON network operation type, e.g., `type.googleapis.com/protocol.WithdrawExpireUnfreezeContract`. * `parameter.value.owner_address `— TRON account address in the hexadecimal format. * `type` — TRON protocol contract type * `ref_block_bytes`, `ref_block_hash` — hash and references of the block in which the transaction has been included. * `expiration` — timestamp of the transaction expiration in ms since last epoch. * `timestamp` — timestamp of the transaction in ms since last epoch. * `extraData` — additional transaction details: * `unsignedTransactionSerialized` — unsigned serialized transaction in Base64 encrypted format ready for signing. * `createdAt` — timestamp of the transaction in the ISO 8601 format. ### 4. Sign and send transaction Use `unsignedTransactionData` to [sign and send](/docs/unified-api-signing-transaction) the transaction following the TRON-specific signing logic. # Direct and SSV staking v3.1 (Unlimited) Source: https://docs.p2p.org/docs/unlimited-unified-api ## P2P.org DVT Staking Architecture Overview ### Components and Roles * **P2pOrgUnlimitedEthDepositor:** This on-chain contract serves as the single entry-point for client ETH deposits into P2P.org’s staking system. It escrows all incoming ETH from users and holds it until P2P’s service performs the actual beacon chain deposit or issues a refund. In other words, it **temporarily holds user ETH** and then forwards it **only** to either the official Ethereum **Beacon Deposit Contract** (to create validators using the user’s withdrawal credentials) or back to the user if the service times out. This design ensures the user retains custody over withdrawal credentials (the deposit uses a client-provided withdrawal address) while P2P coordinates the validator setup off-chain. * **P2pSsvProxyFactory:** This is the main on-chain **orchestration contract** for P2P.org’s Distributed Validator Technology (SSV) staking. It acts as the **entry point for validator registration** and is responsible for deploying the necessary helper contracts per client. When a user initiates staking, the factory contract deploys a new **P2pSsvProxy** instance (a minimal proxy contract) for that user’s validators and also coordinates creation of a **FeeDistributor** contract for reward splitting. The factory batches and proxies the complex operations (beacon deposits and SSV cluster registration) so that users do **not** need to handle SSV tokens themselves. P2P.org’s contracts manage all required SSV token funding for validator registration while the user’s ETH stake remains under the user’s withdrawal credentials. * **FeeDistributor:** (Deployed via the factory) A per-client contract that handles **reward distribution** according to the configured splits. For example, a client’s FeeDistributor might be set to deliver 90% of rewards to the client, 6% to a referrer, and the remaining \~4% to P2P.org. The `P2pOrgUnlimitedEthDepositor` uses a **FeeDistributorFactory** to deploy this contract at a deterministic address when the user deposits ETH. The FeeDistributor’s address becomes part of the deposit’s identity and is used to tie the user’s deposit to their reward distribution scheme. * **P2pSsvProxy:** (Deployed via the factory) A lightweight proxy contract that becomes the **owner of the validator cluster** on the SSV Network. This contract receives SSV tokens from the factory and calls the SSV Network on-chain to register the new validators. Each user (or each deposit batch) gets its own proxy contract, which P2P’s infrastructure will manage as the cluster controller. The proxy holds the validator’s public key and encrypted key shares, and it interfaces with the SSV network contract to add the validator with the chosen operators. Importantly, by using this proxy, P2P can supply the needed SSV tokens on-chain and invoke SSV **`registerValidator`** calls, abstracting those steps away from the end-user. ### Staking Process Flow **Diagram 1: User Deposit & Proxy Setup Flow** ```mermaid theme={null} sequenceDiagram autonumber participant User participant P2pSsvProxyFactory participant P2pOrgUnlimitedEthDepositor participant FeeDistributorFactory participant FeeDistributor participant P2pSsvProxy User->>P2pSsvProxyFactory: addEth({ethAmount, withdrawalCreds, splits...}) activate P2pSsvProxyFactory P2pSsvProxyFactory->>P2pOrgUnlimitedEthDepositor: addEth(...) activate P2pOrgUnlimitedEthDepositor P2pOrgUnlimitedEthDepositor->>FeeDistributorFactory: createIfAbsent(config) FeeDistributorFactory->>FeeDistributor: deploy new FeeDistributor FeeDistributor-->>P2pOrgUnlimitedEthDepositor: FeeDistributor address P2pOrgUnlimitedEthDepositor-->>P2pSsvProxyFactory: depositId deactivate P2pOrgUnlimitedEthDepositor P2pSsvProxyFactory->>P2pSsvProxy: deploy Proxy for user P2pSsvProxyFactory-->>User: emit EthForSsvStakingDeposited (proxy + depositId) deactivate P2pSsvProxyFactory ``` ETH is transferred from User → `P2pOrgUnlimitedEthDepositor` and held in escrow. `FeeDistributor` and `P2pSsvProxy` are created and linked to the deposit. **Diagram 2: Operator-Driven Activation (Beacon + SSV Registration)** ```mermaid theme={null} sequenceDiagram autonumber participant Operator (P2P.org) participant P2pSsvProxyFactory participant P2pOrgUnlimitedEthDepositor participant DepositContract (Beacon Chain) participant P2pSsvProxy participant SSVToken participant SSVNetwork Operator->>P2pSsvProxyFactory: makeBeaconDepositsAndRegisterValidators(depositId, validatorData) activate P2pSsvProxyFactory P2pSsvProxyFactory->>P2pOrgUnlimitedEthDepositor: makeBeaconDeposit(depositId, validatorData) activate P2pOrgUnlimitedEthDepositor loop For each validator P2pOrgUnlimitedEthDepositor->>DepositContract: deposit(pubkey, withdrawalCreds, signature, root) with 32 ETH end P2pOrgUnlimitedEthDepositor-->>P2pSsvProxyFactory: Eth2DepositCompleted deactivate P2pOrgUnlimitedEthDepositor P2pSsvProxyFactory->>SSVToken: transfer(to: P2pSsvProxy, amount) P2pSsvProxyFactory->>P2pSsvProxy: registerValidators(pubkeys, shares, operatorIds) activate P2pSsvProxy P2pSsvProxy->>SSVNetwork: registerValidator(...) deactivate P2pSsvProxy P2pSsvProxyFactory-->>Operator: emit RegistrationCompleted deactivate P2pSsvProxyFactory ``` Validators are deposited to the Beacon chain using escrowed ETH. SSV tokens are transferred and used to register the validator on the SSV Network via the proxy. **1. User Deposit and Proxy Deployment:** The process begins with the **user initiating a stake** by calling `P2pSsvProxyFactory.addEth`. The user includes their 32 ETH \* n (or more) and specifies: * `_eth2WithdrawalCredentials`: the user’s withdrawal credentials (usually an `0x01` prefixed ETH1 address, meaning the user’s own address for withdrawals). * `_ethAmountPerValidatorInWei`: typically set to exactly 32 ETH (in wei) for each new validator. * `_clientConfig` and `_referrerConfig`: addresses and fee percentages for the reward split (e.g. 90% to client, 6% to referrer, 4% to P2P). * `_extraData`: any extra metadata (e.g. MEV relay info). When `addEth` is called, the factory internally forwards the call (and ETH) to `P2pOrgUnlimitedEthDepositor.addEth`. The **UnlimitedEthDepositor** contract then: * Verifies the deposit parameters (e.g. correct withdrawal credential format and 32 ETH per validator). * Computes a unique **`depositId`** for this request based on the withdrawal credentials, ETH per validator, and the derived FeeDistributor address. * If needed, deploys the FeeDistributor contract for the given client/referrer configuration (via the FeeDistributorFactory). * Records the deposit details on-chain (amount and a 1-day expiration timestamp) and emits the event `P2pOrgUnlimitedEthDepositor__ClientEthAdded` with the depositId and deposit info. Meanwhile, the `P2pSsvProxyFactory` completes the `addEth` call by deploying a new **P2pSsvProxy** contract instance for the deposit (using a create2 clone, so its address is pre-computable) and emitting its own event `P2pSsvProxyFactory__EthForSsvStakingDeposited`. At this point, the user’s **ETH is held** securely in the UnlimitedEthDepositor contract (tagged by depositId) and their **proxy+feeDistributor** have been set up on-chain, but the 32 ETH validator deposits have not yet been sent to the official beacon chain contract. > **Note:** After this step, the user’s part is done – the **client does not need to do anything else**. All subsequent actions are performed by P2P’s off-chain service using the data logged on-chain. **2. Off-Chain Data Generation:** Once the `addEth` transaction is emitted, P2P’s infrastructure picks up the events to identify the new deposit. Off-chain, P2P generates the necessary **validator keys and deposit data**: * P2P picks a set of SSV operators (from an allowed list) and uses its Distributed Validator (DVT/SSV) tools to split the new validator’s private key into encrypted shares for those operators. * P2P also constructs the official **ETH2 deposit data** for each validator: this includes the validator pubkey, a signature, and the deposit data root needed by the Ethereum deposit contract. * These pieces (pubkey, key shares, deposit signature/root) are prepared for each validator in the batch. For example, if the user deposited enough ETH for 3 validators, P2P will generate 3 sets of key data. * Throughout this, the user’s withdrawal address (provided in step 1) is embedded in the deposit data, meaning the user remains the withdrawer of the validators’ funds. P2P correlates the generated data with the on-chain `depositId` and the proxy address from the earlier events. The depositId ties together the user’s ETH and the FeeDistributor/proxy; P2P uses it to ensure the deposit parameters (ETH per validator, etc.) match the data it generated. **3. Beacon Deposit and Validator Registration:** P2P then initiates the on-chain activation of the validators by calling the factory’s administrative function `makeBeaconDepositsAndRegisterValidators` (accessible only to P2P’s operator account). This is a **single atomic transaction** that performs two main tasks: * **(a) Beacon chain deposits:** The factory calls `P2pOrgUnlimitedEthDepositor.makeBeaconDeposit` to transfer the staked ETH from the escrow contract into the official **Beacon Deposit Contract**. P2pOrgUnlimitedEthDepositor uses the depositId to look up the stored deposit record and then processes the batch: * It ensures the deposit is in the expected state (not already used or refunded) and that there is enough ETH for the number of validators (e.g. deposit contract will receive 32 ETH for each pubkey in the list). * It updates the stored record: deducting the amount for the validators being staked and marking any remainder. Typically, if the user provided exactly 32 ETH \* N, the record will drop to zero and be deleted (emitting a `Eth2DepositCompleted` event). If there were any excess ETH beyond whole validators (unlikely in normal use before partial staking is enabled), the contract would mark the deposit as partially used and keep the rest for future use or refund, emitting `Eth2DepositInProgress`. * The contract then loops through each validator in the batch and calls the official **DepositContract**’s `deposit()` function, passing in one validator’s pubkey, the user’s withdrawal credentials (as bytes), the signature, and deposit data root, with 32 ETH attached for each call. This effectively **creates the validators on the beacon chain**, consuming the 32 ETH per validator from the escrow. After completing the loop, an event `P2pOrgUnlimitedEthDepositor__Eth2Deposit` is emitted, recording the depositId and the count of validators deposited in this batch. * **(b) SSV validator registration:** Immediately after initiating the beacon deposits, the factory finalizes the SSV cluster setup on the user’s behalf. It transfers the required amount of **SSV tokens** (the network’s native token used to pay operator fees) from P2P’s token reserves to the user’s newly deployed `P2pSsvProxy` contract. Then, the factory invokes the proxy’s function (e.g. `bulkRegisterValidators`) to register the validator(s) with the SSV Network, providing the list of validator pubkeys, the chosen operator IDs, and the encrypted shares for each validator. The `P2pSsvProxy` as the cluster owner calls the SSV network contract to officially **register the validators** with the given operators and deposits the SSV tokens for initial operation. This step links the validator(s) to a distributed cluster controlled by the `P2pSsvProxy`. Once done, the factory emits `P2pSsvProxyFactory__RegistrationCompleted`, signaling that the end-to-end setup (deposit + SSV registration) is finished for that proxy. At the end of step 3, the user’s ETH has been converted into active validator stakes on the beacon chain, and those validators are running under P2P.org’s distributed validator setup (SSV) without the user having had to manage keys or SSV tokens. The user’s **withdrawal address** remains the recipient of any eventual withdrawals from those validators, while the **FeeDistributor** ensures that execution-layer rewards (and any configured fee cuts) are properly routed. For example, if using an **ElOnlyFeeDistributor**, the validator client is likely configured to send transaction fees/MEV to the FeeDistributor contract, which will then split those rewards per the client/referrer/P2P percentages configured. (In other configurations, the FeeDistributor could also be the withdrawal credential itself, or use an oracle to split consensus rewards – but regardless, it intermediates reward sharing off-chain.) **4. Timeout and Refund Safety:** The system has a built-in safety mechanism in case P2P fails to perform step 3 in a timely manner. When the user’s ETH was first added, an expiration (typically 1 day) was recorded for that deposit batch. If for any reason P2P does **not** complete the beacon deposit within that window, the user can call the **`refund`** function on `P2pOrgUnlimitedEthDepositor` to retrieve their ETH back on-chain. The refund can only be invoked by the original client (it checks that the caller matches the stored client address from the FeeDistributor) and only after the timeout has passed. Upon refund, the contract pays out the entire remaining deposit amount to the user’s address and emits a `P2pOrgUnlimitedEthDepositor__Refund` event. This ensures that users are not at risk of indefinite fund lock-up – either P2P uses the ETH to stake within the agreed time or the user can reclaim it. There’s also an admin “rejectService” option that P2P can invoke (e.g. if a deposit cannot be serviced), which immediately enables the client to refund. In practice, under normal operation P2P will perform the deposits well within the window, and a `Eth2DepositCompleted` event signifies the escrowed ETH has been successfully staked. ### Integration of UnlimitedEthDepositor and ProxyFactory The **interaction between`P2pOrgUnlimitedEthDepositor` and `P2pSsvProxyFactory` is central to the P2P.org staking flow**. Summarizing their integration: * The **ProxyFactory uses the UnlimitedEthDepositor as a backend service** for handling ETH. The factory never holds the user’s ETH itself; instead it passes it to `P2pOrgUnlimitedEthDepositor.addEth` and gets back a `depositId` reference. This depositId is then included in the factory’s own event to correlate with the new proxy. Essentially, the factory “outsources” the ETH escrow and beacon deposit logic to the UnlimitedDepositor contract. * The **UnlimitedEthDepositor contract, in turn, trusts calls only from the factory’s owner/operator**. The critical call to actually perform deposits (`makeBeaconDeposit`) is restricted to P2P’s control and expects the factory (or a designated operator) to supply the correct validator data. This separation of concerns means the UnlimitedDepositor doesn’t need to know about SSV or proxies – it only manages ETH deposits and refunds – while the ProxyFactory doesn’t handle raw ETH movements to the beacon chain (reducing its complexity and risk). * Data flow: after a user calls `addEth`, **both contracts emit events** that P2P’s off-chain system listens to. The `P2pOrgUnlimitedEthDepositor__ClientEthAdded` event includes the depositId, amount, and user metadata. The `P2pSsvProxyFactory__EthForSsvStakingDeposited` event includes the same depositId plus the new proxy address and fee distributor address. Using these, the off-chain system can link the user’s ETH deposit to the deployed proxy and proceed with key generation. * Finally, when P2P calls `makeBeaconDepositsAndRegisterValidators`, the factory **drives both contracts in one go**: it invokes the UnlimitedDepositor to move ETH into validators and then calls functions on the new P2pSsvProxy to register those validators. The successful completion results in events from both: `Eth2Deposit` from the depositor (showing how many validators were created) and `RegistrationCompleted` from the factory, tying to the proxy address. In summary, **`P2pOrgUnlimitedEthDepositor`and`P2pSsvProxyFactory` work in tandem**: the depositor contract guarantees the secure handling of the user’s ETH (with the ability to refund) and performs the low-level beacon deposits, while the factory orchestrates the overall workflow – from taking the user’s request to deploying the needed contracts and finally registering the validators with the SSV network. This architecture allows P2P.org to offer a one-stop staking service where the **user contributes only ETH and a withdrawal address** and P2P’s system takes care of validator creation, distributed key management, and operator registration behind the scenes. The result is a seamless staking process that leverages smart contracts for security and transparency (fund custody and on-chain actions) while relying on off-chain coordination for the heavy-lifting of key generation and SSV cluster setup. ## Smart contract deployments **P2pOrgUnlimitedEthDepositor (direct)** [Mainnet](https://etherscan.io/address/0x23BE839a14cEc3D6D716D904f09368Bbf9c750eb) `0x23BE839a14cEc3D6D716D904f09368Bbf9c750eb` [Hoodi](https://hoodi.etherscan.io/address/0x933AcC6f337489D78188CBef2141cD9D6466d07D) `0x933AcC6f337489D78188CBef2141cD9D6466d07D` [Github](https://github.com/p2p-org/eth-staking-fee-distributor-contracts/blob/v3.1-audited/contracts/p2pEth2Depositor/P2pOrgUnlimitedEthDepositor.sol) [Audit](https://github.com/mixbytes/audits_public/tree/master/P2P.org/Staking%20Fee%20Distributor%20Diff%20Audit%20\(v1\)) **P2pOrgUnlimitedEthDepositor (SSV)** [Mainnet](https://etherscan.io/address/0x7c58c03AABf3Cc131903592B40C192BB4F949f1F) `0x7c58c03AABf3Cc131903592B40C192BB4F949f1F` [Hoodi](https://hoodi.etherscan.io/address/0xd01bF2297a153cE00B64972ffB6e7B767Bf0b285) `0xd01bF2297a153cE00B64972ffB6e7B767Bf0b285` [Github](https://github.com/p2p-org/eth-staking-fee-distributor-contracts/blob/v3.1-audited/contracts/p2pEth2Depositor/P2pOrgUnlimitedEthDepositor.sol) [Audit](https://github.com/mixbytes/audits_public/tree/master/P2P.org/Staking%20Fee%20Distributor%20Diff%20Audit%20\(v1\)) **P2pSsvProxyFactory** [Mainnet](https://etherscan.io/address/0x5ed861aec31cCB496689FD2E0A1a3F8e8D7B8824) `0x5ed861aec31cCB496689FD2E0A1a3F8e8D7B8824` [Hoodi](https://hoodi.etherscan.io/address/0x1f72FC2585D283DfEcF748cc5d19c014158A7C6f) `0x2444fae9394deBF503775940AF2a3e9364A31e34` [Github](https://github.com/p2p-org/p2p-ssv-proxy/blob/v3.1-audited/src/p2pSsvProxyFactory/P2pSsvProxyFactory.sol) [Audit](https://github.com/mixbytes/audits_public/tree/master/P2P.org/SSV%20Integration%20Diff%20Audit%20\(v1\)) # Validator Source: https://docs.p2p.org/docs/validator Staking Data API provides methods to retrieve essential information about validators within the network. These endpoints offer insights into a validator's current stake, rewards received, Annual Percentage Yield (APY), and associated fees. ## Methods Unless stated otherwise, the `startAt`–`finishAt` range cannot exceed 31 days, and `finishNumber` cannot be lower than `startNumber`. ### Get Validator Summary **Endpoint:** [GET /api/v1/\{network}/data/validator/summary](/reference/data-validator-summary) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to obtain the general basic information about a validator for the period, such as the different types of rewards earned by the validator, the current stake and APY associated with the validator. ### Get Validator Stake **Endpoint:** [GET /api/v1/\{network}/data/validator/stakes](/reference/data-validator-stakes) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to monitor the current stake of a validator. Regularly check the stake data to assess the validator's commitment and participation in the network. `groupBy` selects the aggregation: `stakingPeriod` (default) aggregates by epoch, `day` aggregates by calendar day. `groupBy=day` cannot be combined with `startNumber` / `finishNumber`; use `startAt` / `finishAt` instead, otherwise the request returns `400`. `stake` is the total stake balance of the validator. On Ethereum it includes ETH that is still in the deposit or activation queue. With `groupBy=day` on Ethereum, the response additionally contains the optional fields `activeStake` (already active on the Beacon Chain) and `inactiveStake` (still waiting to be activated), which together make up `stake`. On other networks `groupBy=day` currently falls back to the staking-period grouping and these two fields are not returned. ### Get Validator Rewards **Endpoint:** [GET /api/v1/\{network}/data/validator/rewards](/reference/data-validator-rewards) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to track the different types of rewards earned by the validator. Monitor reward data to assess the validator's performance and profitability. ### Get Validator APY **Endpoint:** [GET /api/v1/\{network}/data/validator/apy](/reference/data-validator-apy) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to understand the APY associated with the validator. Regularly check APY data for insights into the validator's long-term performance. ### Get Validator Fee **Endpoint:** [GET /api/v1/\{network}/data/validator/fee](/reference/data-validator-fee) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to assess the fees charged by the validator. Monitor fee data to understand the financial implications of choosing a particular validator. ### Get Validator Name **Endpoint:** [GET /api/v1/\{network}/data/validator/name](/reference/data-validator-name) **Supported networks:** Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. Ethereum is not supported. **Description:** Utilize this endpoint to know the name of the validator. ### Get Validator State **Endpoint:** [GET /api/v1/\{network}/data/validator/state](/reference/data-validator-state) **Supported networks:** Ethereum, Solana, Polkadot, Kusama, Sui, TON, Cardano, Celestia. **Description:** Utilize this endpoint to know the state of the validator. To monitor the number of delegators, use the network-level [Get Delegators Count](/docs/network#get-delegators-count) endpoint; there is no per-validator delegators count. ### Get Validator Statuses **Endpoint:** [GET /api/v1/\{network}/data/validator/statuses](/reference/data-validator-statuses) **Supported networks:** Ethereum. **Description:** Utilize this method to obtain the number of validators created via Staking API in each status. This allows identifying any changes, such as transitions from waiting to active or instances of slashing, and staying informed that you are supporting a reliable and actively participating validator. ### Get Validator Statuses Detailed **Endpoint:** [GET /api/v1/\{network}/data/validator/statuses/detailed](/reference/data-validator-statuses-detailed) **Supported networks:** Ethereum. **Description:** Utilize this method to obtain the status of each individual validator created via Staking API, along with the total count. Each list item contains the validator public key (`validator`) and its `status`; use it when the per-status counts from [Get Validator Statuses](#get-validator-statuses) are not granular enough. # Validator Consolidation Source: https://docs.p2p.org/docs/validator-consolidation The Pectra upgrade introduces major improvements to the process of validator creation and management across both Ethereum and SSV staking APIs. These enhancements improve scalability, enable larger validator's effective balance (up to 2048 ETH), and streamline flows using type of withdrawal credentials. You can now consolidate your stakes and merge multiple existing validators into one to share a single withdrawal address. By this measure, the following benefits can be gained: * Easing the process of validator management * Reducing the number of active validators tied to the same withdrawal address * Migrating the withdrawal credentials from the `0x01` type to `0x02` which enables auto compounding and simplifies future staking operations * Preparing the infrastructure for advanced staking operations, such as [top-ups](/docs/incremental-staking-top-up) and [partial withdrawals](/docs/partial-withdrawals) To consolidate multiple validators: 1. Create the consolidation request. 2. Sign and broadcast the transaction. Request examples are provided using [cURL](https://curl.se/). > [!TIP] > > The flow is supported for both Ethereum and SSV validators via the same endpoint. ## 1. Create consolidation request Send a POST request to [/api/v1/eth/staking/direct/tx/consolidation-validators](/reference/eth-staking-consolidation-validators) to prepare a transaction for merging several source validators into a target one. Note that the maximum effective balance of the target validator is 2048 ETH. Example request: ```bash bash theme={null} curl --request POST \ --url https://api.p2p.org/api/v1/eth/staking/direct/tx/consolidation-validators \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer ' \ --data ' { "withdrawalAddress": "0x338EF19fA2eC0fc4d1277B1307a613fA1FBbc0cb", "sourcePubkeys": [ "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39", "0x4Ef81c0018aB0DCbBdC8915D26efAcEa7CDef61eE9aBdddcBdAD2f2F04c5b6E4fBA6F5afD1Ad46267c1DC8544E690fE4" ], "targetPubkey": "0xffC08FcD7cFeF5c70fB2b0e1f2A8EaA690AaE2bDFfa5dBEc4dEef31DcC0B19eB1f9Cebe3E2fe9eefBD9a1BDF6FD89b39" } ' ``` * `withdrawal address` — withdrawal address for the target validator. * `sourcePubkeys` — list of public keys belonging to the source validators. * `targetPubkey` — public key of the target validator. Example response: ```json JSON theme={null} { "error": null, "result": { "list": [ { "serializeTx": "0x02f87883088bb080840422bd...334caaf5e9c0", "gasLimit": "1000000", "data": "0xad9049587a26e8db61f6...1549f334caaf5e9", "value": "1", "chainId": 560048, "type": 2, "maxFeePerGas": "2211533588", "maxPriorityFeePerGas": "69385672" } ] } } ``` * `serializeTx` — serialized unsigned transaction. * `gasLimit` — maximum gas (A measure of computational effort required to execute a transaction or smart contract on a blockchain. Users must pay a gas fee, usually in the native token, to have their transactions processed by the network.) limit for this block. * `data` — transaction data. * `value` — amount this transaction is sending in Wei. * `chainId` — chain ID this transaction is authorized on, as specified by [EIP-155](https://eips.ethereum.org/EIPS/eip-155). * `type` — [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) type of this transaction envelope. * `maxFeePerGas` — maximum price per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee in Wei. * `maxPriorityFeePerGas` — price per unit of gas in Wei, which is added to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee. This added fee is used to incentivize miners to prioritize this transaction. ## 2. Sign and broadcast transaction Use `serializeTx` from the previous step to [sign and send](/docs/signing-transaction-eth) the signed transaction to the Ethereum network. By broadcasting this transaction, you are queuing the consolidation request. After the transaction is processed in the chain's queue, the source validator will be closed, and the resulting target validator will use the `0x02` type of withdrawal credentials. # Security Audits Source: https://docs.p2p.org/docs/widget-audits P2P.org security audits > [card] [Widget Demo](https://demo.widget.p2p.org) > [card] [Live Example](https://widget.p2p.org/) P2P.org Widget smart contracts and infrastructure undergo regular security audits by independent third-party firms. ## Smart Contract Audits * [Lending Proxy](https://github.com/mixbytes/audits_public/blob/master/P2P.org/Lending%20Proxy/README.md) * [Resolv integration](https://github.com/mixbytes/audits_public/blob/master/P2P.org/Resolv%20Integration/README.md) # Widget Overview Source: https://docs.p2p.org/docs/widget-overview Widget overview covering DeFi protocol aggregation, platform integration, and core widget functionality > [card] [Widget Demo](https://demo.widget.p2p.org) > [card] [Live Example](https://widget.p2p.org/) ## What is P2P.org Widget? P2P.org Widget is a **DeFi aggregation solution** designed to aggregate decentralized protocols into a unified interface for end users, with flexible integration options for platforms, wallets, and web applications. ### For End Users * **Complexity**: Finding reliable DeFi platforms is time-consuming and risky * **Fragmentation**: Managing positions across multiple platforms is difficult * **Trust**: Determining which protocols suit best for your purposes ### For Platforms & Wallets * **Development Costs**: Building DeFi functionality from scratch is expensive * **Time to Market**: Implementing multiple protocol integrations takes months * **Maintenance**: Keeping up with protocol updates and security requires ongoing effort ## Our Solution ```mermaid theme={null} graph LR A[User] --> B[Widget Interface] B --> C[Verified Protocols] C --> D[Morpho Lending] C --> E[Lido Staking] C --> F[Other Protocols] G[Your Platform/Wallet] --> H[iframe Integration] H --> B ``` ### For Your Users The widget provides a **single, simple interface** where users can: * Deposit supported tokens and stablecoins, including USDC, ETH, SOL, TON, and more, to access decentralized protocols * Access only **pre-vetted, reliable protocols** * Access to all options in one place * View consolidated profit/loss across all options ### For Your Platform The widget offers **plug-and-play DeFi functionality**: * **iframe integration** – embed in minutes, not months * **Immediate access** to multiple protocols and networks * **Fully configurable** – enable all features or limit to specific tokens/networks ## Supported Networks | Network | Type | Protocols Available | | - | - | - | | **Ethereum** | EVM L1 | Morpho, Lido Veda, Resolv, Lombard | | **Base** | EVM L2 | Morpho | | **TON** | L1 | P2P.org & TonWhales | | **Solana** | L1 | P2P Staking | > [!NOTE] > > [View the current live protocols](https://widget.p2p.org/) and their availability ## Core Features ### Multiple Protocol Options * **Lending**: Provide tokens to be liable for rewards (via protocols like Morpho) * **Staking**: Participate in network validation and be liable for rewards from the network * **Restaking**: Enhanced staking with additional rewards from the network or protocol (e.g., ETH via Lido) ### Smart Options Selection * Multiple options available per protocol * **Automatic highlighting** of highest-yield options * Real-time APY updates * Clear reward information ### Unified Overview * All options visible in one place * Consolidated profit/loss tracking * Reward claiming for protocol-specific tokens (e.g., Morpho tokens) * User transaction history ## How It Works ```mermaid theme={null} sequenceDiagram participant U as User participant W as Widget participant P as Protocol Smart Contract U->>W: Connects wallet W->>U: Shows available options & APYs U->>W: Selects option and amount W->>U: Shows transaction preview U->>P: Signs transaction P->>U: Position created W->>U: Updates portfolio view ``` 1. **User connects wallet** through your platform 2. **Widget displays available options** with current APYs 3. **User selects option** and confirms transaction 4. **Transaction executes** directly with protocol smart contracts 5. **Tracked** in unified interface *** > [!NOTE] > > [Contact our team](https://support.p2p.org) to discuss your specific integration needs and get access to a demo environment. # Platform Integration Examples Source: https://docs.p2p.org/docs/widget-platform-integration Platform-specific integration examples for embedding the P2P.org Widget via iOS, Android, React Native, and iframe > [card] [Widget Demo](https://demo.widget.p2p.org) > [card] [Live Example](https://widget.p2p.org/) This guide provides integration examples for embedding the P2P.org Widget across different platforms and technologies. Each platform requires specific implementation approaches while maintaining the core functionality. ## Swift (iOS) Integrate the widget into iOS applications using WKWebView with proper wallet injection. ### Implementation * Use `WKWebView` with unique client url * `injected` in `window` must be initialized with your wallet ### Code Example ```swift theme={null} // A simple widget scene that displays web content in a SwiftUI view public struct WidgetScene: View { @Environment(\.dismiss) private var dismiss private let url: URL private let title: String public init(url: URL, title: String) { self.url = url self.title = title } public var body: some View { VStack(spacing: 0) { WebView(url: url) .navigationBarTitle(title, displayMode: .inline) } .background(Colors.background) } } fileprivate struct WebView: UIViewRepresentable { let url: URL func makeUIView(context: Context) -> WKWebView { let webView = WKWebView() webView.navigationDelegate = context.coordinator webView.allowsBackForwardNavigationGestures = true return webView } func updateUIView(_ webView: WKWebView, context: Context) { let request = URLRequest(url: url) webView.load(request) } func makeCoordinator() -> Coordinator { Coordinator(self) } class Coordinator: NSObject, WKNavigationDelegate { var parent: WebView init(_ parent: WebView) { self.parent = parent } func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { // Here must be JS injection of your wallet // You can check example of implementation in opensource, like here // https://github.com/AlphaWallet/alpha-wallet-ios/blob/master/modules/AlphaWalletBrowser/AlphaWalletBrowser/WKWebViewConfiguration.swift } } } ``` ### View Model ```swift theme={null} /// A simple view model for widget scenes public struct WidgetViewModel { private let urlString: String private let widgetTitle: String public init(urlString: String, title: String) { self.urlString = urlString self.widgetTitle = title } /// The URL to load in the widget public var url: URL { guard let url = URL(string: urlString) else { // Fallback to a default URL if the provided string is invalid return URL(string: "https://url_of_widget_instance/")! } return url } /// The title to display in the navigation bar public var title: String { return widgetTitle } } ``` ## Kotlin (Android) Integrate the widget into Android applications using WebView with custom wallet injection. ### Implementation * Use `WebView` with unique client url * `injected` in `window` must be initialized with your wallet ### Activity Code ```kotlin theme={null} import android.os.Bundle import android.webkit.WebResourceRequest import android.webkit.WebView import android.webkit.WebViewClient import androidx.appcompat.app.AppCompatActivity import androidx.activity.viewModels class WebViewActivity : AppCompatActivity() { private lateinit var webView: WebView private val viewModel: WebViewViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_webview) webView = findViewById(R.id.webView) setupWebView() val url = viewModel.url webView.loadUrl(url.toString()) } private fun setupWebView() { webView.webViewClient = object : WebViewClient() { override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean { view?.loadUrl(request?.url.toString()) return false } override fun onPageFinished(view: WebView?, url: String?) { super.onPageFinished(view, url) val jsCode = // Injection of your wallet with actual wallet object webView.evaluateJavascript(jsCode) { result -> } } } // WebView settings webView.settings.apply { javaScriptEnabled = true loadWithOverviewMode = true useWideViewPort = true } } } ``` ### View Model ```kotlin theme={null} import android.net.Uri import androidx.lifecycle.ViewModel class WebViewViewModel : ViewModel() { private val urlString: String = "https://url_of_widget_instance/" // Your dynamic URL private val widgetTitle: String = "Widget Title" // The widget title val url: Uri get() = Uri.parse(urlString) val title: String get() = widgetTitle } ``` ### Layout XML ```xml theme={null} ``` ## React Native Integrate the widget into React Native applications using react-native-webview. ### Implementation * Use `WebView` with unique client url * `injected` in `window` must be initialized with your wallet ### Code Example ```tsx theme={null} import React, { useEffect, useRef } from "react"; import { View, Text, StyleSheet } from "react-native"; import { WebView } from "react-native-webview"; const WebViewScreen = () => { // Ref to interact with the WebView const webViewRef = useRef(null); const url = "https://url_of_widget_instance/"; // UseEffect to inject JS after the page has loaded const onLoadEnd = () => { const jsCode = ` // Injection of your wallet with actual wallet object `; // Inject JavaScript after page load if (webViewRef.current) { webViewRef.current.injectJavaScript(jsCode); } }; return ( ); }; const styles = StyleSheet.create({ webview: { flex: 1, }, }); export default WebViewScreen; ``` ## Web Integration (No Custom Wallet) For web applications where you don't need custom wallet integration, use a simple iframe approach. ### Implementation * Use `iframe` with unique client url * For wallet connection, RainbowKit is used internally ### Code Example ```html theme={null}