@mayflower-sys/evm-avm-sdk
v202607.1306.150
Published
EVM AVM SDK for interacting with the Mayflower AVMs on EVM chains.
Readme
@mayflower-sys/evm-avm-sdk
A small, transport-agnostic TypeScript SDK for the AVM on EVM. It packs
instructions and reads into plain { to, data } payloads and decodes the
results — it never touches the network itself. Bring your own
viem client (or any RPC transport) to actually send them.
The core idea
Everything the SDK produces is pure data, so you can log, cache, batch, or simulate it before it ever leaves your process:
PackedTx—{ to, data }, ready to hand to a wallet'ssendTransaction.PackedCall<A>—{ to, data, decode }, ready for aneth_call;decodeturns the returned bytes into a typed value.
What's inside
| Namespace | What it does |
| --------------------------- | ---------------------------------------------------------------------- |
| Ix | Instruction packers. Ix.<Op>.pack(args) returns a PackedTx. |
| Entities | Read helpers. Entities.<T>.fetchMsg(...) returns a PackedCall. |
| Events | Decode a receipt's logs into a typed, tagged union of events. |
| Fixed18 / SignedFixed18 | 18-decimal fixed-point helpers (mirror the on-chain libraries). |
| Util | Small helpers, e.g. strToBytes32 to hash a string into a bytes32 id. |
Sending a transaction
import { Ix } from "@mayflower-sys/evm-avm-sdk"
import { createWalletClient, http } from "viem"
const wallet = createWalletClient({ account, chain, transport: http(rpcUrl) })
// Pack a "buy shares" instruction — pure, no I/O.
const tx = Ix.IssueSharesWithExactReserveIn.pack({
market,
exactReserveIn: 1_000_000n, // reserve tokens to spend (raw, token decimals)
minSharesOut: 0n, // slippage floor
receiver: account.address,
})
// Send it with your own transport.
const hash = await wallet.sendTransaction(tx)Reading state
import { Entities } from "@mayflower-sys/evm-avm-sdk"
import { createPublicClient, http } from "viem"
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) })
const call = Entities.Market.fetchMsg(marketAddress)
const { data } = await publicClient.call({ to: call.to, data: call.data })
const market = call.decode(data!) // typed Market snapshotDecoding events
import { Events } from "@mayflower-sys/evm-avm-sdk"
const receipt = await publicClient.waitForTransactionReceipt({ hash })
const events = Events.decodeEvents(receipt) // all emitter events, tagged
const bought = Events.findEvent(receipt, "AvmTokensBought") // one by tag (throws if absent)License
FSL-1.1-MIT.
