Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T
## Added

- Add e2e tests for external signer flow (build → getSigningMessage → sign externally → submit) to verify the flow works correctly with the latest SDK version
- Add ABI JSON generation tool: `generateModuleAbiJSON`, `generateEntryFunctionAbiJSON`, `generateViewFunctionAbiJSON` to fetch on-chain module ABIs and produce JSON-serializable output; `parseEntryFunctionAbiJSON` and `parseViewFunctionAbiJSON` to hydrate them back into SDK-native `EntryFunctionABI`/`ViewFunctionABI` types
- Add `@aptos-labs/generate-abi-json` standalone CLI package (available via `npx @aptos-labs/generate-abi-json`) to generate ABI JSON from on-chain state without writing code
- Add MultiKey (K-of-N mixed key types) transfer example (`examples/typescript/multikey_transfer.ts`)
- Add MultiEd25519 (K-of-N Ed25519) transfer example (`examples/typescript/multi_ed25519_transfer.ts`)

Expand Down
59 changes: 59 additions & 0 deletions packages/generate-abi-json/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# @aptos-labs/generate-abi-json

CLI tool to generate JSON-serializable entry/view function ABIs from on-chain Aptos Move modules. The generated JSON can be embedded in application source code and used with the Aptos TypeScript SDK to skip remote ABI fetching at runtime.

## Usage

```bash
npx @aptos-labs/generate-abi-json --address 0x1 --module coin --pretty
```

### Options

| Flag | Description |
|------|-------------|
| `--network <network>` | Network to connect to: `mainnet`, `testnet`, `devnet`, `local` (default: `mainnet`) |
| `--node-url <url>` | Custom fullnode URL (overrides `--network`; include `/v1`) |
| `--address <address>` | Account address of the module (required) |
| `--module <name>` | Module name (required) |
| `--function <name>` | Specific function name (omit to output all functions) |
| `--output <file>` | Write JSON to a file instead of stdout |
| `--pretty` | Pretty-print JSON with 2-space indentation |
| `--help` | Show help message |

### Examples

```bash
# All entry/view ABIs for the coin module on mainnet
npx @aptos-labs/generate-abi-json --address 0x1 --module coin --pretty

# Single entry function, written to a file
npx @aptos-labs/generate-abi-json --address 0x1 --module coin --function transfer --output coin_transfer.json

# Use testnet
npx @aptos-labs/generate-abi-json --network testnet --address 0x1 --module coin

# Use a custom node URL
npx @aptos-labs/generate-abi-json --node-url http://localhost:8080/v1 --address 0x1 --module coin
```

## Using the output with the SDK

```typescript
import { parseEntryFunctionAbiJSON } from "@aptos-labs/ts-sdk";
import coinAbi from "./coin-abi.json";

// Parse the JSON back into an SDK-native EntryFunctionABI
const transferAbi = parseEntryFunctionAbiJSON(coinAbi.entryFunctions.transfer);

// Use it to build transactions without remote ABI fetching
const txn = await aptos.transaction.build.simple({
sender: alice.accountAddress,
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [bob.accountAddress, 100],
abi: transferAbi,
},
});
```
27 changes: 27 additions & 0 deletions packages/generate-abi-json/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@aptos-labs/generate-abi-json",
"version": "0.1.0",
"description": "CLI tool to generate JSON-serializable entry/view function ABIs from on-chain Aptos Move modules",
"license": "Apache-2.0",
"packageManager": "pnpm@10.30.3",
"engines": {
"node": ">=20.0.0"
},
"bin": {
"generate-abi-json": "dist/index.js"
},
"files": [
"dist"
],
"scripts": {
"build:clean": "rm -rf dist",
"build": "pnpm build:clean && tsup"
},
"dependencies": {
"@aptos-labs/ts-sdk": ">=6.2.0"
},
"devDependencies": {
"tsup": "^8.5.1",
"typescript": "^5.9.3"
}
}
Loading
Loading