ergo
packagemoduleThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
README¶
ergo-lib-go
Go wrapper around C bindings for ErgoLib fromsigma-rust
Install
go get -u github.com/sigmaspace-io/ergo-lib-go
Supported Platforms
This library makes heavy use of cgo. A set of precompiled shared library objects are provided. For the time being the following platforms are supported and tested against:
Platform | Architecture | Triple | Supported | Tested |
---|---|---|---|---|
Linux | amd64 | x86_64-unknown-linux-gnu | ✅ | ✅ |
aarch64 | aarch64-unknown-linux-gnu | ✅ | ⏳ | |
Darwin | amd64 | x86_64-apple-darwin | ✅ | ✅ |
aarch64 | aarch64-apple-darwin | ✅ | ✅ | |
Windows | amd64 | x86_64-pc-windows-gnu | ✅ | ✅ |
Supported sigma-rust versions
sigma-rust Version | ergo-lib-go Version |
---|---|
v0.26.0 | v0.26.0 |
v0.28.0 | v0.28.0 |
Library
The libraries underlib
were compiled fromsigma-rust
with the following commands:
cargo build -p ergo-lib-c --release --target x86_64-apple-darwincargo build -p ergo-lib-c --release --target aarch64-apple-darwincross build -p ergo-lib-c --release --target x86_64-unknown-linux-gnucross build -p ergo-lib-c --release --target aarch64-unknown-linux-gnucross build -p ergo-lib-c --release --target x86_64-pc-windows-gnu
rustup run nightly-2024-01-26 cbindgen --config cbindgen.toml --crate ergo-lib-c --output h/ergo_lib.h
Credits
Documentation¶
Index¶
- Constants
- func MnemonicToSeed(mnemonicPhrase string, mnemonicPassword string) []byte
- func UnitsPerErgo() int64
- func VerifySignature(address Address, message []byte, signature SignedMessage) (bool, error)
- type Address
- type BatchMerkleProof
- type BlockHeader
- type BlockHeaders
- type BlockId
- type BlockIds
- type Box
- type BoxAssetsData
- type BoxAssetsDataList
- type BoxCandidate
- type BoxCandidateBuilder
- type BoxCandidates
- type BoxId
- type BoxSelection
- type BoxValue
- type Boxes
- type ByteArray
- type ByteArrays
- type CommitmentHint
- type Constant
- func NewConstant(s string) (Constant, error)
- func NewConstantFromBox(box Box) Constant
- func NewConstantFromBytes(b []byte) (Constant, error)
- func NewConstantFromECPointBytes(b []byte) (Constant, error)
- func NewConstantFromInt16(i int16) Constant
- func NewConstantFromInt32(i int32) Constant
- func NewConstantFromInt64(i int64) Constant
- type ContextExtension
- type Contract
- type DataInput
- type DataInputs
- type DerivationPath
- type ExtendedPublicKey
- type ExtendedSecretKey
- type HintsBag
- type Input
- type Inputs
- type MerkleProof
- type MnemonicGenerator
- type NipopowProof
- type NipopowVerifier
- type Parameters
- type PoPowHeader
- type PreHeader
- type Propositions
- type ProverResult
- type ReducedTransaction
- type SecretKey
- type SecretKeys
- type SignedMessage
- type SimpleBoxSelector
- type StateContext
- type Token
- type TokenAmount
- type TokenId
- type Tokens
- type Transaction
- type TransactionHintsBag
- type Tree
- type TxBuilder
- type TxId
- type UnsignedInput
- type UnsignedInputs
- type UnsignedTransaction
- type Wallet
Constants¶
const (// MainnetPrefix is the network prefix used in mainnet address encodingMainnetPrefix networkPrefix = 0// TestnetPrefix is the network prefix used in testnet address encodingTestnetPrefix = 16)
const (// P2PkPrefix 0x01 - Pay-to-PublicKey(P2PK) addressP2PkPrefix addressTypePrefix = 1// Pay2ShPrefix 0x02 - Pay-to-Script-Hash(P2SH)Pay2ShPrefix addressTypePrefix = 2// Pay2SPrefix 0x03 - Pay-to-Script(P2S)Pay2SPrefix addressTypePrefix = 3)
const (// R4 id for the non-mandatory R4 registerR4 nonMandatoryRegisterId = 4// R5 id for the non-mandatory R5 registerR5 nonMandatoryRegisterId = 5// R6 id for the non-mandatory R6 registerR6 nonMandatoryRegisterId = 6// R7 id for the non-mandatory R7 registerR7 nonMandatoryRegisterId = 7// R8 id for the non-mandatory R8 registerR8 nonMandatoryRegisterId = 8// R9 id for the non-mandatory R9 registerR9 nonMandatoryRegisterId = 9)
const (// Left represents left side the node is on in the merkle treeLeft nodeSide = 0// Right represents right side the node is on in the merkle treeRight nodeSide = 1)
Variables¶
This section is empty.
Functions¶
funcMnemonicToSeed¶added inv0.28.0
MnemonicToSeed converts a mnemonic phrase into a mnemonic seedmnemonicPassword is optional and is used to salt the seed
funcUnitsPerErgo¶
func UnitsPerErgo()int64
UnitsPerErgo returns number of units inside one ERGO (i.e. one ERG using nano ERG representation)
funcVerifySignature¶
func VerifySignature(addressAddress, message []byte, signatureSignedMessage) (bool,error)
VerifySignature verifies that the signature is presented to satisfy SigmaProp conditions
Types¶
typeAddress¶
type Address interface {// Base58 converts an Address to a base58 string using the provided networkPrefix.Base58(prefix networkPrefix)string// TypePrefix returns the addressTypePrefix for the Address.// 0x01 - Pay-to-PublicKey(P2PK) address.// 0x02 - Pay-to-Script-Hash(P2SH).// 0x03 - Pay-to-Script(P2S).TypePrefix() addressTypePrefix// Tree returns the Address as TreeTree()Tree// contains filtered or unexported methods}
funcNewAddress¶
NewAddress creates an Address from a base58 string.
funcNewAddressFromPublicKey¶added inv0.28.0
NewAddressFromPublicKey creates a new Address from public key bytes
funcNewAddressFromTree¶added inv0.28.0
NewAddressFromTree creates a new Address from supplied Tree
typeBatchMerkleProof¶
funcNewBatchMerkleProof¶
func NewBatchMerkleProof(jsonstring) (BatchMerkleProof,error)
typeBlockHeader¶
type BlockHeader interface {// BlockId returns the BlockId of the BlockHeaderBlockId()BlockId// Equals checks if provided BlockHeader is sameEquals(blockHeaderBlockHeader)bool// contains filtered or unexported methods}
BlockHeader represents data of the block header available in Sigma proposition
funcNewBlockHeader¶
func NewBlockHeader(jsonstring) (BlockHeader,error)
NewBlockHeader creates a new BlockHeader from block header array JSON (Node API)
typeBlockHeaders¶
type BlockHeaders interface {// Len returns the length of the collectionLen()int// Get returns the BlockHeader at the provided index if it existsGet(indexint) (BlockHeader,error)// Add adds provided BlockHeader to the end of the collectionAdd(blockHeaderBlockHeader)// All returns an iterator over all BlockHeader inside the collectionAll()iter.Seq2[int,BlockHeader]// contains filtered or unexported methods}
BlockHeaders an ordered collection of BlockHeader
funcNewBlockHeaders¶
func NewBlockHeaders()BlockHeaders
NewBlockHeaders creates an empty BlockHeaders collection
typeBlockId¶
type BlockId interface {// Equals checks if provided BlockId is sameEquals(blockIdBlockId)bool// contains filtered or unexported methods}
BlockId represents the id of a BlockHeader
funcNewBlockId¶
NewBlockId creates a new BlockId from hex-encoded string
typeBlockIds¶
type BlockIds interface {// Len returns the length of the collectionLen()int// Get returns the BlockId at the provided index if it existsGet(indexint) (BlockId,error)// Add adds provided BlockId to the end of the collectionAdd(blockIdBlockId)// All returns an iterator over all BlockId inside the collectionAll()iter.Seq2[int,BlockId]}
BlockIds an ordered collection of BlockId
typeBox¶
type Box interface {// BoxId returns the BoxId of the BoxBoxId()BoxId// RegisterValue returns value (Constant) stored in the register or nil if the register is emptyRegisterValue(registerId nonMandatoryRegisterId) (Constant,error)// CreationHeight returns the creation height of the BoxCreationHeight()uint32// Tokens returns the ergo Tokens for the BoxTokens()Tokens// Tree returns the ergo Tree for the BoxTree()Tree// BoxValue returns the BoxValue of the BoxBoxValue()BoxValue// Json returns json representation of Box as string (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)Json() (string,error)// JsonEIP12 returns json representation of Box as string according to EIP-12https://github.com/ergoplatform/eips/pull/23JsonEIP12() (string,error)// Size calculates serialized box size(in bytes)Size()uint32// Equals checks if provided Box is sameEquals(boxBox)bool// contains filtered or unexported methods}
Box that is taking part in some transaction on the chain Differs with BoxCandidateby added transaction id and an index in the input of that transaction
funcNewBox¶
func NewBox(boxValueBoxValue, creationHeightuint32, contractContract, txIdTxId, indexuint16, tokensTokens) (Box,error)
NewBox creates a new Box from provided parameters:boxValue - amount of money associated with the boxcreationHeight - height when a transaction containing the box is created.contract - guarding contract(Contract), which should be evaluated to true in order to open(spend) this boxtxId - transaction id in which this box was "created" (participated in outputs)index - index (in outputs) in the transaction
funcNewBoxFromJson¶
NewBoxFromJson parse Box from JSON. Supports Ergo Node/Explorer API and box values and token amount encoded as strings.
typeBoxAssetsData¶
type BoxAssetsData interface {// BoxValue returns the BoxValue of the BoxAssetsDataBoxValue()BoxValue// Tokens returns the Tokens of the BoxAssetsDataTokens()Tokens// Equals checks if provided BoxAssetsData is sameEquals(boxAssetsDataBoxAssetsData)bool// contains filtered or unexported methods}
BoxAssetsData is a pair of value and tokens for a box
funcNewBoxAssetsData¶
func NewBoxAssetsData(boxValueBoxValue, tokensTokens)BoxAssetsData
NewBoxAssetsData creates a new BoxAssetsData from the supplied BoxValue and Tokens
typeBoxAssetsDataList¶
type BoxAssetsDataList interface {// Len returns the length of the collectionLen()int// Get returns the BoxAssetsData at the provided index if it existsGet(indexint) (BoxAssetsData,error)// Add adds provided BoxAssetsData to the end of the collectionAdd(boxAssetsDataBoxAssetsData)// All returns an iterator over all BoxAssetsData inside the collectionAll()iter.Seq2[int,BoxAssetsData]// contains filtered or unexported methods}
BoxAssetsDataList is an ordered collection of BoxAssetsData
funcNewBoxAssetsDataList¶
func NewBoxAssetsDataList()BoxAssetsDataList
NewBoxAssetsDataList creates an empty BoxAssetsDataList
typeBoxCandidate¶
type BoxCandidate interface {// RegisterValue returns value (Constant) stored in the register or nil if the register is emptyRegisterValue(registerId nonMandatoryRegisterId) (Constant,error)// CreationHeight returns the creation height of the BoxCandidateCreationHeight()uint32// Tokens returns the ergo Tokens for the BoxCandidateTokens()Tokens// Tree returns the ergo Tree for the BoxCandidateTree()Tree// BoxValue returns the BoxValue of the BoxCandidateBoxValue()BoxValue// Equals checks if provided BoxCandidate is sameEquals(candidateBoxCandidate)bool// contains filtered or unexported methods}
BoxCandidate contains the same fields as Box except for transaction id and index, that will be calculatedafter full transaction formation. Use BoxCandidateBuilder to create an instance
typeBoxCandidateBuilder¶
type BoxCandidateBuilder interface {// SetMinBoxValuePerByte sets minimal value (per byte of the serialized box size)SetMinBoxValuePerByte(minBoxValuePerByteuint32)// MinBoxValuePerByte returns minimal value (per byte of the serialized box size)MinBoxValuePerByte()uint32// SetValue sets new box valueSetValue(boxValueBoxValue)// Value returns box valueValue()BoxValue// CalcBoxSizeBytes calculates serialized box size(in bytes)CalcBoxSizeBytes() (uint32,error)// CalcMinBoxValue calculates minimal box value for the current box serialized size(in bytes)CalcMinBoxValue() (BoxValue,error)// SetRegisterValue sets register with a given id (R4 - R9) to the given valueSetRegisterValue(registerId nonMandatoryRegisterId, constantConstant)// RegisterValue returns register value for the given register id (R4 - R9), or nil if the register is emptyRegisterValue(registerId nonMandatoryRegisterId) (Constant,error)// DeleteRegisterValue deletes register value(make register empty) for the given register id (R4 - R9)DeleteRegisterValue(registerId nonMandatoryRegisterId)// MintToken mints token, as defined inhttps://github.com/ergoplatform/eips/blob/master/eip-0004.md// Parameters:// token - token id(box id of the first input box in transaction) and token amount// tokenName - token name (will be encoded in R4)// tokenDesc - token description (will be encoded in R5)// numDecimals - number of decimals (will be encoded in R6)MintToken(tokenToken, tokenNamestring, tokenDescstring, numDecimalsuint32)// AddToken adds given token id and token amountAddToken(tokenIdTokenId, tokenAmountTokenAmount)// Build builds the box candidateBuild() (BoxCandidate,error)}
BoxCandidateBuilder is a builder to build a BoxCandidate
funcNewBoxCandidateBuilder¶
func NewBoxCandidateBuilder(boxValueBoxValue, contractContract, creationHeightuint32)BoxCandidateBuilder
NewBoxCandidateBuilder creates a BoxCandidateBuilder with required box parameters.Parameters:boxValue - amount of money associated with the boxcontract - guard Contract which should be evaluated to true in order to open/spend this boxcreationHeight - height when a transaction containing the box is created.It should not exceed the height of the block, containing the transaction with this box.
typeBoxCandidates¶
type BoxCandidates interface {// Len returns the length of the collectionLen()int// Get returns the BoxCandidate at the provided index if it existsGet(indexint) (BoxCandidate,error)// Add adds provided BoxCandidate to the end of the collectionAdd(boxCandidateBoxCandidate)// All returns an iterator over all BoxCandidate inside the collectionAll()iter.Seq2[int,BoxCandidate]// contains filtered or unexported methods}
BoxCandidates is an ordered collection of BoxCandidate
funcNewBoxCandidates¶
func NewBoxCandidates()BoxCandidates
NewBoxCandidates creates an empty BoxCandidates collection
typeBoxId¶
type BoxId interface {// Base16 returns the BoxId as base16 encoded stringBase16()string// Equals checks if provided BoxId is sameEquals(boxIdBoxId)bool// contains filtered or unexported methods}
BoxId (32-byte digest)
typeBoxSelection¶
type BoxSelection interface {// Boxes returns selected boxes to spend as transaction inputsBoxes()Boxes// ChangeBoxes returns selected boxes to use as changeChangeBoxes()BoxAssetsDataList// Equals checks if provided BoxSelection is sameEquals(boxSelectionBoxSelection)bool// contains filtered or unexported methods}
BoxSelection represents selected boxes with change boxes. Instance are created by SimpleBoxSelector
funcNewBoxSelection¶
func NewBoxSelection(ergoBoxesBoxes, changeErgoBoxesBoxAssetsDataList)BoxSelection
NewBoxSelection creates a selection to easily inject custom selection algorithms
typeBoxValue¶
type BoxValue interface {// Int64 returns BoxValue value as int64Int64()int64// Equals checks if provided BoxValue is sameEquals(boxValueBoxValue)bool// contains filtered or unexported methods}
BoxValue in nanoERGs with bound checks
funcNewBoxValue¶
NewBoxValue creates a BoxValue from int64
funcSafeUserMinBoxValue¶
func SafeUserMinBoxValue()BoxValue
SafeUserMinBoxValue returns recommended (safe) minimal BoxValue to use in case box size estimation is unavailable.Allows box size upto 2777 bytes with current min box value per byte of 360 nanoERGs
funcSuggestedTxFee¶
func SuggestedTxFee()BoxValue
SuggestedTxFee returns the suggested transaction fee (semi-default value used across wallets and dApp as of Oct 2020)
typeBoxes¶
type Boxes interface {// Len returns the length of the collectionLen()int// Get returns the Box at the provided index if it existsGet(indexint) (Box,error)// Add adds provided Box to the end of the collectionAdd(boxBox)// All returns an iterator over all Box inside the collectionAll()iter.Seq2[int,Box]// contains filtered or unexported methods}
Boxes an ordered collection of Box
typeByteArray¶
type ByteArray interface {// contains filtered or unexported methods}
funcNewByteArray¶
typeByteArrays¶
type ByteArrays interface {Len()intGet(indexint) (ByteArray,error)Add(byteArrayByteArray)All()iter.Seq2[int,ByteArray]// contains filtered or unexported methods}
funcNewByteArrays¶
func NewByteArrays()ByteArrays
typeCommitmentHint¶
type CommitmentHint interface {// contains filtered or unexported methods}
CommitmentHint is a family of hints which are about a correspondence between a public image of a secret image and prover's commitmentto randomness ("a" in a sigma protocol).
typeConstant¶
type Constant interface {// Base16 encode as Base16-encoded ErgoTree serialized value or throw an error if serialization failedBase16() (string,error)// Type returns the Constant type as stringType() (string,error)// Value returns the Constant value as stringValue() (string,error)// Int16 extracts int16 value and returns error if wrong Constant typeInt16() (int16,error)// Int32 extracts int32 value and returns error if wrong Constant typeInt32() (int32,error)// Int64 extracts int64 value and returns error if wrong Constant typeInt64() (int64,error)// Bytes extracts byte array and returns error if wrong Constant typeBytes() ([]byte,error)// Equals checks if provided Constant is sameEquals(constantConstant)bool// contains filtered or unexported methods}
Constant represents Ergo constant(evaluated) values
funcNewConstant¶
NewConstant creates a new Constant from Base16-encoded ErgoTree serialized value
funcNewConstantFromBox¶
NewConstantFromBox creates a new Constant from Box
funcNewConstantFromBytes¶
NewConstantFromBytes creates a new Constant from byte array
funcNewConstantFromECPointBytes¶
NewConstantFromECPointBytes parse from raw EcPoint value from bytes and make ProveDlog Constant
funcNewConstantFromInt16¶added inv0.28.0
NewConstantFromInt16 creates a new Constant from int16 value
funcNewConstantFromInt32¶
NewConstantFromInt32 creates a new Constant from int32 value
funcNewConstantFromInt64¶
NewConstantFromInt64 creates a new Constant from int64 value
typeContextExtension¶
type ContextExtension interface {// Keys returns iterator over all keys in the ContextExtensionKeys()iter.Seq[uint8]// Get returns Constant at provided key or nil if it doesn't existGet(keyuint8) (Constant,error)// Set adds Constant at provided keySet(keyuint8, constantConstant)// All returns iterator over all key,value pairs in the ContextExtensionAll()iter.Seq2[uint8,Constant]// Values returns iterator over all Constant in the ContextExtensionValues()iter.Seq[Constant]// contains filtered or unexported methods}
ContextExtension represent user-defined variables to be put into context
funcNewContextExtension¶added inv0.28.0
func NewContextExtension()ContextExtension
NewContextExtension creates new empty ContextExtension instance
typeContract¶
type Contract interface {// Tree returns the ergo Tree of the ContractTree()Tree// Equals checks if provided Contract is sameEquals(contractContract)bool// contains filtered or unexported methods}
Contract defines the contract(script) that will be guarding box contents
funcNewContractCompileFromString¶
NewContractCompileFromString compiles a contract from ErgoScript source code
funcNewContractFromTree¶
NewContractFromTree creates a new Contract from ergo Tree
funcNewContractPayToAddress¶
NewContractPayToAddress creates a new Contract that allows spending of the guarded box by a given recipient (Address)
typeDataInput¶
type DataInput interface {// BoxId returns the BoxId of the DataInputBoxId()BoxId// contains filtered or unexported methods}
DataInput represent inputs that are used to enrich script context, but won't be spent by the transaction
typeDataInputs¶
type DataInputs interface {// Len returns the length of the collectionLen()int// Get returns the Input at the provided index if it existsGet(indexint) (DataInput,error)// Add adds provided DataInput to the end of the collectionAdd(dataInputDataInput)// All returns an iterator over all DataInput inside the collectionAll()iter.Seq2[int,DataInput]// contains filtered or unexported methods}
DataInputs an ordered collection if DataInput
funcNewDataInputs¶
func NewDataInputs()DataInputs
NewDataInputs creates an empty DataInputs collection
typeDerivationPath¶added inv0.28.0
type DerivationPath interface {// String returns the DerivationPath formatted as string in the m/44/429/acc'/0/addr formatString()string// Depth returns the length of the DerivationPathDepth()uint32// Next returns a new DerivationPath with the last element of the derivation path being increased, e.g. m/1/2 -> m/1/3Next() (DerivationPath,error)// contains filtered or unexported methods}
funcNewDerivationPath¶added inv0.28.0
func NewDerivationPath(accountuint32, addressIndices []uint32) (DerivationPath,error)
NewDerivationPath creates DerivationPath from account index and address indices
funcNewDerivationPathFromString¶added inv0.28.0
func NewDerivationPathFromString(sstring) (DerivationPath,error)
NewDerivationPathFromString creates DerivationPath from string whichshould be in the form of m/44/429/acc'/0/addr
typeExtendedPublicKey¶added inv0.28.0
type ExtendedPublicKey interface {// Child derives a new ExtendedPublicKey from the provided indexChild(childIndexuint32) (ExtendedPublicKey,error)// Derive derives a new ExtendedPublicKey from the supplied DerivationPathDerive(derivationPathDerivationPath) (ExtendedPublicKey,error)// Address returns the Address associated with the ExtendedPublicKeyAddress()Address// contains filtered or unexported methods}
funcNewExtendedPublicKey¶added inv0.28.0
func NewExtendedPublicKey(publicKeyBytes []byte, chainCode []byte, derivationPathDerivationPath) (ExtendedPublicKey,error)
NewExtendedPublicKey creates a new ExtendedPublicKey from publicKeyBytes, chainCode and derivationPathpublicKeyBytes needs to be the length of 33 byteschainCode needs to be the length of 32 bytes
typeExtendedSecretKey¶added inv0.28.0
type ExtendedSecretKey interface {// Child derives a new ExtendedSecretKey from the provided index// The index is in the form of soft or hardened indices// For example: 4 or 4' respectivelyChild(indexstring) (ExtendedSecretKey,error)// Path returns the DerivationPath of the ExtendedSecretKeyPath()DerivationPath// SecretKey returns the SecretKey of the ExtendedSecretKeySecretKey()SecretKey// ExtendedPublicKey returns the ExtendedPublicKey associated with the ExtendedSecretKeyExtendedPublicKey()ExtendedPublicKey// Derive derives a new ExtendedSecretKey from the supplied DerivationPathDerive(derivationPathDerivationPath) (ExtendedSecretKey,error)}
funcDeriveMaster¶added inv0.28.0
func DeriveMaster(seed []byte) (ExtendedSecretKey,error)
DeriveMaster derives root ExtendedSecretKey from seed bytes
funcNewExtendedSecretKey¶added inv0.28.0
func NewExtendedSecretKey(secretKeyBytes []byte, chainCode []byte, derivationPathDerivationPath) (ExtendedSecretKey,error)
NewExtendedSecretKey creates a new ExtendedSecretKey from secretKeyBytes, chainCode and derivationPathsecretKeyBytes needs to be the length of 32 byteschainCode needs to be the length of 32 bytes
typeHintsBag¶
type HintsBag interface {// Add adds CommitmentHint to the bagAdd(hintCommitmentHint)// Len returns the length of the HintsBagLen()int// Get returns the CommitmentHint at the provided index if it existsGet(indexint) (CommitmentHint,error)// All returns an iterator over all CommitmentHint inside the collectionAll()iter.Seq2[int,CommitmentHint]// contains filtered or unexported methods}
HintsBag is a collection of CommitmentHint to be used by a prover
typeInput¶
type Input interface {// BoxId returns BoxId of InputBoxId()BoxId// SpendingProof returns spending proof of Input as ProverResultSpendingProof()ProverResult// contains filtered or unexported methods}
Input represents signed inputs in signed transaction
typeInputs¶
type Inputs interface {// Len returns the length of the collectionLen()int// Get returns the Input at the provided index if it existsGet(indexint) (Input,error)// Add adds provided Input to the end of the collectionAdd(inputInput)// All returns an iterator over all Input inside the collectionAll()iter.Seq2[int,Input]}
Inputs an ordered collection of Input
typeMerkleProof¶
type MerkleProof interface {// AddNode adds a new node and it's hash to the MerkleProof. Hash must be 32 bytes in sizeAddNode(hash []byte, side nodeSide)error// Valid validates the MerkleProof against the provided root hashValid(expectedRoot []byte)bool// ValidBase16 validates the MerkleProof against the provided base16 root hashValidBase16(expectedRootstring)bool}
funcNewMerkleProof¶
func NewMerkleProof(leafData []byte) (MerkleProof,error)
funcNewMerkleProofFromJson¶
func NewMerkleProofFromJson(jsonstring) (MerkleProof,error)
typeMnemonicGenerator¶
type MnemonicGenerator interface {// Generate a new mnemonic sentence using random entropyGenerate() (string,error)// GenerateFromEntropy generates a new mnemonic sentence using provided entropyGenerateFromEntropy(entropy []byte) (string,error)}
MnemonicGenerator generates new mnemonic seed phrases
funcNewMnemonicGenerator¶
func NewMnemonicGenerator(languagestring, strengthuint32) (MnemonicGenerator,error)
NewMnemonicGenerator creates a new MnemonicGenerator based on supplied language and strength
typeNipopowProof¶
type NipopowProof interface {// IsBetterThan implementation of the ≥ algorithm from KMZ17, see Algorithm 4//https://fc20.ifca.ai/preproceedings/74.pdfIsBetterThan(otherProofNipopowProof) (bool,error)// SuffixHead returns suffix headSuffixHead()PoPowHeader// Json returns json representation of NipopowProof as textJson() (string,error)// contains filtered or unexported methods}
funcNewNipopowProof¶
func NewNipopowProof(jsonstring) (NipopowProof,error)
NewNipopowProof parse NipopowProof from JSON
typeNipopowVerifier¶
type NipopowVerifier interface {// BestProof returns the best NipopowProofBestProof()NipopowProof// BestChain returns chain of BlockHeaders from the best proofBestChain()BlockHeaders// Process given NipopowProofProcess(newProofNipopowProof)error}
NipopowVerifier a verifier for PoPow proofs. During its lifetime, it processes many proofs with the aim ofdeducing at any given point what is the best (sub)chain rooted at the specified genesis
funcNewNipopowVerifier¶
func NewNipopowVerifier(genesisBlockIdBlockId)NipopowVerifier
NewNipopowVerifier creates a new NipopowVerifier
typeParameters¶added inv0.28.0
type Parameters interface {// contains filtered or unexported methods}
funcDefaultParameters¶added inv0.28.0
func DefaultParameters()Parameters
DefaultParameters returns default blockchain parameters that were set at genesis
funcNewParameters¶added inv0.28.0
func NewParameters(blockVersionint32,storageFeeFactorint32,minValuePerByteint32,maxBlockSizeint32,maxBlockCostint32,tokenAccessCostint32,inputCostint32,dataInputCostint32,outputCostint32)Parameters
NewParameters creates new Parameters from provided blockchain parameters
funcNewParametersFromJson¶added inv0.28.0
func NewParametersFromJson(jsonstring) (Parameters,error)
NewParametersFromJson parses parameters from JSON. Support Ergo Node API/Explorer API
typePoPowHeader¶
type PoPowHeader interface {// Header returns BlockHeader of PoPowHeaderHeader() (BlockHeader,error)// Interlinks returns BlockIds of PoPowHeaderInterlinks() (BlockIds,error)// InterlinksProof returns BatchMerkleProof of PoPowHeaderInterlinksProof() (BatchMerkleProof,error)// CheckInterlinksProof checks interlinks proofCheckInterlinksProof()bool// Json returns json representation of PoPowHeader as stringJson() (string,error)// Equals checks if provided PoPowHeader is sameEquals(poPowHeaderPoPowHeader)bool// contains filtered or unexported methods}
funcNewPoPowHeader¶
func NewPoPowHeader(jsonstring) (PoPowHeader,error)
NewPoPowHeader parses PoPowHeader from json string
typePreHeader¶
type PreHeader interface {// Equals checks if provided PreHeader is sameEquals(preHeaderPreHeader)bool// contains filtered or unexported methods}
PreHeader represents a block header with the current SpendingTransaction, that can be predicted by a miner before its formation
funcNewPreHeader¶
func NewPreHeader(headerBlockHeader)PreHeader
NewPreHeader creates PreHeader using data from BlockHeader
typePropositions¶
type Propositions interface {// Add adds new propositionAdd(bytes []byte)error// contains filtered or unexported methods}
Propositions list(public keys)
funcNewPropositions¶
func NewPropositions()Propositions
NewPropositions creates empty proposition holder
typeProverResult¶
type ProverResult interface {// Bytes returns proof bytesBytes() []byte// ContextExtension returns ContextExtension of ProverResultContextExtension()ContextExtension// Json representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)Json() (string,error)}
ProverResult represents proof of correctness of tx spending
typeReducedTransaction¶
type ReducedTransaction interface {// UnsignedTransaction returns the UnsignedTransactionUnsignedTransaction()UnsignedTransaction// contains filtered or unexported methods}
ReducedTransaction represents reduced transaction, i.e. unsigned transaction where each unsigned inputis augmented with ReducedInput which contains a script reduction result.After an unsigned transaction is reduced it can be signed without context.Thus, it can be serialized and transferred for example to Cold Wallet and signedin an environment where secrets are known.see EIP-19 for more details -https://github.com/ergoplatform/eips/blob/f280890a4163f2f2e988a0091c078e36912fc531/eip-0019.md
funcNewReducedTransaction¶
func NewReducedTransaction(unsignedTxUnsignedTransaction, boxesToSpentBoxes, dataBoxesBoxes, stateContextStateContext) (ReducedTransaction,error)
NewReducedTransaction creates a ReducedTransaction i.e unsigned transaction where each unsigned inputis augmented with ReducedInput which contains a script reduction result
typeSecretKey¶
type SecretKey interface {// Address returns address of the SecretKeyAddress()Address// Bytes returns SecretKey encoded to bytesBytes() []byte// contains filtered or unexported methods}
SecretKey represents secret key for the prover
funcNewSecretKeyFromBytes¶
NewSecretKeyFromBytes parses dlog secret key from bytes (SEC-1-encoded scalar)provided secret key bytes must be of length 32
typeSecretKeys¶
type SecretKeys interface {// Len returns the length of the collectionLen()int// Get returns the SecretKey at the provided index if it existsGet(indexint) (SecretKey,error)// Add adds provided SecretKey to the end of the collectionAdd(secretKeySecretKey)// All returns an iterator over all SecretKey inside the collectionAll()iter.Seq2[int,SecretKey]// contains filtered or unexported methods}
SecretKeys an ordered collection of SecretKey
funcNewSecretKeys¶
func NewSecretKeys()SecretKeys
NewSecretKeys creates an empty SecretKeys collection
typeSignedMessage¶
type SignedMessage interface {// contains filtered or unexported methods}
typeSimpleBoxSelector¶
type SimpleBoxSelector interface {// Select selects inputs to satisfy target balance and tokens// Parameters:// inputs - available inputs (returns an error, if empty)// targetBalance - coins (in nanoERGs) needed// targetTokens - amount of tokens needed// Returns: selected inputs and box assets(value+tokens) with changeSelect(inputsBoxes, targetBalanceBoxValue, targetTokensTokens) (BoxSelection,error)}
SimpleBoxSelector is a naive box selector, collects inputs until target balance is reached
funcNewSimpleBoxSelector¶
func NewSimpleBoxSelector()SimpleBoxSelector
NewSimpleBoxSelector creates a new SimpleBoxSelector
typeStateContext¶
type StateContext interface {// Equals checks if provided StateContext is sameEquals(stateContextStateContext)bool// contains filtered or unexported methods}
StateContext represents blockchain state (last headers, etc.)
funcNewStateContext¶
func NewStateContext(preHeaderPreHeader, headersBlockHeaders, parametersParameters) (StateContext,error)
NewStateContext creates StateContext from PreHeader and BlockHeaders
typeToken¶
type Token interface {// Id returns TokenId of the TokenId()TokenId// Amount returns TokenAmount of the TokenAmount()TokenAmount// JsonEIP12 returns json representation of Token as string according to EIP-12https://github.com/ergoplatform/eips/pull/23JsonEIP12() (string,error)// Equals checks if provided Token is sameEquals(tokenToken)bool// contains filtered or unexported methods}
Token represented with TokenId paired with its TokenAmount
funcNewToken¶
func NewToken(tokenIdTokenId, tokenAmountTokenAmount)Token
NewToken creates Token from provided TokenId and TokenAmount
typeTokenAmount¶
type TokenAmount interface {// Int64 converts TokenAmount to int64Int64()int64// Equals checks if provided TokenAmount is sameEquals(tokenAmountTokenAmount)bool// contains filtered or unexported methods}
TokenAmount is token amount with bound checks
funcNewTokenAmount¶
func NewTokenAmount(amountint64) (TokenAmount,error)
NewTokenAmount creates TokenAmount from int64
typeTokenId¶
type TokenId interface {// Base16 returns the TokenId as base16 encoded stringBase16()string// Equals checks if provided TokenId is sameEquals(tokenIdTokenId)bool// contains filtered or unexported methods}
TokenId (32-byte digest)
funcNewTokenId¶
NewTokenId creates a TokenId from a base16-encoded string (32 byte digest)
funcNewTokenIdFromBoxId¶
NewTokenIdFromBoxId creates a TokenId from ergo box id (32 byte digest)
typeTokens¶
type Tokens interface {// Len returns the length of the collectionLen()int// Get returns the Token at the provided index if it existsGet(indexint) (Token,error)// Add adds provided Token to the end of the collectionAdd(tokenToken)// All returns an iterator over all Token inside the collectionAll()iter.Seq2[int,Token]// contains filtered or unexported methods}
Tokens an ordered collection of Token
typeTransaction¶
type Transaction interface {// TxId returns TxId for this TransactionTxId()TxId// Inputs returns Inputs for this TransactionInputs()Inputs// DataInputs returns DataInputs for this TransactionDataInputs()DataInputs// OutputCandidates returns BoxCandidates for this TransactionOutputCandidates()BoxCandidates// Outputs returns Boxes for this TransactionOutputs()Boxes// Json returns json representation of Transaction as string (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)Json() (string,error)// JsonEIP12 returns json representation of Transaction as string according to EIP-12https://github.com/ergoplatform/eips/pull/23JsonEIP12() (string,error)// Validate validates the current TransactionValidate(stateContextStateContext, boxesToSpentBoxes, dataBoxesBoxes)error// contains filtered or unexported methods}
Transaction is an atomic state transition operation. It destroys Boxes from the stateand creates new ones. If transaction is spending boxes protected by some non-trivial scripts,its inputs should also contain proof of spending correctness - context extension (user-definedkey-value map) and data inputs (links to existing boxes in the state) that may be used duringscript reduction to crypto, signatures that satisfies the remaining cryptographic protectionof the script.Transactions are not encrypted, so it is possible to browse and view every transaction evercollected into a block.
funcNewTransaction¶
func NewTransaction(unsignedTxUnsignedTransaction, proofsByteArrays) (Transaction,error)
NewTransaction creates Transaction from UnsignedTransaction and an array of proofs in the same order asUnsignedTransaction inputs with empty proof indicated with empty ByteArray
funcNewTransactionFromJson¶
func NewTransactionFromJson(jsonstring) (Transaction,error)
NewTransactionFromJson parse Transaction from JSON. Supports Ergo Node/Explorer API and box values and token amount encoded as strings.
typeTransactionHintsBag¶
type TransactionHintsBag interface {// AddHintsForInput adds hints for inputAddHintsForInput(indexuint32, hintsBagHintsBag)// AllHintsForInput gets HintsBag corresponding to input indexAllHintsForInput(indexuint32)HintsBag// contains filtered or unexported methods}
funcExtractHintsFromSignedTransaction¶
func ExtractHintsFromSignedTransaction(transactionTransaction,stateContextStateContext,boxesToSpendBoxes,dataBoxesBoxes,realPropositionsPropositions,simulatedPropositionsPropositions) (TransactionHintsBag,error)
ExtractHintsFromSignedTransaction extracts hints from signed transaction
funcNewTransactionHintsBag¶
func NewTransactionHintsBag()TransactionHintsBag
NewTransactionHintsBag creates empty TransactionHintsBag
typeTree¶
type Tree interface {// Base16 converts the Tree to a base16 encoded string.Base16() (string,error)// Address converts the Tree to an Address.Address() (Address,error)// TemplateBytesLength determines the length of the byte arrayTemplateBytesLength() (int,error)// TemplateHash returns the hash of the template bytes as stringTemplateHash() (string,error)// ConstantsLength returns the number of constants stored in the serialized ErgoTree or throws error if the parsing of constants failedConstantsLength() (int,error)// Constant returns Constant with given index (as stored in serialized ErgoTree) if it exists or throws error if the parsing of constants failedConstant(indexint) (Constant,error)// Constants returns all Constant within the Tree or throws error if the parsing of constants failedConstants() ([]Constant,error)// Equals checks if provided Tree is sameEquals(treeTree)bool// contains filtered or unexported methods}
Tree is the root of ErgoScript IR. Serialized instances of Tree are self-sufficient and can be passed around
typeTxBuilder¶
type TxBuilder interface {// SetDataInputs set data inputs for transactionSetDataInputs(dataInputsDataInputs)// SetContextExtension sets context extension for a given inputSetContextExtension(boxIdBoxId, contextExtensionContextExtension)// SetTokenBurnPermit permits the burn of the given token amount, i.e. allows this token amount to be omitted in the outputsSetTokenBurnPermit(tokensTokens)// DataInputs returns DataInputs of the TxBuilderDataInputs()DataInputs// BoxSelection returns BoxSelection of the TxBuilderBoxSelection()BoxSelection// OutputCandidates returns BoxCandidates of the TxBuilderOutputCandidates()BoxCandidates// CurrentHeight returns the current heightCurrentHeight()uint32// FeeAmount returns the fee amount of the TxBuilderFeeAmount()BoxValue// ChangeAddress returns the change address of the TxBuilderChangeAddress()Address// Build builds the UnsignedTransactionBuild() (UnsignedTransaction,error)}
TxBuilder builds UnsignedTransaction
funcNewTxBuilder¶
func NewTxBuilder(boxSelectionBoxSelection,outputCandidatesBoxCandidates,currentHeightuint32,feeAmountBoxValue,changeAddressAddress)TxBuilder
NewTxBuilder creates a new TxBuilderParametersboxSelection - selected input boxesoutputCandidates - output boxes to be "created" in this transactioncurrentHeight - chain height that will be used in additionally created boxes (change, miner's fee, etc.)feeAmount - miner's feechangeAddress - change (inputs - outputs) will be sent to this address
typeTxId¶
type TxId interface {// String returns TxId as stringString() (string,error)// Equals checks if provided TxId is sameEquals(txIdTxId)bool// contains filtered or unexported methods}
TxId represents transaction id
typeUnsignedInput¶
type UnsignedInput interface {// BoxId returns the BoxId of the UnsignedInputBoxId()BoxId// ContextExtension returns the ContextExtension of the UnsignedInputContextExtension()ContextExtension// contains filtered or unexported methods}
UnsignedInput used in construction of UnsignedTransactions
typeUnsignedInputs¶
type UnsignedInputs interface {// Len returns the length of the collectionLen()int// Get returns the UnsignedInput at the provided index if it existsGet(indexint) (UnsignedInput,error)// Add adds provided UnsignedInput to the end of the collectionAdd(unsignedInputUnsignedInput)// All returns an iterator over all UnsignedInput inside the collectionAll()iter.Seq2[int,UnsignedInput]}
UnsignedInputs an ordered collection of UnsignedInput
funcNewUnsignedInputs¶
func NewUnsignedInputs()UnsignedInputs
NewUnsignedInputs creates an empty UnsignedInputs collection
typeUnsignedTransaction¶
type UnsignedTransaction interface {// TxId returns TxId for this UnsignedTransactionTxId()TxId// UnsignedInputs returns UnsignedInputs for this UnsignedTransactionUnsignedInputs()UnsignedInputs// DataInputs returns DataInputs for this UnsignedTransactionDataInputs()DataInputs// OutputCandidates returns BoxCandidates for this UnsignedTransactionOutputCandidates()BoxCandidates// Json returns json representation of UnsignedTransaction as string (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)Json() (string,error)// JsonEIP12 returns json representation of UnsignedTransaction as string according to EIP-12https://github.com/ergoplatform/eips/pull/23JsonEIP12() (string,error)// contains filtered or unexported methods}
UnsignedTransaction represents an unsigned transaction (inputs without proofs)
funcNewUnsignedTransactionFromJson¶
func NewUnsignedTransactionFromJson(jsonstring) (UnsignedTransaction,error)
NewUnsignedTransactionFromJson parse UnsignedTransaction from JSON. Supports Ergo Node/Explorer API and box values and token amount encoded as strings.
typeWallet¶
type Wallet interface {// AddSecret adds a secret to the wallets proverAddSecret(secretSecretKey)error// SignTransaction signs a transactionSignTransaction(stateContextStateContext, unsignedTxUnsignedTransaction, boxesToSpendBoxes, dataBoxesBoxes) (Transaction,error)// SignTransactionMulti signs a multi signature transactionSignTransactionMulti(stateContextStateContext, unsignedTxUnsignedTransaction, boxesToSpendBoxes, dataBoxesBoxes, txHintsTransactionHintsBag) (Transaction,error)// SignReducedTransaction signs a reduced transaction (generating proofs for inputs)SignReducedTransaction(reducedTxReducedTransaction) (Transaction,error)// SignReducedTransactionMulti signs a multi signature reduced transactionSignReducedTransactionMulti(reducedTxReducedTransaction, txHintsTransactionHintsBag) (Transaction,error)// GenerateCommitments generates Commitments for unsigned txGenerateCommitments(stateContextStateContext, unsignedTxUnsignedTransaction, boxesToSpendBoxes, dataBoxesBoxes) (TransactionHintsBag,error)// GenerateCommitmentsForReducedTransaction generates Commitments for reduced transactionGenerateCommitmentsForReducedTransaction(reducedTxReducedTransaction) (TransactionHintsBag,error)// SignMessageUsingP2PK signs an arbitrary message using a P2PK addressSignMessageUsingP2PK(addressAddress, message []byte) (SignedMessage,error)}
funcNewWallet¶
NewWallet creates a Wallet instance loading secret key from mnemonic or throws error if a DlogSecretKey cannot be parsed from the provided phrase
funcNewWalletFromSecretKeys¶
func NewWalletFromSecretKeys(secretsSecretKeys)Wallet
NewWalletFromSecretKeys creates a Wallet from secrets
Source Files¶
- address.go
- batchmerkleproof.go
- blockheader.go
- box.go
- boxcandidatebuilder.go
- boxselector.go
- bytearray.go
- cgo.go
- constant.go
- contextextension.go
- contract.go
- datainput.go
- derivationpath.go
- errors.go
- extendedpublickey.go
- extendedsecretkey.go
- input.go
- merkleproof.go
- mnemonic.go
- nipopow.go
- parameters.go
- preheader.go
- reducedtransaction.go
- secretkey.go
- statecontext.go
- token.go
- transaction.go
- tree.go
- txbuilder.go
- verifier.go
- wallet.go
Directories¶
Path | Synopsis |
---|---|
packaged | |
include See https://github.com/golang/go/issues/26366. | See https://github.com/golang/go/issues/26366. |
lib See https://github.com/golang/go/issues/26366. | See https://github.com/golang/go/issues/26366. |
lib/darwin-aarch64 See https://github.com/golang/go/issues/26366. | See https://github.com/golang/go/issues/26366. |
lib/darwin-amd64 See https://github.com/golang/go/issues/26366. | See https://github.com/golang/go/issues/26366. |
lib/linux-aarch64 See https://github.com/golang/go/issues/26366. | See https://github.com/golang/go/issues/26366. |
lib/linux-amd64 See https://github.com/golang/go/issues/26366. | See https://github.com/golang/go/issues/26366. |
lib/windows-amd64 See https://github.com/golang/go/issues/26366. | See https://github.com/golang/go/issues/26366. |