XTract
raw JSON → 1.0.0 verified Fri May 01 auth: no javascript
Solidity to MultiversX smart contract transpiler with CLI and TypeScript SDK. As of v1.0.0 (released 2025), XTract also includes wallet creation, WASM build via mxpy, and deployment to devnet/testnet/mainnet. It supports full Solidity function bodies, mappings (including nested), modifiers, inheritance, events, require/revert, and control flow. The npm package xtract-cli ships TypeScript types and a SDK (XtractTranspiler, ContractDeployer) for programmatic use. Peer dependency on @multiversx/sdk-core >=13.0.0. Node >=18 required.
Common errors
error Cannot find module 'xtract-cli' or its corresponding type declarations. ↓
cause Importing from 'xtract-cli' instead of 'xtract-cli/sdk'.
fix
Change import path to 'xtract-cli/sdk'.
error Module parse failed: The keyword 'import' is reserved ↓
cause Using ESM syntax in a CommonJS project without proper configuration.
fix
Add 'type': 'module' to package.json or use .mjs extension.
error Error: Cannot find module '@multiversx/sdk-core' ↓
cause Missing peer dependency when using SDK classes like ContractDeployer.
fix
npm install @multiversx/sdk-core@^13.0.0
error TypeError: XtractTranspiler is not a constructor ↓
cause Default import attempted on a named export.
fix
Use named import: import { XtractTranspiler } from 'xtract-cli/sdk'.
Warnings
breaking v1.0.0 moves SDK exports from root to /sdk subpath. Existing imports from 'xtract-cli' will break. ↓
fix Change import to 'xtract-cli/sdk'.
breaking CLI commands 'xtract build' and 'xtract deploy' are new in v1.0.0. No backward compatibility with v0.x deploy scripts. ↓
fix Update CI/CD pipelines to use the new CLI commands. Review changelog for full migration guide.
deprecated v0.x Python CLI 'xtract' is deprecated but still available on PyPI. New features added only to npm package. ↓
fix Migrate to npm package xtract-cli@>=1.0.0.
gotcha The 'xtract wallet create' command generates a PEM file that includes the private key in plaintext. Do not commit or share this file. ↓
fix Use hardware wallet or keep PEM file secure. For testnets, it's acceptable but avoid on mainnet.
gotcha Transpiled Rust code requires mxpy (MultiversX CLI) for building to WASM. The 'xtract build' command shells out to mxpy. ↓
fix Install mxpy from https://docs.multiversx.com/sdk-and-tools/mxpy/
gotcha TypeScript SDK requires Node >=18. Will fail on older versions with cryptic errors. ↓
fix Update Node.js to >=18.0.0.
Install
npm install xtract-cli yarn add xtract-cli pnpm add xtract-cli Imports
- XtractTranspiler wrong
import { XtractTranspiler } from 'xtract-cli'correctimport { XtractTranspiler } from 'xtract-cli/sdk' - ContractDeployer wrong
import ContractDeployer from 'xtract-cli'correctimport { ContractDeployer } from 'xtract-cli/sdk' - XtractTranspiler (default) wrong
const XtractTranspiler = require('xtract-cli/sdk').XtractTranspilercorrectimport XtractTranspiler from 'xtract-cli/sdk'
Quickstart
// npm install xtract-cli
import { XtractTranspiler, ContractDeployer } from 'xtract-cli/sdk';
import { ProxyNetworkProvider, UserSigner } from '@multiversx/sdk-core';
// Transpile
const transpiler = new XtractTranspiler();
const solidity = `contract Counter {
uint256 public count;
function increment() public {
count += 1;
}
}`;
const result = await transpiler.transpileCode(solidity);
console.log(result.rustCode);
// Deploy (after building WASM manually)
const provider = new ProxyNetworkProvider('https://devnet-gateway.multiversx.com', { timeout: 10000 });
const signer = UserSigner.fromPem('path/to/wallet.pem');
const deployer = new ContractDeployer(provider, signer);
const address = await deployer.deploy({
wasmPath: './output/contract.wasm',
abiPath: './output/contract.abi.json',
gasLimit: 60000000,
});
console.log('Deployed at:', address);