Documentation ¶
Index ¶
Constants ¶
View Source
const ( SECP256K1FxIndex = 0 NFTFxIndex = 1 PropertyFxIndex = 2 )
Variables ¶
View Source
var Parser txs.Parser
Parser to support serialization and deserialization
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 an X-chain wallet.
func NewBackend ¶
func NewBackend(ctx Context, chainID ids.ID, utxos ChainUTXOs) Backend
type Builder ¶
type Builder interface { // GetFTBalance calculates the amount of each fungible asset that this // builder has control over. GetFTBalance( options ...common.Option, ) (map[ids.ID]uint64, error) // GetImportableBalance calculates the amount of each fungible 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. // // - [outputs] specifies all the recipients and amounts that should be sent // from this transaction. NewBaseTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.BaseTx, error) // NewCreateAssetTx creates a new asset. // // - [name] specifies a human readable name for this asset. // - [symbol] specifies a human readable abbreviation for this asset. // - [denomination] specifies how many times the asset can be split. For // example, a denomination of [4] would mean that the smallest unit of the // asset would be 0.001 units. // - [initialState] specifies the supported feature extensions for this // asset as well as the initial outputs for the asset. NewCreateAssetTx( name string, symbol string, denomination byte, initialState map[uint32][]verify.State, options ...common.Option, ) (*txs.CreateAssetTx, error) // NewOperationTx performs state changes on the UTXO set. These state // changes may be more complex than simple value transfers. // // - [operations] specifies the state changes to perform. NewOperationTx( operations []*txs.Operation, options ...common.Option, ) (*txs.OperationTx, error) // NewOperationTxMintFT performs a set of state changes that mint new tokens // for the requested assets. // // - [outputs] maps the assetID to the output that should be created for the // asset. NewOperationTxMintFT( outputs map[ids.ID]*secp256k1fx.TransferOutput, options ...common.Option, ) (*txs.OperationTx, error) // NewOperationTxMintNFT performs a state change that mints new NFTs for the // requested asset. // // - [assetID] specifies the asset to mint the NFTs under. // - [payload] specifies the payload to provide each new NFT. // - [owners] specifies the new owners of each NFT. NewOperationTxMintNFT( assetID ids.ID, payload []byte, owners []*secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.OperationTx, error) // NewOperationTxMintProperty performs a state change that mints a new // property for the requested asset. // // - [assetID] specifies the asset to mint the property under. // - [owner] specifies the new owner of the property. NewOperationTxMintProperty( assetID ids.ID, owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.OperationTx, error) // NewOperationTxBurnProperty performs state changes that burns all the // properties of the requested asset. // // - [assetID] specifies the asset to burn the property of. NewOperationTxBurnProperty( assetID ids.ID, options ...common.Option, ) (*txs.OperationTx, 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) }
Builder provides a convenient interface for building unsigned X-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) }
BuilderBackend specifies the required information needed to build unsigned X-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 BlockchainID() ids.ID AVAXAssetID() ids.ID BaseTxFee() uint64 CreateAssetTxFee() uint64 }
func NewContext ¶
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. // // - [outputs] specifies all the recipients and amounts that should be sent // from this transaction. IssueBaseTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (ids.ID, error) // IssueCreateAssetTx creates, signs, and issues a new asset. // // - [name] specifies a human readable name for this asset. // - [symbol] specifies a human readable abbreviation for this asset. // - [denomination] specifies how many times the asset can be split. For // example, a denomination of [4] would mean that the smallest unit of the // asset would be 0.001 units. // - [initialState] specifies the supported feature extensions for this // asset as well as the initial outputs for the asset. IssueCreateAssetTx( name string, symbol string, denomination byte, initialState map[uint32][]verify.State, options ...common.Option, ) (ids.ID, error) // IssueOperationTx creates, signs, and issues state changes on the UTXO // set. These state changes may be more complex than simple value transfers. // // - [operations] specifies the state changes to perform. IssueOperationTx( operations []*txs.Operation, options ...common.Option, ) (ids.ID, error) // IssueOperationTxMintFT creates, signs, and issues a set of state changes // that mint new tokens for the requested assets. // // - [outputs] maps the assetID to the output that should be created for the // asset. IssueOperationTxMintFT( outputs map[ids.ID]*secp256k1fx.TransferOutput, options ...common.Option, ) (ids.ID, error) // IssueOperationTxMintNFT creates, signs, and issues a state change that // mints new NFTs for the requested asset. // // - [assetID] specifies the asset to mint the NFTs under. // - [payload] specifies the payload to provide each new NFT. // - [owners] specifies the new owners of each NFT. IssueOperationTxMintNFT( assetID ids.ID, payload []byte, owners []*secp256k1fx.OutputOwners, options ...common.Option, ) (ids.ID, error) // IssueOperationTxMintProperty creates, signs, and issues a state change // that mints a new property for the requested asset. // // - [assetID] specifies the asset to mint the property under. // - [owner] specifies the new owner of the property. IssueOperationTxMintProperty( assetID ids.ID, owner *secp256k1fx.OutputOwners, options ...common.Option, ) (ids.ID, error) // IssueOperationTxBurnProperty creates, signs, and issues state changes // that burns all the properties of the requested asset. // // - [assetID] specifies the asset to burn the property of. IssueOperationTxBurnProperty( assetID ids.ID, 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) // 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) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.