Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { ChainUTXOs BuilderBackend SignerBackend AcceptTx(ctx stdcontext.Context, tx *txs.Tx) error }
Backend defines the full interface required to support a P-chain wallet.
func NewBackend ¶
type Builder ¶
type Builder interface { // GetBalance calculates the amount of each asset that this builder has // control over. GetBalance( options ...common.Option, ) (map[ids.ID]uint64, error) // GetImportableBalance calculates the amount of each asset that this // builder could import from the provided chain. // // - [chainID] specifies the chain the funds are from. GetImportableBalance( chainID ids.ID, options ...common.Option, ) (map[ids.ID]uint64, error) // NewBaseTx creates a new simple value transfer. Because the P-chain // doesn't intend for balance transfers to occur, this method is expensive // and abuses the creation of subnets. // // - [outputs] specifies all the recipients and amounts that should be sent // from this transaction. NewBaseTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.CreateSubnetTx, error) // NewAddValidatorTx creates a new validator of the primary network. // // - [vdr] specifies all the details of the validation period such as the // startTime, endTime, stake weight, and nodeID. // - [rewardsOwner] specifies the owner of all the rewards this validator // may accrue during its validation period. // - [shares] specifies the fraction (out of 1,000,000) that this validator // will take from delegation rewards. If 1,000,000 is provided, 100% of // the delegation reward will be sent to the validator's [rewardsOwner]. NewAddValidatorTx( vdr *validator.Validator, rewardsOwner *secp256k1fx.OutputOwners, shares uint32, options ...common.Option, ) (*txs.AddValidatorTx, error) // NewAddSubnetValidatorTx creates a new validator of a subnet. // // - [vdr] specifies all the details of the validation period such as the // startTime, endTime, sampling weight, nodeID, and subnetID. NewAddSubnetValidatorTx( vdr *validator.SubnetValidator, options ...common.Option, ) (*txs.AddSubnetValidatorTx, error) // NewRemoveSubnetValidatorTx removes [nodeID] from the validator // set [subnetID]. NewRemoveSubnetValidatorTx( nodeID ids.NodeID, subnetID ids.ID, options ...common.Option, ) (*txs.RemoveSubnetValidatorTx, error) // NewAddDelegatorTx creates a new delegator to a validator on the primary // network. // // - [vdr] specifies all the details of the delegation period such as the // startTime, endTime, stake weight, and validator's nodeID. // - [rewardsOwner] specifies the owner of all the rewards this delegator // may accrue at the end of its delegation period. NewAddDelegatorTx( vdr *validator.Validator, rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.AddDelegatorTx, error) // NewCreateChainTx creates a new chain in the named subnet. // // - [subnetID] specifies the subnet to launch the chain in. // - [genesis] specifies the initial state of the new chain. // - [vmID] specifies the vm that the new chain will run. // - [fxIDs] specifies all the feature extensions that the vm should be // running with. // - [chainName] specifies a human readable name for the chain. NewCreateChainTx( subnetID ids.ID, genesis []byte, vmID ids.ID, fxIDs []ids.ID, chainName string, options ...common.Option, ) (*txs.CreateChainTx, error) // NewCreateSubnetTx creates a new subnet with the specified owner. // // - [owner] specifies who has the ability to create new chains and add new // validators to the subnet. NewCreateSubnetTx( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.CreateSubnetTx, error) // NewImportTx creates an import transaction that attempts to consume all // the available UTXOs and import the funds to [to]. // // - [chainID] specifies the chain to be importing funds from. // - [to] specifies where to send the imported funds to. NewImportTx( chainID ids.ID, to *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.ImportTx, error) // NewExportTx creates an export transaction that attempts to send all the // provided [outputs] to the requested [chainID]. // // - [chainID] specifies the chain to be exporting the funds to. // - [outputs] specifies the outputs to send to the [chainID]. NewExportTx( chainID ids.ID, outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.ExportTx, error) // NewTransformSubnetTx creates a transform subnet transaction that attempts // to convert the provided [subnetID] from a permissioned subnet to a // permissionless subnet. This transaction will convert // [maxSupply] - [initialSupply] of [assetID] to staking rewards. // // - [subnetID] specifies the subnet to transform. // - [assetID] specifies the asset to use to reward stakers on the subnet. // - [initialSupply] is the amount of [assetID] that will be in circulation // after this transaction is accepted. // - [maxSupply] is the maximum total amount of [assetID] that should ever // exist. // - [minConsumptionRate] is the rate that a staker will receive rewards // if they stake with a duration of 0. // - [maxConsumptionRate] is the maximum rate that staking rewards should be // consumed from the reward pool per year. // - [minValidatorStake] is the minimum amount of funds required to become a // validator. // - [maxValidatorStake] is the maximum amount of funds a single validator // can be allocated, including delegated funds. // - [minStakeDuration] is the minimum number of seconds a staker can stake // for. // - [maxStakeDuration] is the maximum number of seconds a staker can stake // for. // - [minValidatorStake] is the minimum amount of funds required to become a // delegator. // - [maxValidatorWeightFactor] is the factor which calculates the maximum // amount of delegation a validator can receive. A value of 1 effectively // disables delegation. // - [uptimeRequirement] is the minimum percentage a validator must be // online and responsive to receive a reward. NewTransformSubnetTx( subnetID ids.ID, assetID ids.ID, initialSupply uint64, maxSupply uint64, minConsumptionRate uint64, maxConsumptionRate uint64, minValidatorStake uint64, maxValidatorStake uint64, minStakeDuration time.Duration, maxStakeDuration time.Duration, minDelegationFee uint32, minDelegatorStake uint64, maxValidatorWeightFactor byte, uptimeRequirement uint32, options ...common.Option, ) (*txs.TransformSubnetTx, error) // NewAddPermissionlessValidatorTx creates a new validator of the specified // subnet. // // - [vdr] specifies all the details of the validation period such as the // subnetID, startTime, endTime, stake weight, and nodeID. // - [assetID] specifies the asset to stake. // - [validationRewardsOwner] specifies the owner of all the rewards this // validator earns for its validation period. // - [delegationRewardsOwner] specifies the owner of all the rewards this // validator earns for delegations during its validation period. // - [shares] specifies the fraction (out of 1,000,000) that this validator // will take from delegation rewards. If 1,000,000 is provided, 100% of // the delegation reward will be sent to the validator's [rewardsOwner]. NewAddPermissionlessValidatorTx( vdr *validator.SubnetValidator, assetID ids.ID, validationRewardsOwner *secp256k1fx.OutputOwners, delegationRewardsOwner *secp256k1fx.OutputOwners, shares uint32, options ...common.Option, ) (*txs.AddPermissionlessValidatorTx, error) // NewAddPermissionlessDelegatorTx creates a new delegator of the specified // subnet on the specified nodeID. // // - [vdr] specifies all the details of the delegation period such as the // subnetID, startTime, endTime, stake weight, and nodeID. // - [assetID] specifies the asset to stake. // - [rewardsOwner] specifies the owner of all the rewards this delegator // earns during its delegation period. NewAddPermissionlessDelegatorTx( vdr *validator.SubnetValidator, assetID ids.ID, rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.AddPermissionlessDelegatorTx, error) }
Builder provides a convenient interface for building unsigned P-chain transactions.
func NewBuilder ¶
func NewBuilder(addrs ids.ShortSet, backend BuilderBackend) Builder
NewBuilder returns a new transaction builder.
- [addrs] is the set of addresses that the builder assumes can be used when signing the transactions in the future.
- [backend] provides the required access to the chain's context and state to build out the transactions.
func NewBuilderWithOptions ¶
NewBuilderWithOptions returns a new transaction builder that will use the given options by default.
- [builder] is the builder that will be called to perform the underlying opterations.
- [options] will be provided to the builder in addition to the options provided in the method calls.
type BuilderBackend ¶
type BuilderBackend interface { Context UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) GetTx(ctx stdcontext.Context, txID ids.ID) (*txs.Tx, error) }
BuilderBackend specifies the required information needed to build unsigned P-chain transactions.
type ChainUTXOs ¶
type ChainUTXOs interface { AddUTXO(ctx stdcontext.Context, destinationChainID ids.ID, utxo *avax.UTXO) error RemoveUTXO(ctx stdcontext.Context, sourceChainID, utxoID ids.ID) error UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) GetUTXO(ctx stdcontext.Context, sourceChainID, utxoID ids.ID) (*avax.UTXO, error) }
type Context ¶
type Context interface { NetworkID() uint32 AVAXAssetID() ids.ID BaseTxFee() uint64 CreateSubnetTxFee() uint64 TransformSubnetTxFee() uint64 CreateBlockchainTxFee() uint64 AddPrimaryNetworkValidatorFee() uint64 AddPrimaryNetworkDelegatorFee() uint64 AddSubnetValidatorFee() uint64 AddSubnetDelegatorFee() uint64 }
func NewContext ¶
func NewContext( networkID uint32, avaxAssetID ids.ID, baseTxFee uint64, createSubnetTxFee uint64, transformSubnetTxFee uint64, createBlockchainTxFee uint64, addPrimaryNetworkValidatorFee uint64, addPrimaryNetworkDelegatorFee uint64, addSubnetValidatorFee uint64, addSubnetDelegatorFee uint64, ) Context
func NewContextFromClients ¶
func NewContextFromURI ¶
func NewContextFromURI(ctx stdcontext.Context, uri string) (Context, error)
type Signer ¶
type Signer interface { SignUnsigned(ctx stdcontext.Context, tx txs.UnsignedTx) (*txs.Tx, error) Sign(ctx stdcontext.Context, tx *txs.Tx) error }
func NewSigner ¶
func NewSigner(kc *secp256k1fx.Keychain, backend SignerBackend) Signer
type SignerBackend ¶
type Wallet ¶
type Wallet interface { Context // Builder returns the builder that will be used to create the transactions. Builder() Builder // Signer returns the signer that will be used to sign the transactions. Signer() Signer // IssueBaseTx creates, signs, and issues a new simple value transfer. // Because the P-chain doesn't intend for balance transfers to occur, this // method is expensive and abuses the creation of subnets. // // - [outputs] specifies all the recipients and amounts that should be sent // from this transaction. IssueBaseTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (ids.ID, error) // IssueAddValidatorTx creates, signs, and issues a new validator of the // primary network. // // - [vdr] specifies all the details of the validation period such as the // startTime, endTime, stake weight, and nodeID. // - [rewardsOwner] specifies the owner of all the rewards this validator // may accrue during its validation period. // - [shares] specifies the fraction (out of 1,000,000) that this validator // will take from delegation rewards. If 1,000,000 is provided, 100% of // the delegation reward will be sent to the validator's [rewardsOwner]. IssueAddValidatorTx( vdr *validator.Validator, rewardsOwner *secp256k1fx.OutputOwners, shares uint32, options ...common.Option, ) (ids.ID, error) // IssueAddSubnetValidatorTx creates, signs, and issues a new validator of a // subnet. // // - [vdr] specifies all the details of the validation period such as the // startTime, endTime, sampling weight, nodeID, and subnetID. IssueAddSubnetValidatorTx( vdr *validator.SubnetValidator, options ...common.Option, ) (ids.ID, error) // IssueAddSubnetValidatorTx creates, signs, and issues a transaction that // removes a validator of a subnet. // // - [nodeID] is the validator being removed from [subnetID]. IssueRemoveSubnetValidatorTx( nodeID ids.NodeID, subnetID ids.ID, options ...common.Option, ) (ids.ID, error) // IssueAddDelegatorTx creates, signs, and issues a new delegator to a // validator on the primary network. // // - [vdr] specifies all the details of the delegation period such as the // startTime, endTime, stake weight, and validator's nodeID. // - [rewardsOwner] specifies the owner of all the rewards this delegator // may accrue at the end of its delegation period. IssueAddDelegatorTx( vdr *validator.Validator, rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (ids.ID, error) // IssueCreateChainTx creates, signs, and issues a new chain in the named // subnet. // // - [subnetID] specifies the subnet to launch the chain in. // - [genesis] specifies the initial state of the new chain. // - [vmID] specifies the vm that the new chain will run. // - [fxIDs] specifies all the feature extensions that the vm should be // running with. // - [chainName] specifies a human readable name for the chain. IssueCreateChainTx( subnetID ids.ID, genesis []byte, vmID ids.ID, fxIDs []ids.ID, chainName string, options ...common.Option, ) (ids.ID, error) // IssueCreateSubnetTx creates, signs, and issues a new subnet with the // specified owner. // // - [owner] specifies who has the ability to create new chains and add new // validators to the subnet. IssueCreateSubnetTx( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (ids.ID, error) // IssueImportTx creates, signs, and issues an import transaction that // attempts to consume all the available UTXOs and import the funds to [to]. // // - [chainID] specifies the chain to be importing funds from. // - [to] specifies where to send the imported funds to. IssueImportTx( chainID ids.ID, to *secp256k1fx.OutputOwners, options ...common.Option, ) (ids.ID, error) // IssueExportTx creates, signs, and issues an export transaction that // attempts to send all the provided [outputs] to the requested [chainID]. // // - [chainID] specifies the chain to be exporting the funds to. // - [outputs] specifies the outputs to send to the [chainID]. IssueExportTx( chainID ids.ID, outputs []*avax.TransferableOutput, options ...common.Option, ) (ids.ID, error) // IssueTransformSubnetTx creates a transform subnet transaction that attempts // to convert the provided [subnetID] from a permissioned subnet to a // permissionless subnet. This transaction will convert // [maxSupply] - [initialSupply] of [assetID] to staking rewards. // // - [subnetID] specifies the subnet to transform. // - [assetID] specifies the asset to use to reward stakers on the subnet. // - [initialSupply] is the amount of [assetID] that will be in circulation // after this transaction is accepted. // - [maxSupply] is the maximum total amount of [assetID] that should ever // exist. // - [minConsumptionRate] is the rate that a staker will receive rewards // if they stake with a duration of 0. // - [maxConsumptionRate] is the maximum rate that staking rewards should be // consumed from the reward pool per year. // - [minValidatorStake] is the minimum amount of funds required to become a // validator. // - [maxValidatorStake] is the maximum amount of funds a single validator // can be allocated, including delegated funds. // - [minStakeDuration] is the minimum number of seconds a staker can stake // for. // - [maxStakeDuration] is the maximum number of seconds a staker can stake // for. // - [minValidatorStake] is the minimum amount of funds required to become a // delegator. // - [maxValidatorWeightFactor] is the factor which calculates the maximum // amount of delegation a validator can receive. A value of 1 effectively // disables delegation. // - [uptimeRequirement] is the minimum percentage a validator must be // online and responsive to receive a reward. IssueTransformSubnetTx( subnetID ids.ID, assetID ids.ID, initialSupply uint64, maxSupply uint64, minConsumptionRate uint64, maxConsumptionRate uint64, minValidatorStake uint64, maxValidatorStake uint64, minStakeDuration time.Duration, maxStakeDuration time.Duration, minDelegationFee uint32, minDelegatorStake uint64, maxValidatorWeightFactor byte, uptimeRequirement uint32, options ...common.Option, ) (ids.ID, error) // IssueAddPermissionlessValidatorTx creates, signs, and issues a new // validator of the specified subnet. // // - [vdr] specifies all the details of the validation period such as the // subnetID, startTime, endTime, stake weight, and nodeID. // - [assetID] specifies the asset to stake. // - [validationRewardsOwner] specifies the owner of all the rewards this // validator earns for its validation period. // - [delegationRewardsOwner] specifies the owner of all the rewards this // validator earns for delegations during its validation period. // - [shares] specifies the fraction (out of 1,000,000) that this validator // will take from delegation rewards. If 1,000,000 is provided, 100% of // the delegation reward will be sent to the validator's [rewardsOwner]. IssueAddPermissionlessValidatorTx( vdr *validator.SubnetValidator, assetID ids.ID, validationRewardsOwner *secp256k1fx.OutputOwners, delegationRewardsOwner *secp256k1fx.OutputOwners, shares uint32, options ...common.Option, ) (ids.ID, error) // IssueAddPermissionlessDelegatorTx creates, signs, and issues a new // delegator of the specified subnet on the specified nodeID. // // - [vdr] specifies all the details of the delegation period such as the // subnetID, startTime, endTime, stake weight, and nodeID. // - [assetID] specifies the asset to stake. // - [rewardsOwner] specifies the owner of all the rewards this delegator // earns during its delegation period. IssueAddPermissionlessDelegatorTx( vdr *validator.SubnetValidator, assetID ids.ID, rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (ids.ID, error) // IssueUnsignedTx signs and issues the unsigned tx. IssueUnsignedTx( utx txs.UnsignedTx, options ...common.Option, ) (ids.ID, error) // IssueTx issues the signed tx. IssueTx( tx *txs.Tx, options ...common.Option, ) (ids.ID, error) }
Click to show internal directories.
Click to hide internal directories.