cross-chain-compiler
v1.0.0
Published
A simple library to compile .sol and validate .clar files.
Downloads
19
Readme
Multi-Chain Compiler Library
A lightweight Node.js utility to handle smart contract compilation for both Solidity (EVM) and Clarity (Stacks).
Prerequisites
- Node.js: v16 or higher.
- Clarity CLI: To compile/check
.clarfiles, you must have the Stacks node tools installed.cargo install blockstack-core --features --bin clarity-cli
Installation npm install
Usage As a Module const CrossCompiler = require('./index'); const compiler = new CrossCompiler();
// Compile Solidity const solResult = await compiler.compile('./Contract.sol');
// Validate Clarity const clarResult = await compiler.compile('./Contract.clar');
Via Command Line node index.js ./path/to/your/contract.sol
Features
- Solidity: Returns full ABI and EVM Bytecode.
- Clarity: Performs static analysis and type checking via clarity-cli.
- Automatic Detection: Routes compilation based on file extension.
Important Note on Clarity
Unlike Solidity, which compiles to bytecode that is sent to the chain, Clarity code is published as human-readable source code. The "compilation" step in Clarity is primarily for validation (ensuring types are correct and the contract is "decidable"). Ensure your environment has clarity-cli in the system PATH for the .clar logic to work!
