Cardano-specific Features
This guide covers blockchain-specific features in Tx3 for the Cardano blockchain.
Protocol Parameters
Section titled “Protocol Parameters”// Access protocol parameterspparams.min_fee_coefficientpparams.min_fee_constantpparams.coins_per_utxo_byte
Native Scripts
Section titled “Native Scripts”// Define native scriptpolicy TimeLock = import("validators/vesting.ak");
// Use native scripttx lock(until: Int) { input source { from: TimeLock, min_amount: Ada(amount), }}
Certificates
Section titled “Certificates”cardano { certificates: [ StakeRegistration { ... }, StakeDelegation { ... }, StakeDeregistration { ... }, ]}
Withdrawals
Section titled “Withdrawals”cardano { withdrawals: [ (StakeCredential, Int), // (stake credential, amount) ]}
Collateral
Section titled “Collateral”cardano { collateral: input { from: User, min_amount: Ada(collateral_amount), }}
Common Patterns
Section titled “Common Patterns”Stake Registration
Section titled “Stake Registration”tx register_stake( stake_credential: StakeCredential) { input source { from: User, min_amount: Ada(registration_fee), }
cardano { certificates: [ StakeRegistration { credential: stake_credential, } ] }}
Stake Delegation
Section titled “Stake Delegation”tx delegate_stake( stake_credential: StakeCredential, pool_id: PoolId) { input source { from: User, min_amount: Ada(delegation_fee), }
cardano { certificates: [ StakeDelegation { credential: stake_credential, pool_id: pool_id, } ] }}
Reward Withdrawal
Section titled “Reward Withdrawal”tx withdraw_rewards( stake_credential: StakeCredential, amount: Int) { input source { from: User, min_amount: Ada(withdrawal_fee), }
cardano { withdrawals: [ (stake_credential, amount) ] }}
Common Use Cases
Section titled “Common Use Cases”Stake Pool Registration
Section titled “Stake Pool Registration”tx register_pool( pool_params: PoolParams) { input source { from: Operator, min_amount: Ada(registration_fee), }
cardano { certificates: [ PoolRegistration { params: pool_params, } ] }}
Stake Pool Retirement
Section titled “Stake Pool Retirement”tx retire_pool( pool_id: PoolId, epoch: Int) { input source { from: Operator, min_amount: Ada(retirement_fee), }
cardano { certificates: [ PoolRetirement { pool_id: pool_id, epoch: epoch, } ] }}
Multi-Certificate Transaction
Section titled “Multi-Certificate Transaction”tx multi_cert( stake_cred: StakeCredential, pool_id: PoolId) { input source { from: User, min_amount: Ada(total_fee), }
cardano { certificates: [ StakeRegistration { credential: stake_cred, }, StakeDelegation { credential: stake_cred, pool_id: pool_id, } ] }}
Network-Specific Features
Section titled “Network-Specific Features”Testnet Support
Section titled “Testnet Support”// Network selectionnetwork = "testnet"
// Testnet-specific parameterspparams.testnet = true
Mainnet Support
Section titled “Mainnet Support”// Network selectionnetwork = "mainnet"
// Mainnet-specific parameterspparams.mainnet = true