Categorygithub.com/endless-labs/endless-go-sdk
modulepackage
1.0.0
Repository: https://github.com/endless-labs/endless-go-sdk.git
Documentation: pkg.go.dev

# README

endless-go-sdk

An SDK for the Endless blockchain in Go

go-version

+1.22

Getting started

Add go to your go.mod file

go get -u  github.com/endless-labs/endless-go-sdk

Where can I see examples?

Take a look at examples/ for some examples of how to write clients.

Where can I learn more?

You can read more about the Go SDK documentation on docs.endless.link

Feature support

  • BCS encoding and decoding
  • Structured API parsing
  • Ed25519 Signer support
  • MultiEd25519 support
  • Secp256k1 Signer support
  • On-chain and off-chain multi-sig support
  • Sponsored transaction and Multi-agent support
  • Transaction submission and waiting
  • External signer support e.g. HSMs or external services
  • Transaction Simulation
  • Automated sequence number management for parallel transaction submission

Examples

  • Fund the account with the faucet to create it on-chain
  • Transaction signing
  • Sponsored transaction example
  • Batch transaction
  • External and alternative signing methods
  • Performance differences between transaction submission methods
  • Create On-chain multi-sig
  • Create Off-chain multi-sig
  • Upgrade account to Off-chain multi-sig
  • Safe transaction

# Packages

Package api represents all types associated with the Endless REST API.
Package bcs implements Binary Canonical Serialization [BCS].
Package crypto handles all cryptographic types and operations associated with Endless.
Package examples is a collection of examples for the Endless Go SDK.

# Functions

BytesToHex converts bytes to a 0x prefixed hex string.
CoinBatchSafeTransferPayload builds an EntryFunction payload for transferring coins to multiple receivers Args: - coinType is the type of coin to transfer.
CoinBatchTransferPayload builds an EntryFunction payload for transferring coins to multiple receivers Args: - coinType is the type of coin to transfer.
CoinSafeTransferPayload builds an SafeEntryFunction payload for transferring coins Args: - coinType is the type of coin to transfer.
CoinTransferPayload builds an EntryFunction payload for transferring coins Args: - coinType is the type of coin to transfer.
EDSTransferTransaction Move some EDS from sender to dest, only for single signer Amount in Octas (10^-8 EDS) options may be: MaxGasAmount, GasUnitPrice, ExpirationSeconds, ValidUntil, SequenceNumber, ChainIdOption deprecated, please use the EntryFunction APIs.
FungibleAssetPrimaryStoreTransferPayload builds an [EntryFunction] payload to transfer between two primary stores.
FungibleAssetTransferPayload builds an EntryFunction payload to transfer between two fungible asset stores Args: - faMetadataAddress is the [AccountAddress] of the metadata for the fungible asset - source is the store [AccountAddress] to transfer from - dest is the destination [AccountAddress] - amount is the amount of coins to transfer Note: for now, if metadata is nil, then it will fail to build.
Get makes a GET request to the endpoint and parses the response into the given type with JSON.
No description provided by the author
MultisigAddOwnerPayload creates a payload to add an owner from the multisig.
MultisigApprovePayload generates a payload for approving a transaction on-chain.
MultisigChangeThresholdPayload creates a payload to change the number of signatures required for a transaction to pass.
MultisigCreateAccountPayload creates a payload for setting up a multisig Required signers must be between 1 and the number of addresses total (sender + additional addresses).
MultisigCreateTransactionPayload creates a transaction to be voted upon in an on-chain multisig Note, this serializes an EntryFunction payload, and sends it as an argument in the transaction.
MultisigCreateTransactionPayloadWithHash creates a transaction to be voted upon in an on-chain multisig This differs from MultisigCreateTransactionPayload by instead taking a SHA3-256 hash of the payload and using that as the identifier of the transaction.
MultisigRejectPayload generates a payload for rejecting a transaction on-chain.
MultisigRemoveOwnerPayload creates a payload to remove an owner from the multisig.
NewAccountFromSigner creates an account from a Signer, which is most commonly a private key.
NewClient Creates a new client with a specific network config that can be extended in the future.
NewEd25519Account creates a legacy Ed25519 account, this is most commonly used in wallets.
NewEd25519SingleSenderAccount creates a single signer Ed25519 account.
NewHttpError creates a new HttpError from a http.Response.
NewIndexerClient creates a new client specifically for requesting data from the indexer.
NewNodeClient creates a new client for interacting with an EndlessCoin nodE API.
NewNodeClientWithHttpClient creates a new client for interacting with an EndlessCoin nodE API with a custom http.Client.
NewObjectTag creates a 0x1::object::Object TypeTag based on an inner type.
NewOptionTag creates a 0x1::option::Option TypeTag based on an inner type.
NewSecp256k1Account creates a Secp256k1 account.
NewStringTag creates a TypeTag for 0x1::string::String.
No description provided by the author
NewTypeTag wraps a TypeTagImpl in a TypeTag.
NewVectorTag creates a TypeTag for vector<inner>.
ParseHex Convenience function to deal with 0x at the beginning of hex strings.
Post
Post makes a POST request to the endpoint with the given body and parses the response into the given type with JSON.
PublishPackagePayloadFromJsonFile publishes code created with the EndlessCoin CLI to publish with it.
RawTransactionPrehash Return the sha3-256 prehash for RawTransaction Do not write to the []byte returned.
RawTransactionWithDataPrehash Return the sha3-256 prehash for RawTransactionWithData Do not write to the []byte returned.
Sha3256Hash takes a hash of the given sets of bytes.
StrToBigInt converts a string to a big.Int.
StrToUint64 converts a string to a uint64.

# Constants

ClientHeader is the header key for the SDK version.
ContentTypeEndlessSignedTxnBcs header for sending BCS transaction payloads.
No description provided by the author
Default to 5 minutes.
Default to min gas price.
Default to 0.001 EDS max gas amount.
No description provided by the author
HttpErrSummaryLength is the maximum length of the body to include in the error message.
No description provided by the author
No description provided by the author
No description provided by the author
address type argument.
bool type argument.
u128 type argument.
u16 type argument.
u256 type argument.
u32 type argument.
u64 type argument.
u8 type argument.
vector<u8> type argument.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Deprecated.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TransactionSubmissionTypeMultiAgent represents a multi-agent or fee payer transaction.
TransactionSubmissionTypeSingle represents a single signer transaction, no multi-agent and no-fee payer.
Represents the address type in Move AddressTag.
Represents the bool type in Move BoolTag.
Represents the signer type in Move SignerTag.
Represents the struct type in Move StructTag.
Represents the u128 type in Move U128Tag.
Represents the u16 type in Move U16Tag.
Represents the u256 type in Move U256Tag.
Represents the u32 type in Move U32Tag.
Represents the u64 type in Move U64Tag.
Represents the u8 type in Move U8Tag.
Represents the vector type in Move VectorTag.
UserTransactionVariant is the variant for a transaction submitted by a user.

# Variables

AccountFour represents the 0x4 address.
AccountOne represents the 0x1 address.
AccountThree represents the 0x3 address.
AccountTwo represents the 0x2 address.
AccountZero represents the 0x0 address.
ClientHeaderValue is the header value for the SDK version.
No description provided by the author
MainnetConfig is for use with mainnet.
NamedNetworks Map from network name to NetworkConfig.
TestnetConfig is for use with testnet.
TransactionPrefix is a cached hash prefix for taking transaction hashes.

# Structs

AccountInfo is returned from calls to #Account().
AccountResourceInfo is returned by #AccountResource() and #AccountResources().
AccountResourceRecord DeserializeSequence[AccountResourceRecord](bcs) approximates the Rust side BTreeMap<StructTag,Vec<u8>> They should BCS the same with a prefix Uleb128 length followed by (StructTag,[]byte) pairs.
AddressTag represents the address type in Move.
BoolTag represents the bool type in Move.
Client is a facade over the multiple types of underlying clients, as the user doesn't actually care where the data comes from.
No description provided by the author
ConcResponse is a concurrent response wrapper as a return type for all APIs.
Ed25519TransactionAuthenticator for legacy ED25519 accounts Implements TransactionAuthenticatorImpl, bcs.Struct.
EntryFunction call a single published entry function arguments are ordered BCS encoded bytes.
EstimateGasInfo is returned by #EstimateGasPrice().
No description provided by the author
HttpError is an error type that represents an error from a http request.
IndexerClient is a GraphQL client specifically for requesting for data from the EndlessCoin indexer.
ModuleBundle is long deprecated and no longer used, but exist as an enum position in TransactionPayload.
ModuleId the identifier for a module e.g.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Multisig is an on-chain multisig transaction, that calls an entry function associated.
MultisigTransactionPayload is an enum allowing for multiple types of transactions to be called via multisig Note this does not implement TransactionPayloadImpl.
NetworkConfig a configuration for the Client and which network to use.
NodeClient is a client for interacting with an EndlessCoin nodE API.
NodeInfo information retrieved about the current state of the blockchain on API requests.
RawTransaction representation of a transaction's parts prior to signing Implements crypto.MessageSigner, crypto.Signer, bcs.Struct.
No description provided by the author
No description provided by the author
Script A Move script as compiled code as a transaction.
ScriptArgument a Move script argument, which encodes its type with it.
No description provided by the author
SignedTransaction a raw transaction plus its authenticator for a fully verifiable message.
SignerTag represents the signer type in Move.
No description provided by the author
StructTag represents an on-chain struct of the form address::module::name<T1,T2,...> and each T is a [TypeTag].
TransactionAuthenticator is used for authorizing a transaction.
No description provided by the author
No description provided by the author
TransactionPayload the actual instructions of which functions to call on chain.
No description provided by the author
No description provided by the author
TypeTag is a wrapper around a [TypeTagImpl] e.g.
U128Tag represents the u128 type in Move.
U16Tag represents the u16 type in Move.
U256Tag represents the u256 type in Move.
U32Tag represents the u32 type in Move.
U64Tag represents the u64 type in Move.
U8Tag represents the u8 type in Move.
VectorTag represents the vector<T> type in Move, where T is another [TypeTag].
ViewPayload is a payload for a view function.

# Interfaces

EndlessClient is an interface for all functionality on the Client.
EndlessFaucetClient is an interface for all functionality on the Client that is Faucet related.
EndlessRpcClient is an interface for all functionality on the Client that is Node RPC related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TransactionSigner is a generic interface for a way to sign transactions.
TypeTagImpl is an interface describing all the different types of [TypeTag].

# Type aliases

Account is a wrapper for a signer, handling the AccountAddress and signing.
AccountAddress is a 32 byte address on the EndlessCoin blockchain It can represent an Object, an Account, and much more.
AdditionalSigners will set the additional signers for a transaction.
ChainIdOption will set the chain ID for a transaction TODO: This one may want to be removed / renamed?.
EstimateGasUnitPrice estimates the gas unit price for a transaction.
EstimateMaxGasAmount estimates the max gas amount for a transaction.
EstimatePrioritizedGasUnitPrice estimates the prioritized gas unit price for a transaction.
ExpirationSeconds will set the number of seconds from the current time to expire a transaction.
GasUnitPrice will set the gas unit price in octas (1/10^8 EDS) for a transaction.
MaxGasAmount will set the max gas amount in gas units for a transaction.
No description provided by the author
PollPeriod is an option to PollForTransactions.
PollTimeout is an option to PollForTransactions.
No description provided by the author
ScriptArgumentVariant the type of the script argument.
SequenceNumber will set the sequence number for a transaction.
SignedTransactionVariant is the variant for a signed transaction.
No description provided by the author
No description provided by the author
TransactionSubmissionType is the counter for an enum.
TypeTagVariant is an enum representing the different types of TypeTag.