@telaro/erc8004-bridge
v0.1.2
Published
JavaScript SDK for the Telaro ERC-8004 bridge. Decode Wormhole payloads published by Telaro's Solana program, encode receivePublish calldata for TelaroErc8004Receiver on EVM, and derive the Solana emitter address that anchors the trust path.
Downloads
444
Maintainers
Readme
@telaro/erc8004-bridge
JavaScript SDK for the Telaro ERC-8004 bridge. Decode Wormhole payloads
published by the Telaro Solana program, encode receivePublish calldata
for the TelaroErc8004Receiver Solidity contract on EVM, and derive the
canonical Solana emitter address that anchors the trust path.
Install
pnpm add @telaro/erc8004-bridge @solana/web3.js
# optional, only if you use encodeReceivePublishCalldata
pnpm add viemWhat this does
The Telaro Solana program (programs/telaro/src/instructions/register_to_erc8004.rs)
publishes a Wormhole message every time an agent registers or updates
its on-chain score. The receiver contract on Base
(packages/erc8004-bridge/evm/src/TelaroErc8004Receiver.sol) verifies
the VAA, mints or updates the corresponding ERC-8004 IdentityRegistry
entry, and writes a bonded feedback into the ReputationRegistry.
This SDK lets external relayers and indexers talk to that pipeline without forking the contract code.
Surface
import {
// emitter derivation
findEmitterPda,
pubkeyToBytes32,
// payload codec
encodePublishPayload,
decodePublishPayload,
type PublishPayload,
// calldata builder
encodeReceivePublishCalldata,
// ABI fragments for event filters
RECEIVER_ABI_FRAGMENTS,
} from "@telaro/erc8004-bridge";Derive the emitter address
import { PublicKey } from "@solana/web3.js";
import { findEmitterPda, pubkeyToBytes32 } from "@telaro/erc8004-bridge";
const TELARO_PROGRAM = new PublicKey("3DUrvVWEziYLtEbiDtfxqh1ioXRFX6DNvV4iTsGed2rs");
const [emitter] = findEmitterPda(TELARO_PROGRAM);
console.log("solanaEmitter:", pubkeyToBytes32(emitter));Decode a VAA payload
import { decodePublishPayload } from "@telaro/erc8004-bridge";
const decoded = decodePublishPayload(vaaPayloadBytes);
console.log("agent:", decoded.agentPda);
console.log("score:", decoded.score);
console.log("bond:", decoded.bondAtomic.toString());
console.log("uri:", decoded.agentUri);Submit a VAA to the receiver
import { encodeReceivePublishCalldata } from "@telaro/erc8004-bridge";
const data = await encodeReceivePublishCalldata(encodedVm);
await wallet.sendTransaction({
to: TELARO_RECEIVER_ADDRESS,
data,
value: 0n,
});Payload layout
The bytes the Solana program emits inside the Wormhole VAA payload:
| Offset | Size | Field | |---|---|---| | 0 | 1 | version u8 | | 1 | 32 | agent_pda bytes32 | | 33 | 20 | evm_address | | 53 | 2 | score u16 BE | | 55 | 8 | bond_atomic u64 BE | | 63 | 4 | agent_uri_len u32 BE | | 67 | N | agent_uri utf-8 |
Total: 67 + N bytes. The encode + decode helpers in this package are
the JS mirror of _decodePayload in TelaroErc8004Receiver.sol.
