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.
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:
await client.solana.stake({
feePayer: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw',
fromPublicKey: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw',
amount: '1002282880',
});Currently, the following networks are supported:
client.solana— Solana.
More networks will be added in future versions.
Parameters
baseUrl string, required
|
token string, required |
network string, required |
timeoutMs number |
retry object If the client encounters one of HTTP response codes listed in If If these parameters are not provided, the client will never retry failed requests and will fail immediately. |
logger object If the object is not provided, Staking SDK will not log any messages. |
What's next?
- Staking SDK for Solana
- Staking API reference
Updated 8 days ago