blockchain

package
v0.17.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 28 Imported by: 18 modules, 57 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultAnvilPrivateKey = `ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80`
	AnvilPrivateKey1       = `0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d`
	AnvilPrivateKey2       = `0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a`
	AnvilPrivateKey3       = `0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6`
	AnvilPrivateKey4       = `0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a`
	DefaultAnvilPublicKey  = `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266`
	AnvilPublicKey1        = `0x70997970C51812dc3A010C7d01b50e0d17dc79C8`
	AnvilPublicKey2        = `0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC`
	AnvilPublicKey3        = `0x90F79bf6EB2c4f870365E785982E1f101E93b906`
	AnvilPublicKey4        = `0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65`
)
View Source
const (
	DefaultAptosAPIPort     = "8080"
	DefaultAptosFaucetPort  = "8081"
	DefaultAptosArm64Image  = "ghcr.io/friedemannf/aptos-tools:aptos-node-v1.42.1"
	DefaultAptosX86_64Image = "aptoslabs/tools:aptos-node-v1.42.1"
)
View Source
const (
	DefaultBesuPrivateKey1 = "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63"
	DefaultBesuPrivateKey2 = "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3"
	DefaultBesuPrivateKey3 = "ae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f"
	DefaultBesuPublicKey1  = "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
	DefaultBesuPublicKey2  = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57"
	DefaultBesuPublicKey3  = "0xf17f52151EbEF6C7334FAD080c5704D77216b732"
)
View Source
const (
	TypeAnvil       = "anvil"
	TypeAnvilZKSync = "anvil-zksync"
	TypeGeth        = "geth"
	TypeBesu        = "besu"
	TypeSolana      = "solana"
	TypeAptos       = "aptos"
	TypeSui         = "sui"
	TypeTron        = "tron"
	TypeTon         = "ton"
	TypeCanton      = "canton"
	TypeStellar     = "stellar"
)

Blockchain node type

View Source
const (
	FamilyEVM     = "evm"
	FamilySolana  = "solana"
	FamilyAptos   = "aptos"
	FamilySui     = "sui"
	FamilyTron    = "tron"
	FamilyTon     = "ton"
	FamilyCanton  = "canton"
	FamilyStellar = "stellar"
)

Blockchain node family

View Source
const (
	// DefaultCantonPort is a default Canton container port
	DefaultCantonPort = "8080"
	// TokenExpiry is JWT token expiry
	TokenExpiry = time.Hour * 24 * 365 * 10 // 10 years
)
View Source
const (
	RootFundingAddr   = `0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266`
	RootFundingWallet = `` /* 491-byte string literal not displayed */
	GenesisClique     = `` /* 919-byte string literal not displayed */

	DefaultGethPrivateKey = `ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80`
	DefaultGethPublicKey  = `0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266`
)
View Source
const (
	// DefaultSolanaPrivateKey is the base58-encoded private key matching the keypair
	// written to the test validator's /root/.config/solana/cli/id.json.
	// The corresponding public key is DefaultSolanaPublicKey.
	DefaultSolanaPrivateKey = "DmPfeHBC8Brf8s5qQXi25bmJ996v6BHRtaLc6AH51yFGSqQpUMy1oHkbbXobPNBdgGH2F29PAmoq9ZZua4K9vCc"
	// DefaultSolanaPublicKey is the public key derived from DefaultSolanaPrivateKey.
	DefaultSolanaPublicKey = "9n1pyVGGo6V4mpiSDMVay5As9NurEkY283wwRk1Kto2C"
)
View Source
const (
	// DefaultStellarImage is the official Stellar quickstart image for local development.
	// Pinned to a specific multi-arch (amd64+arm64) per-commit tag instead of :latest so test
	// runs are reproducible and a quickstart release cannot silently change flags/ports.
	// https://github.com/stellar/quickstart
	DefaultStellarImage = "stellar/quickstart:v667-b1428.1-latest"

	// DefaultStellarRPCPort is the port the quickstart unified HTTP gateway listens on.
	// The gateway multiplexes by path: Horizon at "/", Soroban RPC at "/rpc", Friendbot at "/friendbot".
	DefaultStellarRPCPort = "8000"

	// DefaultStellarFriendbotPort is the port the Friendbot faucet is served on.
	//
	// Deprecated: Friendbot shares the quickstart unified gateway on DefaultStellarRPCPort
	// (8000) at path "/friendbot", so this constant is redundant. It is retained for
	// backwards compatibility with external callers that may reference it. New code should
	// use DefaultStellarRPCPort, or derive the Friendbot URL from Output.NetworkSpecificData.StellarNetwork.FriendbotURL.
	DefaultStellarFriendbotPort = "8000"

	// DefaultStellarNetworkPassphrase is the network passphrase for local standalone network
	// https://stellar.org/developers/guides/concepts/networks
	DefaultStellarNetworkPassphrase = "Standalone Network ; February 2017"
)
View Source
const (
	DefaultFaucetPort    = "9123/tcp"
	DefaultFaucetPortNum = "9123"
	DefaultSuiNodePort   = "9000"
	// DefaultSuiImage is the mysten/sui-tools image when Input.Image is empty on non-arm64 hosts.
	DefaultSuiImage = "mysten/sui-tools:devnet-v1.73.0"
	// DefaultSuiImageARM64 is used when Input.Image is empty on arm64 (e.g. Apple Silicon).
	DefaultSuiImageARM64 = "mysten/sui-tools:ci-arm64"
)
View Source
const (
	// NOTE: Prefunded high-load wallet from MyLocalTon pre-funded wallet, that can send up to 254 messages per 1 external message
	// https://docs.ton.org/v3/documentation/smart-contracts/contracts-specs/highload-wallet#highload-wallet-v2
	DefaultTonHlWalletAddress  = "-1:5ee77ced0b7ae6ef88ab3f4350d8872c64667ffbe76073455215d3cdfab3294b"
	DefaultTonHlWalletMnemonic = "" /* 157-byte string literal not displayed */

)
View Source
const (
	DefaultTronPort = "9090"
)
View Source
const DefaultUbuntuCACertificatePath = "/etc/ssl/certs/ca-certificates.crt"

Variables

View Source
var (
	DefaultAptosAccount    = "0xa337b42bd0eecf8fb59ee5929ea4541904b3c35a642040223f3d26ab57f59d6e"
	DefaultAptosPrivateKey = "0xd477c65f88ed9e6d4ec6e2014755c3cfa3e0c44e521d0111a02868c5f04c41d4"
)
View Source
var AnvilZKSyncRichAccountPks = []string{
	"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
	"59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
	"5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
	"7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6",
	"47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a",
	"8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba",
	"92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e",
	"4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356",
	"dbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97",
	"2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
}
View Source
var TRONAccounts = Accounts{
	HDPath:   "m/44'/195'/0'/0/",
	Mnemonic: "resemble birth wool happy sun burger fatal trumpet globe purity health ritual",
	PrivateKeys: []string{
		"932a39242805a1b1095638027f26af9664d1d5bf8ab3b7527ee75e7efb2946dd",
		"1c17c9c049d36cde7e5ea99df6c86e0474b04f0e258ab619a1e674f397a17152",
		"458130a239671674746582184711a6f8d633355df1a491b9f3b323576134c2e9",
		"2676fd1427968e07feaa9aff967d4ba7607c5497c499968c098d0517cd75cfbb",
		"d26b24a691ff2b03ee6ab65bf164def216f73574996b9ca6299c43a9a63767ac",
		"55df6adf3d081944dbe4688205d94f236fb4427ac44f3a286a96d47db0860667",
		"8a9a60ddd722a40753c2a38edd6b6fa38e806d681c9b08a520ba4912e62b6458",
		"75eb182fb623acf5e53d9885c4e8578f2530533a96c753481cc4277ecc6022de",
		"6c4b22b1d9d68ef7a8ecd151cd4ffdd4ecc2a7b3a3f8a9f9f9bbdbcef6671f10",
		"e578d66453cb41b6c923b9caa91c375a0545eeb171ccafc60b46fa834ce5c200",
	},

	More: []string{},
}

Functions

func VerifyContract added in v0.1.17

func VerifyContract(out *Output, address, foundryDir, contractFile, contractName, compilerVersion string) error

VerifyContract wraps the forge verify-contract command.

Types

type Accounts added in v0.1.17

type Accounts struct {
	HDPath      string   `json:"hdPath"`
	Mnemonic    string   `json:"mnemonic"`
	PrivateKeys []string `json:"privateKeys"`
	More        []string `json:"more"`
}

type CantonData added in v0.15.0

type CantonData struct {
	// Docker internal endpoints, only reachable if connected to the same Docker network (framework.DefaultNetworkName)
	InternalEndpoints CantonEndpoints `toml:"internal_endpoints" comment:"Docker-internal endpoints, only reachable from containers connected to the same networks"`
	// External endpoints, reachable from the Docker host
	ExternalEndpoints CantonEndpoints `toml:"external_endpoints" comment:"Docker-external endpoints, only reachable from the Docker host"`
}

type CantonEndpoints added in v0.13.0

type CantonEndpoints struct {
	// ScanAPIURL https://docs.sync.global/app_dev/scan_api/index.html
	ScanAPIURL string `toml:"scan_api_url" comment:"https://docs.sync.global/app_dev/scan_api/index.html"`
	// RegistryAPIURL https://docs.sync.global/app_dev/token_standard/index.html#api-references
	RegistryAPIURL string `toml:"registry_api_url" comment:"https://docs.sync.global/app_dev/token_standard/index.html#api-references"`

	// SuperValidator The endpoints for the super validator
	SuperValidator CantonParticipantEndpoints `toml:"super_validator" comment:"Canton super validator endpoints"`
	// Participants The endpoints for the participants, in order from participant1 to participantN - depending on the number of validators requested
	Participants []CantonParticipantEndpoints `toml:"participants" comment:"Canton participant endpoints"`
}

type CantonParticipantEndpoints added in v0.13.0

type CantonParticipantEndpoints struct {
	// JSONLedgerAPIURL https://docs.digitalasset.com/build/3.5/reference/json-api/json-api.html
	JSONLedgerAPIURL string `toml:"json_ledger_api_url" comment:"https://docs.digitalasset.com/build/3.5/reference/json-api/json-api.html"`
	// GRPCLedgerAPIURL https://docs.digitalasset.com/build/3.5/reference/lapi-proto-docs.html
	GRPCLedgerAPIURL string `toml:"grpc_ledger_api_url" comment:"https://docs.digitalasset.com/build/3.5/reference/lapi-proto-docs.html"`
	// AdminAPIURL https://docs.digitalasset.com/operate/3.5/howtos/configure/apis/admin_api.html
	AdminAPIURL string `toml:"admin_api_url" comment:"https://docs.digitalasset.com/operate/3.5/howtos/configure/apis/admin_api.html"`
	// ValidatorAPIURL https://docs.sync.global/app_dev/validator_api/index.html
	ValidatorAPIURL string `toml:"validator_api_url" comment:"https://docs.sync.global/app_dev/validator_api/index.html"`

	// HTTPHealthCheckURL responds on GET /health
	HTTPHealthCheckURL string `toml:"http_health_check_url" comment:"HTTP health check endpoint, responds on GET /health"`
	// GRPCHealthCheckURL grpc.health.v1.Health/Check
	GRPCHealthCheckURL string `toml:"grpc_health_check_url" comment:"GRPC health check endpoint, responds to grpc.health.v1.Health/Check"`

	// UserID is the user id associated with this participant, the JWT will have a subject claim set for this user.
	UserID string `toml:"user_id" comment:"the user id associated with this participant, used in the JWT token"`
	// JWT JSON Web Token for this participant
	JWT string `toml:"jwt" comment:"JSON Web Token for this participant"`
}

type ChainFamily added in v0.10.31

type ChainFamily string

func TypeToFamily added in v0.10.31

func TypeToFamily(t string) (ChainFamily, error)

type ExposeWs added in v0.1.17

type ExposeWs = bool
const (
	WithWsEndpoint    ExposeWs = true
	WithoutWsEndpoint ExposeWs = false
)

type Input

type Input struct {
	// Common EVM fields
	Type          string `` /* 282-byte string literal not displayed */
	Image         string `toml:"image" comment:"Blockchain node image in format: $registry:$image, ex.: ghcr.io/foundry-rs/foundry:stable"`
	PullImage     bool   `toml:"pull_image" comment:"Whether to pull image or not when creating Docker container"`
	Port          string `toml:"port" comment:"The port Docker container will expose"`
	ContainerName string `toml:"container_name" comment:"Docker container name"`
	// Not applicable to Solana, ws port for Solana is +1 of port
	WSPort                   string   `toml:"port_ws" comment:"WebSocket port container will expose"`
	ChainID                  string   `toml:"chain_id" comment:"Blockchain chain ID"`
	DockerCmdParamsOverrides []string `toml:"docker_cmd_params" comment:"Docker command parameters override, ex. for Anvil: [\"-b\", \"1\", \"--mixed-mining\"]"`
	Out                      *Output  `toml:"out" comment:"blockchain deployment output"`

	// Solana fields
	// publickey to mint when solana-test-validator starts
	PublicKey    string `toml:"public_key" comment:"Public key to mint when solana-test-validator starts"`
	ContractsDir string `toml:"contracts_dir" comment:"Solana's contracts directory"`
	// programs to deploy on solana-test-validator start
	// a map of program name to program id
	// there needs to be a matching .so file in contracts_dir
	SolanaPrograms     map[string]string             `` /* 141-byte string literal not displayed */
	ContainerResources *framework.ContainerResources `toml:"resources" comment:"Docker container resources"`
	CustomPorts        []string                      `toml:"custom_ports" comment:"Custom ports pairs in format $host_port_number:$docker_port_number"`

	// Sui specific: faucet port for funding accounts
	FaucetPort string `toml:"faucet_port" comment:"Sui blockchain network faucet port"`

	// Canton specific
	NumberOfCantonValidators int `toml:"number_of_canton_validators" comment:"Number of Canton network validators"`

	// GAPv2 specific params
	HostNetworkMode  bool   `` /* 132-byte string literal not displayed */
	CertificatesPath string `toml:"certificates_path" comment:"GAPv2 specific parameter: path to default Ubuntu's certificates"`

	// Optional params
	ImagePlatform *string `toml:"image_platform" comment:"Docker image platform, default is 'linux/amd64'"`
	// Custom environment variables for the container
	CustomEnv map[string]string `toml:"custom_env" comment:"Docker container environment variables in TOML format key = value"`
}

Input is a blockchain network configuration params

type NetworkSpecificData added in v0.1.17

type NetworkSpecificData struct {
	SuiAccount     *SuiWalletInfo      `toml:"sui_account" comment:"Sui network account info"`
	CantonData     *CantonData         `toml:"canton_data" comment:"Canton network data"`
	StellarNetwork *StellarNetworkInfo `toml:"stellar_network" comment:"Stellar network info"`
}

type Node

type Node struct {
	ExternalWSUrl   string `toml:"ws_url" comment:"External blockchain node WebSocket URL"`
	ExternalHTTPUrl string `toml:"http_url" comment:"External blockchain node HTTP URL"`
	InternalWSUrl   string `toml:"internal_ws_url" comment:"Internal blockchain node WebSocket URL"`
	InternalHTTPUrl string `toml:"internal_http_url" comment:"Internal blockchain node HTTP URL"`
	// K8sService is a Kubernetes service spec used to connect locally
	K8sService *v1.Service `toml:"k8s_service" comment:"Kubernetes service spec used to connect locally"`
}

Node represents blockchain node output, URLs required for connection locally and inside docker network

type Output

type Output struct {
	UseCache            bool                     `toml:"use_cache" comment:"Whether to respect caching or not, if cache = true component won't be deployed again"`
	Type                string                   `` /* 178-byte string literal not displayed */
	Family              string                   `toml:"family" comment:"Blockchain family, can be one of: evm solana aptos sui tron ton canton stellar"`
	ContainerName       string                   `toml:"container_name" comment:"Blockchain Docker container name"`
	NetworkSpecificData *NetworkSpecificData     `toml:"network_specific_data" comment:"Blockchain network-specific data"`
	Container           testcontainers.Container `toml:"-"`
	ChainID             string                   `toml:"chain_id" comment:"Chain ID"`
	Nodes               []*Node                  `toml:"nodes" comment:"Blockchain nodes info"`
}

Output is a blockchain network output, ChainID and one or more nodes that forms the network

func NewBlockchainNetwork

func NewBlockchainNetwork(in *Input) (*Output, error)

func NewWithContext added in v0.11.6

func NewWithContext(ctx context.Context, in *Input) (*Output, error)

NewBlockchainNetwork this is an abstraction that can spin up various blockchain network simulators

type StellarNetworkInfo added in v0.13.14

type StellarNetworkInfo struct {
	NetworkPassphrase string `toml:"network_passphrase" json:"networkPassphrase" comment:"Stellar network passphrase"`
	FriendbotURL      string `toml:"friendbot_url" json:"friendbotUrl" comment:"Friendbot faucet URL for funding accounts"`
}

StellarNetworkInfo contains Stellar network-specific configuration

type SuiWalletInfo added in v0.1.17

type SuiWalletInfo struct {
	Alias           *string `toml:"alias" json:"alias" comment:"Alias key name, usually null"`                   // Alias key name, usually "null"
	Flag            int     `toml:"flag" json:"flag" comment:"-"`                                                // Flag is an integer
	KeyScheme       string  `toml:"key_scheme" json:"keyScheme" comment:"Sui key scheme"`                        // Key scheme is a string
	Mnemonic        string  `toml:"mnemonic" json:"mnemonic" comment:"Sui key mnemonic"`                         // Mnemonic is a string
	PeerId          string  `toml:"peer_id" json:"peerId" comment:"Sui key peer ID"`                             // Peer ID is a string
	PublicBase64Key string  `toml:"public_base64_key" json:"publicBase64Key" comment:"Sui key in base64 format"` // Public key in Base64 format
	SuiAddress      string  `toml:"sui_address" json:"suiAddress" comment:"Sui key address"`                     // Sui address is a 0x prefixed hex string
}

SuiWalletInfo info about Sui account/wallet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL