Codecall.js can compile the solidity code in the js project, execute it remotely on the node and return the result.
npm install @chainstarter/codecall.jsbash
yarn add @chainstarter/codecall.js
`
or
`bash
npm install --save @chainstarter/codecall.js
`
$3
`javascript
// webpack CopyWebpackPlugin
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpackConfig = {
plugins : [
...,
new CopyWebpackPlugin([ // add plugin
{
from: 'node_modules/@chainstarter/codecall.js/dist/codecall.worker.js',
to: 'codecall.worker.js'
}
])
]
}
`
Usage
$3
`javascript
import {Client} from '@chainstarter/codecall.js'
client = new Client()
const code =
// call and print data
client.call(code).then(console.log)
`
#### Add custom chain
`javascript
import { Client } from '@chainstarter/codecall.js';
client = new Client()
client.addChain(4399,
{
address: '0xBF4b1bE1F00F5624ba4D65f8548ccF6E75d0deFe', // You can publish the contract on other chains by yourself
rpc: "{{RPC}}" // The node rpc address
})
`
#### Set default chain
`javascript
import { Client } from '@chainstarter/codecall.js';
client = new Client()
// set default chain
client.setDefaultChainId(4399)
`
$3
`javascript
const {call} = require('@chainstarter/codecall.js/dist/node')
// call data
call(
).then(console.log)
``