Nomad SDK
This package includes the NomadContext
, a management system for Nomad core
contracts, which inherits from the MultiProvider
. NomadContext
allows
developers to easily interact with the Nomad system on any number of networks.
Documentation
- Multi Provider
- Nomad SDK
- Example: SDK Quick Start
Setup (front-end only)
Configure webpack with wasm
, syncWebAssembly
and topLevelAwait
:
module: {
rules: [
{
test: /\.wasm$/,
type: 'webassembly/sync',
},
],
},
experiments: {
syncWebAssembly: true,
topLevelAwait: true,
},
Intended Usage
Instantiate a NomadContext:
// sdk includes a wasm module, so must await the import
const { NomadContext } = await import('@nomad-xyz/sdk')
type Env = 'production' | 'development'
const environment: Env = 'development'
// instantiate a preconfigured NomadContext
const nomadContext = await NomadContext.fetch(environment)
Commonly used methods:
// register custom rpc provider
nomadContext.registerRpcProvider('ethereum', 'https://...')
// register signer
nomadContext.registerSigner('ethereum', someSigner)
// convert domain name to domain ID
nomadContext.resolveDomain('ethereum') // nomad domain ID: 6648936
// convert domain ID to domain name
nomadContext.resolveDomainName(6648936) // nomad domain name: ethereum
// get the core nomad contracts for a given domain
nomadContext.getCore('ethereum')
// get the replica contract for ethereum on moonbeam
nomadContext.mustGetReplicaFor('moonbeam', 'ethereum')
// check liveness
nomadContext.checkHomes(['ethereum', 'moonbeam'])
nomadContext.blacklist() // returns set of down networks, if any
Fetch a NomadMessage
import { NomadMessage } from '@nomad-xyz/sdk'
const message = await NomadMessage.baseSingleFromTransactionHash(nomadContext, 'ethereum', '0x1234...')
// get the status of a message (NOT RECOMMENDED FOR USAGE IN PRODUCTION)
// 1 = dispatched
// 2 = included
// 3 = relayed
// 4 = processed
const status = await message.status()
// get a timestamp (in seconds) when a message will be ready to process
// on the destination
const confirmAt = await message.confirmAt()
// manually claim on destination after latency period
// Ethereum destination only
const receipt = await message.process()
const processTx = await message.getProcess()
Building
yarn build