This repository contains scripts for interacting with the Pier Two Cardano staking API. These scripts provide a command-line interface for managing Cardano staking operations.
- Add Stake Accounts: Add known Cardano stake accounts to your Pier Two account
- List Stakes: View and manage your Cardano staking positions
- List Addresses: View payment and stake addresses for a specific index
- Register Stake Address: Craft transactions to register new stake addresses
- Deregister Stake Address: Craft transactions to deregister stake addresses
- Delegate Stake: Craft transactions to delegate stake to pools
- Register and Delegate: Perform both operations in a single transaction
- Withdraw Stake Rewards: Craft transactions to withdraw staking rewards
- Node.js (v18 or higher)
- pnpm package manager
- Valid Pier Two API key
- Cardano private key (for transaction signing)
- Clone the repository:
git clone https://github.com/Pier-Two/cardano-staking-api-scripts.git
cd cardano-staking-api-scripts- Install dependencies:
pnpm install- Set up environment variables:
# Create .env file manually with the following variables:copy the .env.example contents into a .env file in the project root with your configuration:
# Required
API_KEY=your_pier_two_api_key_here
CARDANO_MNEMONIC=abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
API_BASE_URL=https://gw-1.api.test.piertwo.ioTo create your .env file, copy the template above and replace the placeholder values with your actual configuration.
Add a known Cardano stake account to your Pier Two account:
pnpm add-stake-account --stake-address stake1ux... --reference "My Fund" --label "Balance Sheet Stake"Note: This script currently requires the full stake address. For automatic address derivation, use list-addresses first to get the stake address for your desired index.
View all your Cardano staking positions:
pnpm list-stakesView the payment and stake addresses for a specific address index:
pnpm list-addresses --address-index 0This is useful for:
- Verifying which addresses you're working with
- Checking derivation paths
- Getting usage examples for other commands
Perform both registration and delegation in a single transaction:
pnpm register-and-delegate --address-index 0Sign and submit automatically:
pnpm register-and-delegate --address-index 0 --sign-and-submitCraft a transaction to withdraw stake rewards:
pnpm withdraw-stake-rewards --address-index 0 --amount 1000000Sign and submit automatically:
pnpm withdraw-stake-rewards --address-index 0 --amount 1000000 --sign-and-submitWith confirmation waiting:
pnpm withdraw-stake-rewards --address-index 0 --amount 1000000 --sign-and-submit --wait-confirmationCraft a transaction to register a new stake address:
pnpm register-stake-address --address-index 0With custom pool:
pnpm register-stake-address --address-index 0Sign and submit automatically:
pnpm register-stake-address --address-index 0 --sign-and-submitWith confirmation waiting:
pnpm register-stake-address --address-index 0 --sign-and-submit --wait-confirmationCraft a transaction to deregister a stake address:
pnpm deregister-stake-address --address-index 0Sign and submit automatically:
pnpm deregister-stake-address --address-index 0 --sign-and-submitWith confirmation waiting:
pnpm deregister-stake-address --address-index 0 --sign-and-submit --wait-confirmationCraft a transaction to delegate stake to a pool:
pnpm delegate-stake --address-index 0Sign and submit automatically:
pnpm delegate-stake --address-index 0 --sign-and-submit