@shodai-network/agreements-protocol-evm
v0.1.4
Published
TypeScript SDK for the Agreements Protocol
Readme
Agreements Protocol - TypeScript SDK
This directory contains the TypeScript SDK for transforming agreement JSON into on-chain parameters and interacting with deployed agreement contracts.
This package is licensed under Apache-2.0. It is intended to remain redistributable independently of the BUSL-licensed core contract implementations.
Setup
npm ciThe SDK build inlines ABIs and deployment metadata from ../contracts, so compile the contracts first in a fresh clone:
npm --prefix ../contracts run compileDevelopment
Build
npm run buildRun Tests
npm run testWatch Mode
npm run test:watchUsage
Once built, you can import and use the SDK.
Creating Agreements
import { AgreementFactory } from "@shodai-network/agreements-protocol-evm";
import { createPublicClient, createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const publicClient = createPublicClient({
transport: http("http://127.0.0.1:8545"),
});
const walletClient = createWalletClient({
account: privateKeyToAccount("0x..."),
transport: http("http://127.0.0.1:8545"),
});
const factory = new AgreementFactory(
{ factoryAddress: "0x..." },
{ publicClient, walletClient },
);
const { address } = await factory.createAgreement(agreementJson, {
initValues: {
grantorEthAddress: "0x123...",
recipientEthAddress: "0x456...",
},
});Interacting With Agreements
import { AgreementEngine } from "@shodai-network/agreements-protocol-evm";
import { createPublicClient, createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
const publicClient = createPublicClient({
transport: http("http://127.0.0.1:8545"),
});
const walletClient = createWalletClient({
account: privateKeyToAccount("0x..."),
transport: http("http://127.0.0.1:8545"),
});
const agreement = new AgreementEngine("0x...", publicClient, walletClient);
await agreement.submitInput(agreementJson, "grantorData", {
grantorName: "Alice",
scope: "Development of Web3 tooling",
});
const readOnlyAgreement = new AgreementEngine("0x...", publicClient);
const state = await readOnlyAgreement.getCurrentState();
const data = await readOnlyAgreement.getData();License
The SDK package is licensed under Apache-2.0. See LICENSE, NOTICE, ../licenses/Apache-2.0.txt, and ../LICENSING.md.
