Documentation ¶
Index ¶
- Constants
- Variables
- func GetEthAddress(privKey *crypto.PrivateKeySECP256K1R) common.Address
- func PublicKeyToEthAddress(pubKey crypto.PublicKey) common.Address
- type AvaxAPI
- func (service *AvaxAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JsonTxID) error
- func (service *AvaxAPI) ExportKey(r *http.Request, args *ExportKeyArgs, reply *ExportKeyReply) error
- func (service *AvaxAPI) ImportAVAX(_ *http.Request, args *ImportAVAXArgs, response *api.JsonTxID) error
- func (service *AvaxAPI) ImportKey(r *http.Request, args *ImportKeyArgs, reply *api.JsonAddress) error
- type Batch
- type Block
- type Database
- func (db Database) Ancient(kind string, number uint64) ([]byte, error)
- func (db Database) AncientSize(kind string) (uint64, error)
- func (db Database) Ancients() (uint64, error)
- func (db Database) AppendAncient(number uint64, hash, header, body, receipts, td []byte) error
- func (db Database) HasAncient(kind string, number uint64) (bool, error)
- func (db Database) NewBatch() ethdb.Batch
- func (db Database) NewIterator() ethdb.Iterator
- func (db Database) NewIteratorWithPrefix(prefix []byte) ethdb.Iterator
- func (db Database) NewIteratorWithStart(start []byte) ethdb.Iterator
- func (db Database) Sync() error
- func (db Database) TruncateAncients(items uint64) error
- type DebugAPI
- type EVMInput
- type EVMOutput
- type ExportAVAXArgs
- type ExportKeyArgs
- type ExportKeyReply
- type Factory
- type GetAcceptedFrontReply
- type ImportAVAXArgs
- type ImportKeyArgs
- type NetAPI
- type SnowmanAPI
- type StaticService
- type Tx
- type TxError
- type UnsignedAtomicTx
- type UnsignedExportTx
- func (tx *UnsignedExportTx) Accept(ctx *snow.Context, _ database.Batch) error
- func (tx *UnsignedExportTx) EVMStateTransfer(state *state.StateDB) error
- func (tx *UnsignedExportTx) InputUTXOs() ids.Set
- func (tx *UnsignedExportTx) SemanticVerify(vm *VM, stx *Tx) TxError
- func (tx *UnsignedExportTx) Verify(avmID ids.ID, ctx *snow.Context, feeAmount uint64, feeAssetID ids.ID) error
- type UnsignedImportTx
- func (tx *UnsignedImportTx) Accept(ctx *snow.Context, _ database.Batch) error
- func (tx *UnsignedImportTx) EVMStateTransfer(state *state.StateDB) error
- func (tx *UnsignedImportTx) InputUTXOs() ids.Set
- func (tx *UnsignedImportTx) SemanticVerify(vm *VM, stx *Tx) TxError
- func (tx *UnsignedImportTx) Verify(avmID ids.ID, ctx *snow.Context, feeAmount uint64, feeAssetID ids.ID) error
- type UnsignedTx
- type VM
- func (vm *VM) Bootstrapped() error
- func (vm *VM) Bootstrapping() error
- func (vm *VM) BuildBlock() (snowman.Block, error)
- func (vm *VM) Clock() *timer.Clock
- func (vm *VM) Codec() codec.Codec
- func (vm *VM) CreateHandlers() map[string]*commonEng.HTTPHandler
- func (vm *VM) CreateStaticHandlers() map[string]*commonEng.HTTPHandler
- func (vm *VM) FormatEthAddress(addr common.Address) (string, error)
- func (vm *VM) GetAcceptedNonce(address common.Address) (uint64, error)
- func (vm *VM) GetAtomicUTXOs(chainID ids.ID, addrs ids.ShortSet, startAddr ids.ShortID, startUTXOID ids.ID, ...) ([]*avax.UTXO, ids.ShortID, ids.ID, error)
- func (vm *VM) GetBlock(id ids.ID) (snowman.Block, error)
- func (vm *VM) GetSpendableCanonical(keys []*crypto.PrivateKeySECP256K1R, amount uint64) ([]EVMInput, [][]*crypto.PrivateKeySECP256K1R, error)
- func (vm *VM) Initialize(ctx *snow.Context, db database.Database, b []byte, ...) error
- func (vm *VM) LastAccepted() ids.ID
- func (vm *VM) Logger() logging.Logger
- func (vm *VM) ParseAddress(addrStr string) (ids.ID, ids.ShortID, error)
- func (vm *VM) ParseBlock(b []byte) (snowman.Block, error)
- func (vm *VM) ParseEthAddress(addrStr string) (common.Address, error)
- func (vm *VM) SetPreference(blkID ids.ID)
- func (vm *VM) Shutdown() error
- type Web3API
Constants ¶
const ( GenesisTestAddr = "0x751a0b96e1042bee789452ecb20253fba40dbe85" GenesisTestKey = "0xabd71b35d559563fea757f0f5edbde286fb8c043105b15abb7cd57189306d7d1" )
test constants
Variables ¶
var Codec codec.Codec
Codec does serialization and deserialization
var (
ID = ids.NewID([32]byte{'e', 'v', 'm'})
)
ID this VM should be referenced by
Functions ¶
func GetEthAddress ¶ added in v0.2.12
func GetEthAddress(privKey *crypto.PrivateKeySECP256K1R) common.Address
Types ¶
type AvaxAPI ¶ added in v0.2.15
type AvaxAPI struct {
// contains filtered or unexported fields
}
AvaxAPI offers Avalanche network related API methods
func (*AvaxAPI) ExportAVAX ¶ added in v0.2.15
func (service *AvaxAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JsonTxID) error
ExportAVAX exports AVAX from the P-Chain to the X-Chain It must be imported on the X-Chain to complete the transfer
func (*AvaxAPI) ExportKey ¶ added in v0.2.15
func (service *AvaxAPI) ExportKey(r *http.Request, args *ExportKeyArgs, reply *ExportKeyReply) error
ExportKey returns a private key from the provided user
func (*AvaxAPI) ImportAVAX ¶ added in v0.2.15
func (service *AvaxAPI) ImportAVAX(_ *http.Request, args *ImportAVAXArgs, response *api.JsonTxID) error
ImportAVAX issues a transaction to import AVAX from the X-chain. The AVAX must have already been exported from the X-Chain.
func (*AvaxAPI) ImportKey ¶ added in v0.2.15
func (service *AvaxAPI) ImportKey(r *http.Request, args *ImportKeyArgs, reply *api.JsonAddress) error
ImportKey adds a private key to the provided user
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block implements the snowman.Block interface
type Database ¶
Database implements ethdb.Database
func (Database) AncientSize ¶
AncientSize returns an error as we don't have a backing chain freezer.
func (Database) AppendAncient ¶
AppendAncient returns an error as we don't have a backing chain freezer.
func (Database) HasAncient ¶
HasAncient returns an error as we don't have a backing chain freezer.
func (Database) NewIterator ¶
NewIterator implements ethdb.Database
func (Database) NewIteratorWithPrefix ¶
NewIteratorWithPrefix implements ethdb.Database
func (Database) NewIteratorWithStart ¶
NewIteratorWithStart implements ethdb.Database
func (Database) TruncateAncients ¶
TruncateAncients returns an error as we don't have a backing chain freezer.
type DebugAPI ¶
type DebugAPI struct {
// contains filtered or unexported fields
}
DebugAPI introduces helper functions for debuging
func (*DebugAPI) GetGenesisBalance ¶
GetGenesisBalance returns the current funds in the genesis
func (*DebugAPI) IssueBlock ¶
IssueBlock to the chain
type EVMOutput ¶ added in v0.2.12
type ExportAVAXArgs ¶ added in v0.2.12
type ExportAVAXArgs struct { api.UserPass // Amount of AVAX to send Amount json.Uint64 `json:"amount"` // ID of the address that will receive the AVAX. This address includes the // chainID, which is used to determine what the destination chain is. To string `json:"to"` }
ExportAVAXArgs are the arguments to ExportAVAX
type ExportKeyArgs ¶ added in v0.2.12
ExportKeyArgs are arguments for ExportKey
type ExportKeyReply ¶ added in v0.2.12
type ExportKeyReply struct { // The decrypted PrivateKey for the Address provided in the arguments PrivateKey string `json:"privateKey"` }
ExportKeyReply is the response for ExportKey
type GetAcceptedFrontReply ¶
type GetAcceptedFrontReply struct { Hash common.Hash `json:"hash"` Number *big.Int `json:"number"` }
GetAcceptedFrontReply defines the reply that will be sent from the GetAcceptedFront API call
type ImportAVAXArgs ¶ added in v0.2.12
type ImportAVAXArgs struct { api.UserPass // Chain the funds are coming from SourceChain string `json:"sourceChain"` // The address that will receive the imported funds To string `json:"to"` }
ImportAVAXArgs are the arguments to ImportAVAX
type ImportKeyArgs ¶ added in v0.2.12
ImportKeyArgs are arguments for ImportKey
type NetAPI ¶
type NetAPI struct {
// contains filtered or unexported fields
}
NetAPI offers network related API methods
func (*NetAPI) Listening ¶
Listening returns an indication if the node is listening for network connections.
type SnowmanAPI ¶
type SnowmanAPI struct {
// contains filtered or unexported fields
}
SnowmanAPI introduces snowman specific functionality to the evm
func (*SnowmanAPI) GetAcceptedFront ¶
func (api *SnowmanAPI) GetAcceptedFront(ctx context.Context) (*GetAcceptedFrontReply, error)
GetAcceptedFront returns the last accepted block's hash and height
type StaticService ¶
type StaticService struct{}
StaticService defines the static API services exposed by the evm
func (*StaticService) BuildGenesis ¶
func (*StaticService) BuildGenesis(_ context.Context, args *core.Genesis) (formatting.CB58, error)
BuildGenesis returns the UTXOs such that at least one address in [args.Addresses] is referenced in the UTXO.
type Tx ¶ added in v0.2.12
type Tx struct { // The body of this transaction UnsignedTx `serialize:"true" json:"unsignedTx"` // The credentials of this transaction Creds []verify.Verifiable `serialize:"true" json:"credentials"` }
Tx is a signed transaction
type TxError ¶ added in v0.2.12
TxError provides the ability for errors to be distinguished as permenant or temporary
type UnsignedAtomicTx ¶ added in v0.2.12
type UnsignedAtomicTx interface { UnsignedTx // UTXOs this tx consumes InputUTXOs() ids.Set // Attempts to verify this transaction with the provided state. SemanticVerify(vm *VM, stx *Tx) TxError // Accept this transaction with the additionally provided state transitions. Accept(ctx *snow.Context, batch database.Batch) error EVMStateTransfer(state *state.StateDB) error }
UnsignedAtomicTx is an unsigned operation that can be atomically accepted
type UnsignedExportTx ¶ added in v0.2.12
type UnsignedExportTx struct { avax.Metadata // ID of the network on which this tx was issued NetworkID uint32 `serialize:"true" json:"networkID"` // ID of this blockchain. BlockchainID ids.ID `serialize:"true" json:"blockchainID"` // Which chain to send the funds to DestinationChain ids.ID `serialize:"true" json:"destinationChain"` // Inputs Ins []EVMInput `serialize:"true" json:"inputs"` // Outputs that are exported to the chain ExportedOutputs []*avax.TransferableOutput `serialize:"true" json:"exportedOutputs"` // contains filtered or unexported fields }
UnsignedExportTx is an unsigned ExportTx
func (*UnsignedExportTx) EVMStateTransfer ¶ added in v0.2.12
func (tx *UnsignedExportTx) EVMStateTransfer(state *state.StateDB) error
func (*UnsignedExportTx) InputUTXOs ¶ added in v0.2.12
func (tx *UnsignedExportTx) InputUTXOs() ids.Set
InputUTXOs returns an empty set
func (*UnsignedExportTx) SemanticVerify ¶ added in v0.2.12
func (tx *UnsignedExportTx) SemanticVerify( vm *VM, stx *Tx, ) TxError
SemanticVerify this transaction is valid.
type UnsignedImportTx ¶ added in v0.2.12
type UnsignedImportTx struct { avax.Metadata // ID of the network on which this tx was issued NetworkID uint32 `serialize:"true" json:"networkID"` // ID of this blockchain. BlockchainID ids.ID `serialize:"true" json:"blockchainID"` // Which chain to consume the funds from SourceChain ids.ID `serialize:"true" json:"sourceChain"` // Inputs that consume UTXOs produced on the chain ImportedInputs []*avax.TransferableInput `serialize:"true" json:"importedInputs"` // Outputs Outs []EVMOutput `serialize:"true" json:"outputs"` // contains filtered or unexported fields }
UnsignedImportTx is an unsigned ImportTx
func (*UnsignedImportTx) Accept ¶ added in v0.2.12
Accept this transaction and spend imported inputs We spend imported UTXOs here rather than in semanticVerify because we don't want to remove an imported UTXO in semanticVerify only to have the transaction not be Accepted. This would be inconsistent. Recall that imported UTXOs are not kept in a versionDB.
func (*UnsignedImportTx) EVMStateTransfer ¶ added in v0.2.12
func (tx *UnsignedImportTx) EVMStateTransfer(state *state.StateDB) error
func (*UnsignedImportTx) InputUTXOs ¶ added in v0.2.12
func (tx *UnsignedImportTx) InputUTXOs() ids.Set
InputUTXOs returns the UTXOIDs of the imported funds
func (*UnsignedImportTx) SemanticVerify ¶ added in v0.2.12
func (tx *UnsignedImportTx) SemanticVerify( vm *VM, stx *Tx, ) TxError
SemanticVerify this transaction is valid.
type UnsignedTx ¶ added in v0.2.12
type UnsignedTx interface { Initialize(unsignedBytes, signedBytes []byte) ID() ids.ID UnsignedBytes() []byte Bytes() []byte }
UnsignedTx is an unsigned transaction
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM implements the snowman.ChainVM interface
func (*VM) Bootstrapped ¶ added in v0.2.4
Bootstrapped notifies this VM that the consensus engine has finished bootstrapping
func (*VM) Bootstrapping ¶ added in v0.2.4
Bootstrapping notifies this VM that the consensus engine is performing bootstrapping
func (*VM) BuildBlock ¶
BuildBlock implements the snowman.ChainVM interface
func (*VM) CreateHandlers ¶
func (vm *VM) CreateHandlers() map[string]*commonEng.HTTPHandler
CreateHandlers makes new http handlers that can handle API calls
func (*VM) CreateStaticHandlers ¶
func (vm *VM) CreateStaticHandlers() map[string]*commonEng.HTTPHandler
CreateStaticHandlers makes new http handlers that can handle API calls
func (*VM) FormatEthAddress ¶ added in v0.2.12
func (*VM) GetAcceptedNonce ¶ added in v0.2.12
func (*VM) GetAtomicUTXOs ¶ added in v0.2.12
func (vm *VM) GetAtomicUTXOs( chainID ids.ID, addrs ids.ShortSet, startAddr ids.ShortID, startUTXOID ids.ID, limit int, ) ([]*avax.UTXO, ids.ShortID, ids.ID, error)
GetAtomicUTXOs returns the utxos that at least one of the provided addresses is referenced in.
func (*VM) GetSpendableCanonical ¶ added in v0.2.12
func (vm *VM) GetSpendableCanonical(keys []*crypto.PrivateKeySECP256K1R, amount uint64) ([]EVMInput, [][]*crypto.PrivateKeySECP256K1R, error)
func (*VM) Initialize ¶
func (vm *VM) Initialize( ctx *snow.Context, db database.Database, b []byte, toEngine chan<- commonEng.Message, fxs []*commonEng.Fx, ) error
Initialize implements the snowman.ChainVM interface
func (*VM) LastAccepted ¶
LastAccepted returns the ID of the block that was last accepted
func (*VM) ParseAddress ¶ added in v0.2.12
ParseAddress takes in an address and produces the ID of the chain it's for the ID of the address
func (*VM) ParseBlock ¶
ParseBlock implements the snowman.ChainVM interface
func (*VM) ParseEthAddress ¶ added in v0.2.12
func (*VM) SetPreference ¶
SetPreference sets what the current tail of the chain is
type Web3API ¶
type Web3API struct{}
Web3API offers helper API methods
func (*Web3API) ClientVersion ¶
ClientVersion returns the version of the vm running