Introduction

Precompiled contracts are specialized smart contracts implemented directly in the execution layer of a blockchain. Unlike user-deployed smart contracts that execute EVM bytecode, precompiled contracts offer optimized native implementations for complex cryptographic and computational operations. This significantly improves efficiency and reduces gas costs. Precompiled contracts exist at fixed addresses within the execution client and each precompile has a predefined gas cost based on its computational complexity, ensuring predictable execution fees.

Story Protocol introduces two precompiled contracts:

  • p256Verify precompile to support signature verifications in the secp256r1 elliptic curve.
  • ipgraph precompile to enhance on-chain intellectual property management.

In addition, Story Protocol’s execution layer supports all standard EVM precompiled contracts, ensuring full compatibility with Ethereum-based tooling and applications.

Precompiled Contracts

AddressFunctionality
byte1ecrecover- ECDSA signature recovery
byte2sha256 - SHA-256 hash computation
byte3ripemd160 - RIPEMD-160 hash computation
byte4identity - Identity function
byte5modexp - Modular exponentiation
byte6bn256Add - BN256 elliptic curve addition
byte7bn256ScalarMul - BN256 elliptic curve scalar multiplication
byte8bn256Pairing - BN256 elliptic curve pairing check
byte9blake2f - Blake2 hash function
byte10kzgPointEvaluation - KZG polynomial commitment evaluation
byte0p256Verify - Secp256r1 signature verification
byte1ipgraph - Intellectual property management

p256Verify precompile

Refer to RIP-7212 for more information.

IPgraph precompile

The ipgraph precompile enables efficient querying and modification of IP relationships and royalty structures while minimizing gas costs.

This precompile provides multiple functions based on the function selector—the first 4 bytes of the input.

Function SelectorDescriptionGas computation formulaGas Cost
addParentIpAdds a parent IP recordintrinsicGas + (ipGraphWriteGas * parentCount)Larger than 1100
hasParentIpChecks if an IP is parent of another IPipGraphReadGas * averageParentIpCount40
getParentIpsRetrieves parent IPsipGraphReadGas * averageParentIpCount40
getParentIpsCountGets the number of parent IPsipGraphReadGas10
getAncestorIpsRetrieves ancestor IPsipGraphReadGas * averageAncestorIpCount * 2600
getAncestorIpsCountGets the number of ancestor IPsipGraphReadGas * averageParentIpCount * 280
hasAncestorIpChecks if an IP is ancestor of another IPipGraphReadGas * averageAncestorIpCount * 2600
setRoyaltySets royalty details of an IPipGraphWriteGas1000
getRoyaltyRetrieves royalty details of an IPvaries by royalty policyLAP:900, LRP:620, other:1000
getRoyaltyStackRetrieves royalty stack of an IPvaries by royalty policyLAP:50, LRP: 600, other:1000
hasParentIpExtChecks if an IP is parent of another IP through external callipGraphExternalReadGas * averageParentIpCount8400
getParentIpsExtRetrieves parent IPs through external callipGraphExternalReadGas * averageParentIpCount8400
getParentIpsCountExtGets the number of parent IPs through external callipGraphExternalReadGas2100
getAncestorIpsExtRetrieve ancestor IPs through external callipGraphExternalReadGas * averageAncestorIpCount * 2126000
getAncestorIpsCountExtGets the number of ancestor IPs through external callipGraphExternalReadGas * averageParentIpCount * 216800
hasAncestorIpExtChecks if an IP is ancestor of another IP through external callipGraphExternalReadGas * averageAncestorIpCount * 2126000
getRoyaltyExtRetrieves royalty details of an IP through external callvaries by royalty policyLAP:189000, LRP:130200, other:1000
getRoyaltyStackExtRetrieves royalty stack of an IP through external callvaries by royalty policyLAP:10500, LRP:126000, other:1000

Refer to the Royalty Module for detailed information on royalty policies.