@therootnetwork/extrinsic
Sugar over
api.tx.X.Y(...).signAndSend(...): builds, signs, optionally fee-proxies, and waits for finalisation.
Vendor-neutral, on-chain only
Published under @therootnetwork. These talk directly to TRN nodes (WS or HTTPS) — no hosted Futureverse service in the path — so they are the safest dependency to take for projects that need to outlive the Futureverse company.
- Version
2.0.0- Published
- 2025-07-18
- License
- Apache-2.0
- Status
trn-active- npm
- https://www.npmjs.com/package/@therootnetwork/extrinsic
- Types
./dist/index.d.ts- Maintainers
- karishma09, aidan-starke, zees-fv, kenvu-ai
- Depends on
@ethersproject/signing-key·codechain-primitives·ethers·neverthrow·ripple-keypairs- Peer deps
@polkadot/api·@polkadot/keyring·@polkadot/types·@polkadot/types-codec·@polkadot/util·@polkadot/util-crypto·@therootnetwork/api·@therootnetwork/api-types·xrpl- Recent versions
1.0.7·1.0.8·1.0.9·1.0.10·1.0.11-next.0·1.0.11·1.0.12·2.0.0
Why use it
You want a single async call that submits an extrinsic and resolves on finalised success — without manually subscribing to extrinsic status. Especially handy when paying fees in a non-XRP token via FeeProxy.
When to skip it
You need fine-grained control over status events (e.g. you watch Ready → InBlock → Finalized and surface UI between).
Pairs with
@therootnetwork/api— underlying api@therootnetwork/api-types— type lookups
Alternatives
manualsignAndSendwith status callback(works) — finer-grained, more code
Example
import { sendExtrinsic } from '@therootnetwork/extrinsic';
const tx = api.tx.assets.transfer(2 /* XRP */, recipient, 1_000_000n);
const result = await sendExtrinsic(api, tx, signer, { feeAssetId: 1 /* pay in ROOT */ });
console.log(result.txHash, result.events);Gotchas
- Wraps the call in
feeProxy.callWithFeePreferenceswhenfeeAssetIdis set — the inner extrinsic must be a single call, not a batch wrapper.
Upstream README
@therootnetwork/extrinsic
A utility package that makes submitting extrinsic on the Root Network as easy as 🥧
Features
- Wrap extrinsic with FuturePass and Fee Proxy calls.
- Sign extrinsic with native (Keyring), Ethereum and Xaman wallets.
- Estimate extrinsic with any token.
Install
yarn add @polkadot/api @therootnetwork/api @therootnetwork/extrinsic
yarn add -D @therootnetwork/api-types # optional, for Typescript supportUsage
import "@therootnetwork/api-types"; // optional, for Typescript support
import { getApiOptions, getPublicProvider } from "@therootnetwork/api";
import { futurepassWrapper, feeProxyWrapper, nativeWalletSigner } from "@therootnetwork/api";
const api = await ApiPromise.create({
...getApiOptions(),
...getPublicProvider("root"),
});
const senderAddress = "0x25451A4de12dcCc2D166922fA938E900fCc4ED24";
const ROOT_ASSET_ID = 1;
const { estimate, signAndSend } = createDispatcher(
api,
senderAddress,
[futurepassWrapper(), feeProxyWrapper(ROOT_ASSET_ID)],
nativeWalletSigner(process.env.SENDER_PRIVATE_KEY)
);
const extrinsic = api.tx.system.remark("🥧");
// estimate an extrinsic in any token
const feeResult = await estimate(extrinsic, ROOT_ASSET_ID);
if (!feeResult) throw feeResult.value;
console.log(feeResult.value);
// send an extrinsic that pays gas in ROOT token and via FuturePass account
const sendResult = await signAndSend(extrinsic);
if (!sendResult.ok) throw sendResult.value;
console.log(sendResult.value);