Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial version of wrc20 token #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

initial version of wrc20 token #4

wants to merge 3 commits into from

Conversation

cdetrio
Copy link
Contributor

@cdetrio cdetrio commented Jun 26, 2018

No description provided.

@yglukhov
Copy link

yglukhov commented Jul 4, 2018

Is there a way to deploy the contract? The following code fails on estimateGas with Transaction execution error

let Web3 = require("web3")
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
let rustCode = '0x' + fs.readFileSync("./rust.wasm").toString('hex');
var interface = [
    {
        type: "function",
        name: "balance",
        inputs: [{"name": "acc", "type": "address"}],
        outputs: [{"name": "returnValue", "type": "uint64"}],
        constant: true
    },
    {
        type: "function",
        name: "transfer",
        inputs: [{"name": "to", "type":"address"}, {"name": "amount", "type": "uint64"}],
        outputs: []
    }
]
async function upload() {
    let accs = await web3.eth.personal.getAccounts()
    web3.eth.defaultAccount = accs[0]
    var TokenContract = new web3.eth.Contract(interface, { data: rustCode, from: web3.eth.defaultAccount });
    var TokenDeployTransaction = TokenContract.deploy({data: rustCode});
    await web3.eth.personal.unlockAccount(web3.eth.defaultAccount, "")
    let gas = await TokenDeployTransaction.estimateGas() // Fails here!
    let contract = await TokenDeployTransaction.send({gasLimit: gas, from: web3.eth.defaultAccount});
    console.log("Address of new contract: " + contract.options.address);
}
upload()

@hugo-dc
Copy link
Member

hugo-dc commented Jun 16, 2019

@yglukhov Contracts are deployed using ewasm-studio (http://ewasm.ethereum.org/studio/) or the explorer's deployer (http://ewasm.ethereum.org/explorer/deploy).

You cannot deploy your wasm contract directly, it has to be wrapped into a deployer wasm module which when executed returns your contract bytecode, both ewasm-studio and the explorer's deployer wraps the contract into a deployer wasm module.

I've made a script to deploy an ewasm contract without ewasm-studio/explorer's deployer , you can find it here: https://github.com/hugo-dc/deploy-ewasm

It is using wasm-chisel (https://github.com/wasmx/wasm-chisel) to wrap the wasm contract into a deployer. You can find more information in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants