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 but with network-specific parameters.
Get an authentication token to start using the Unified API.
Request examples are provided using cURL.
To check the integration guides for other chains, refer to the Networks Supported section.
Key Story-specific details
chain— always set tostoryfor Story-related requests.network— environment in which the transaction is processed:mainnetoraeneid(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.
Example request (for aeneid network):
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/staking/stake \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
"chain": "story",
"network": "aeneid",
"stakerAddress": "0x3202B5B0602274197CcB22B8c02CEC9539990c7c",
"amount": 1024,
"extra": {
"stakingPeriod": "FLEXIBLE",
"gas": {
"maxFeePerGas": 10,
"maxPriorityFeePerGas": 1,
"gasLimit": 21000
}
}
}'-
chain— blockchain network, always set tostoryfor Story-related requests. -
network— environment in which the transaction is processed:mainnetoraeneid(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:
{
"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,MEDIUMorLONG.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 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.
Example request:
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/transaction/broadcast \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--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:
{
"error": null,
"result": {
"extraData": {}
}
}Unstaking flow
1. Create unstaking request
Send a POST request to /api/v1/unified/staking/unstake.
Example request (formainnetnetwork):
curl --request POST \
--url https://api-test.p2p.org/api/v1/unified/staking/unstake \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--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:
{
"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 the transaction following the Story-specific signing logic.
What's next?
Updated 8 days ago