sdk

package module
v0.0.0-...-6ee715d Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 4 Imported by: 21

README

Wormhole Software Development Kit

This directory contains libraries in various languages for developing software that interacts with wormhole.

Adding a New ChainID

To add a new ChainID to Wormhole:

  1. Add the constant in vaa/structs.go:

    // ChainIDNewChain is the ChainID of NewChain
    ChainIDNewChain ChainID = 99
    

    Keep constants in numerical order and follow the naming convention.

  2. Regenerate methods by running:

    make go-generate
    

    This runs chainid_generator.go which auto-generates String(), ChainIDFromString(), and GetAllNetworkIDs() methods.

  3. Update other components as needed:

    • Add to governor chain lists (node/pkg/governor/mainnet_chains.go)
    • Add manual tokens if required (node/pkg/governor/manual_tokens.go)
    • Update any chain-specific configuration files
    • Add the ChainID in proto/publicrpc/v1/publicrpc.proto.
    • If watcher support is necessary, update the guardian code.

Directory Structure

  • sdk/: Go SDK. This package must live in this directory so that clients can use the github.com/wormhole-foundation/wormhole/sdk import path.
  • vaa/: Go package for using VAAs (Verifiable Action Approval).
  • js/: Legacy JavaScript SDK (Deprecated and Unsupported)
  • js-proto-node/: NodeJS client protobuf.
  • js-proto-web/: Web client protobuf.
  • js-wasm/: WebAssembly libraries.
  • rust/: Rust SDK.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HeartbeatMessagePrefix = []byte("heartbeat|")

	SignedObservationRequestPrefix_old = []byte("signed_observation_request|")
	SignedObservationRequestPrefix     = []byte("signed_observation_request_000000|")
	SignedWormchainAddressPrefix       = []byte("signed_wormchain_address_00000000|")
)
View Source
var KnownAutomaticRelayerEmitters = []struct {
	ChainId vaa.ChainID
	Addr    string
}{
	{ChainId: vaa.ChainIDEthereum, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDBSC, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDPolygon, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDAvalanche, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDFantom, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDKlaytn, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDCelo, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDMoonbeam, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDArbitrum, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDOptimism, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDBase, Addr: "000000000000000000000000706f82e9bb5b0813501714ab5974216704980e31"},
	{ChainId: vaa.ChainIDScroll, Addr: "00000000000000000000000027428DD2d3DD32A4D7f7C497eAaa23130d894911"},
	{ChainId: vaa.ChainIDMantle, Addr: "00000000000000000000000027428dd2d3dd32a4d7f7c497eaaa23130d894911"},
	{ChainId: vaa.ChainIDXLayer, Addr: "00000000000000000000000027428dd2d3dd32a4d7f7c497eaaa23130d894911"},
	{ChainId: vaa.ChainIDWorldchain, Addr: "0000000000000000000000001520cc9e779c56dab5866bebfb885c86840c33d3"},
	{ChainId: vaa.ChainIDXRPLEVM, Addr: "00000000000000000000000027428dd2d3dd32a4d7f7c497eaaa23130d894911"},
}

KnownAutomaticRelayerEmitters is a list of well-known mainnet emitters for the Automatic Relayers. It is based on this: https://github.com/wormhole-foundation/wormhole/blob/2c9703670eadc48a7dc8967e81ed2823affcc679/sdk/js/src/relayer/consts.ts#L95 Note that the format of this is different from the other maps because we don't want to limit it to one per chain.

View Source
var KnownDevnetAutomaticRelayerEmitters = []struct {
	ChainId vaa.ChainID
	Addr    string
}{
	{ChainId: vaa.ChainIDEthereum, Addr: "000000000000000000000000b98F46E96cb1F519C333FdFB5CCe0B13E0300ED4"},
	{ChainId: vaa.ChainIDBSC, Addr: "000000000000000000000000b98F46E96cb1F519C333FdFB5CCe0B13E0300ED4"},

	{ChainId: vaa.ChainIDEthereum, Addr: "000000000000000000000000cc680d088586c09c3e0e099a676fa4b6e42467b4"},
	{ChainId: vaa.ChainIDBSC, Addr: "000000000000000000000000cc680d088586c09c3e0e099a676fa4b6e42467b4"},
}

KnownDevnetAutomaticRelayerEmitters is a list of well-known devnet emitters for the Automatic Relayers. It is based on this: https://github.com/wormhole-foundation/wormhole/blob/2c9703670eadc48a7dc8967e81ed2823affcc679/sdk/js/src/relayer/consts.ts#L82 Note that the format of this is different from the other maps because we don't want to limit it to one per chain.

View Source
var KnownDevnetCoreContracts = map[vaa.ChainID]string{
	vaa.ChainIDEthereum: "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
}

KnownDevnetCoreContracts is a map of known core contract addresses used during development.

View Source
var KnownDevnetEmitters = buildKnownEmitters(knownDevnetTokenbridgeEmitters, knownDevnetNFTBridgeEmitters)

KnownDevnetEmitters is a list of known emitters used during development.

View Source
var KnownDevnetManagerEmitters = []struct {
	ChainId vaa.ChainID
	Addr    string
}{
	{ChainId: vaa.ChainIDSolana, Addr: "af528793be84ee2c922e2b27b7cae282a4d098f4fe528f35ded8c8c06d0b1090"},
	{ChainId: vaa.ChainIDEthereum, Addr: "00000000000000000000000090F8bf6A479f320ead074411a4B0e7944Ea8c9C1"},
}

KnownDevnetManagerEmitters is a list of known manager emitters used during development. Note that the format allows multiple emitters per chain.

View Source
var KnownDevnetNFTBridgeEmitters = buildEmitterMap(knownDevnetNFTBridgeEmitters)

KnownDevnetNFTBridgeEmitters is a map of known NFT emitters used during development.

View Source
var KnownDevnetTokenbridgeEmitters = buildEmitterMap(knownDevnetTokenbridgeEmitters)

KnownDevnetTokenbridgeEmitters is a map of known tokenbridge emitters used during development.

View Source
var KnownDevnetWrappedNativeAddresses = map[vaa.ChainID]string{

	vaa.ChainIDEthereum: "0xDDb64fE46a91D46ee29420539FC25FD07c5FEa3E",
}

KnownDevnetWrappedNativeAddress is a map of wrapped native addresses by chain ID, e.g. WETH for Ethereum

View Source
var KnownEmitters = buildKnownEmitters(knownTokenbridgeEmitters, knownNFTBridgeEmitters)

KnownEmitters is a list of well-known mainnet emitters we want to take into account when iterating over all emitters - like for finding and repairing missing messages.

Wormhole is not permissioned - anyone can use it. Adding contracts to this list is entirely optional and at the core team's discretion.

View Source
var KnownManagerEmitters = []struct {
	ChainId vaa.ChainID
	Addr    string
}{}

KnownManagerEmitters is a list of known manager emitters on various testnets. Note that the format allows multiple emitters per chain.

View Source
var KnownNFTBridgeEmitters = buildEmitterMap(knownNFTBridgeEmitters)

KnownNFTBridgeEmitters is a list of well-known mainnet emitters for the NFT bridge.

View Source
var KnownTestnetAutomaticRelayerEmitters = []struct {
	ChainId vaa.ChainID
	Addr    string
}{
	{ChainId: vaa.ChainIDEthereum, Addr: "00000000000000000000000028D8F1Be96f97C1387e94A53e00eCcFb4E75175a"},
	{ChainId: vaa.ChainIDBSC, Addr: "00000000000000000000000080aC94316391752A193C1c47E27D382b507c93F3"},
	{ChainId: vaa.ChainIDPolygon, Addr: "0000000000000000000000000591C25ebd0580E0d4F27A82Fc2e24E7489CB5e0"},
	{ChainId: vaa.ChainIDAvalanche, Addr: "000000000000000000000000A3cF45939bD6260bcFe3D66bc73d60f19e49a8BB"},
	{ChainId: vaa.ChainIDCelo, Addr: "000000000000000000000000306B68267Deb7c5DfCDa3619E22E9Ca39C374f84"},
	{ChainId: vaa.ChainIDMoonbeam, Addr: "0000000000000000000000000591C25ebd0580E0d4F27A82Fc2e24E7489CB5e0"},
	{ChainId: vaa.ChainIDArbitrum, Addr: "000000000000000000000000Ad753479354283eEE1b86c9470c84D42f229FF43"},
	{ChainId: vaa.ChainIDOptimism, Addr: "00000000000000000000000001A957A525a5b7A72808bA9D10c389674E459891"},
	{ChainId: vaa.ChainIDBase, Addr: "000000000000000000000000ea8029CD7FCAEFFcD1F53686430Db0Fc8ed384E1"},
	{ChainId: vaa.ChainIDSeiEVM, Addr: "000000000000000000000000362fca37E45fe1096b42021b543f462D49a5C8df"},
	{ChainId: vaa.ChainIDUnichain, Addr: "000000000000000000000000362fca37E45fe1096b42021b543f462D49a5C8df"},
	{ChainId: vaa.ChainIDInk, Addr: "000000000000000000000000362fca37E45fe1096b42021b543f462D49a5C8df"},
	{ChainId: vaa.ChainIDXRPLEVM, Addr: "000000000000000000000000362fca37E45fe1096b42021b543f462D49a5C8df"},
	{ChainId: vaa.ChainIDSepolia, Addr: "0000000000000000000000007B1bD7a6b4E61c2a123AC6BC2cbfC614437D0470"},
	{ChainId: vaa.ChainIDArbitrumSepolia, Addr: "0000000000000000000000007B1bD7a6b4E61c2a123AC6BC2cbfC614437D0470"},
	{ChainId: vaa.ChainIDOptimismSepolia, Addr: "00000000000000000000000093BAD53DDfB6132b0aC8E37f6029163E63372cEE"},
	{ChainId: vaa.ChainIDBaseSepolia, Addr: "00000000000000000000000093BAD53DDfB6132b0aC8E37f6029163E63372cEE"},
}

KnownTestnetAutomaticRelayerEmitters is a list of well-known testnet emitters for the Automatic Relayers. It is based on this: https://github.com/wormhole-foundation/wormhole/blob/2c9703670eadc48a7dc8967e81ed2823affcc679/sdk/js/src/relayer/consts.ts#L14 Note that the format of this is different from the other maps because we don't want to limit it to one per chain.

View Source
var KnownTestnetEmitters = buildKnownEmitters(knownTestnetTokenbridgeEmitters, knownTestnetNFTBridgeEmitters)

KnownTestnetEmitters is a list of known emitters on the various L1 testnets.

View Source
var KnownTestnetManagerEmitters = []struct {
	ChainId vaa.ChainID
	Addr    string
}{
	{ChainId: vaa.ChainIDSolana, Addr: "af528793be84ee2c922e2b27b7cae282a4d098f4fe528f35ded8c8c06d0b1090"},
}

KnownTestnetManagerEmitters is a list of known manager emitters on various testnets. Note that the format allows multiple emitters per chain.

View Source
var KnownTestnetNFTBridgeEmitters = buildEmitterMap(knownTestnetNFTBridgeEmitters)

KnownTestnetNFTBridgeEmitters is a map of known NFT emitters on the various L1 testnets.

View Source
var KnownTestnetTokenbridgeEmitters = buildEmitterMap(knownTestnetTokenbridgeEmitters)

KnownTestnetTokenbridgeEmitters is a map of known tokenbridge emitters on the various L1 testnets.

View Source
var KnownTestnetWrappedNativeAddresses = map[vaa.ChainID]string{

	vaa.ChainIDSepolia: "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",

	vaa.ChainIDHolesky: "0xc8f93d9738e7Ad5f3aF8c548DB2f6B7F8082B5e8",
}

KnownTestnetWrappedNativeAddresses is a list of addresses for deployments of wrapped native asssets (e.g. WETH) on various testnets.

View Source
var KnownTokenbridgeEmitters = buildEmitterMap(knownTokenbridgeEmitters)

KnownTokenbridgeEmitters is a list of well-known mainnet emitters for the tokenbridge.

View Source
var KnownWrappedNativeAddress = map[vaa.ChainID]string{

	vaa.ChainIDEthereum: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
}

KnownWrappedNativeAddress is a map of wrapped native addresses by chain ID, e.g. WETH for Ethereum

View Source
var PublicRPCEndpoints = []string{
	"https://wormhole-v2-mainnet-api.mcf.rocks",
	"https://wormhole-v2-mainnet-api.chainlayer.network",
	"https://wormhole-v2-mainnet-api.staking.fund",
	"https://guardian.mainnet.xlabs.xyz",
}

PublicRPCEndpoints is a list of known public RPC endpoints for mainnet, operated by Wormhole guardian nodes.

This list is duplicated a couple times across the codebase - make sure to update all copies!

Functions

func GetEmitterAddressForChain

func GetEmitterAddressForChain(chainID vaa.ChainID, emitterType EmitterType) (vaa.Address, error)

func GetTokenBridgeEmitters

func GetTokenBridgeEmitters(env Environment) map[vaa.ChainID][]byte

GetTokenBridgeEmitters returns the token bridge emitter map for the given environment. Returns nil for test/mock environments (EnvGoTest, EnvAccountantMock).

func IsWTT

func IsWTT(v *vaa.VAA, env Environment) bool

IsWTT checks if the VAA represents a valid wrapped token transfer for a given environment. It verifies: 1. The payload is a transfer (payload type 1 or 3) via vaa.IsTransfer 2. The emitter is a known token bridge emitter for the specified environment

This function validates WTTs with respect to an environment's known token bridge emitters. For a context-free check that only verifies the payload type, use vaa.IsTransfer instead.

Returns false for test/mock environments (EnvGoTest, EnvAccountantMock) and if either check fails.

Note: This function uses the same validation logic as MessagePublication.IsWTT.

Types

type EmitterInfo

type EmitterInfo struct {
	ChainID    vaa.ChainID
	Emitter    string
	BridgeType EmitterType
}

type EmitterType

type EmitterType uint8
const (
	EmitterTypeUnset   EmitterType = 0
	EmitterCoreBridge  EmitterType = 1
	EmitterTokenBridge EmitterType = 2
	EmitterNFTBridge   EmitterType = 3
)

func (EmitterType) String

func (et EmitterType) String() string

type Environment

type Environment uint8

Environment represents the Wormhole network environment

const (
	EnvMainNet Environment = iota
	EnvTestNet
	EnvDevNet
	EnvGoTest
	EnvAccountantMock
)

func EnvironmentFromString

func EnvironmentFromString(env string) Environment

EnvironmentFromString converts a common.Environment string to sdk.Environment. This helper is useful for node code that needs to convert between the two types.

func (Environment) String

func (e Environment) String() string

String returns the string representation of the Environment. The output corresponds to the input format used by EnvironmentFromString.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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