Socket
Book a DemoInstallSign in
Socket

@transia/hooks-toolkit

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@transia/hooks-toolkit

A toolkit for interacting with smart contracts (hooks) on the XRP Ledger.

npmnpm
Version
2.0.0-alpha.1
Version published
Weekly downloads
37
Maintainers
1
Weekly downloads
 
Created
Source

The Hooks Toolkit (Typescript)

Global Prerequsits

$ npm i -g c2wasm-cli

Compile Hooks

Run this command to locally compile an XRPL Hook source file (inside ./contracts) from .c to .wasm code:

$ yarn run build:hooks

Here is what each command does in the background:

  • wasmcc - compiles a Hook source file (C code) to WebAssembly (WASM) code. For example, ./contracts/base.c compiles to ./build/base.wasm
  • wasm-opt - optimizes the WASM code ./build/base.wasm
  • hook-cleaner - cleans it by removing unnecessary additional exports
  • guard_checker - this checks if any guard violation has occurred in the Hooks code before submitting it in SetHook transaction. For more information, visit this link
  • Converts the compiled WASM to hexadecimal characters then submits it as payload in a SetHook transaction

You can also build a single hook with;

$ yarn run build:hook contracts/toolbox/base.c build

Debug the test env

tail -f xahau/log/debug.log | grep HookTrace

Test the Hook Library

Run Unit tests

$ yarn run test:unit

Before you can run the integration tests you must have a standalone rippled server running.

  • Full env with explorer:

    • $ xrpld-netgen up:standalone
  • Docker standalone only:

    • $ docker run -p 5005:5005 -p 6006:6006 -it transia/xahaud:latest

Run Integration tests

$ yarn run test:integration

Run single Integration test

$ yarn run test:integration test/integration/toolbox/base.test.ts

Adding a new Hook

  • Add the hook.c file into the contracts directory
  • Build the hooks $ yarn run build:hooks
  • Copy the hook base.test.ts template into the correct folder. (audited/toolbox)
  • Test the hook using: $ yarn run test:integration test/integration/audited/myHook.test.ts

FAQs

Package last updated on 30 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts