Sign and Broadcast Transaction
To sign and broadcast a transaction to the Story network, follow these steps:
1. Prepare unsigned transactions.
All staking-related API calls return an unsignedTransaction in raw Ethereum transaction format (Base64 encoded RLP). This transaction must be signed by the caller using their private key.
2. Sign the transaction
Use any Ethereum-compatible signing method or library to sign the transaction. Below is an example using ethers.js:
import { Wallet } from 'ethers';
import { arrayify } from 'ethers/lib/utils';
// Your private key (use secure storage in production)
const PRIVATE_KEY = process.env.PRIVATE_KEY!;
// Unsigned transaction in base64 format
const unsignedTxBase64 = process.env.UNSIGNED_TX!;
const wallet = new Wallet(PRIVATE_KEY);
const unsignedTx = Buffer.from(unsignedTxBase64, 'base64');
(async () => {
const signedTx = await wallet.signTransaction(arrayify(unsignedTx));
console.log(Buffer.from(signedTx, 'hex').toString('base64'));
})();
3. Broadcast the signed transaction
Send the signed transaction to the Story network by making a POST request to
/api/v1/story/[network]/tx/send.
-
Example request (for
aeneid
network):curl --request POST \ --url https://api-test.p2p.org/api/v1/story/aeneid/tx/send \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "signedTransaction": "<base64_signed_tx>" }'
signedTransaction
— signed transaction in Base64 encrypted format.
Example response:
{ "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.
What's Next?
- Getting Started.
- Withdrawal.
- Staking API reference.
Updated about 23 hours ago