remix-ide
开发环境更有助于提升工作的效率。/usr/local/lib
的权限为0777,否则报错如下: Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
修改权限的命令如下:
$ sudo chmod -R 0777 /usr/local/lib
python3
和python2.7
,一定要保证输入默认的python版本是python2.7
的,否则一致会安装失败!本人就遇到了这个错误。$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
如果不是也不要着急,使用如下命令,便可以将python2.7设为默认的python版本:
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 200
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
$ npm install remix-ide -g
# 或者显示指定python版本
$ npm install remix-ide -g --python=python2.7
安装成功的输出信息如下:
安装失败也不要怕,可以卸载(大不了使用在线ide,我当时一致安装不成功就是这样想的。。。。)
$ npm uninstall remix-ide -g
# 或者显示指定python版本
$ npm uninstall remix-ide -g --python=python2.7
pragma solidity 0.5.6;
contract multiply_test {
function multiply(uint a) public view returns(uint d) {
return a * 7;
}
}
abi
对应使用solc
命令编译sol文件产生的.abi
文件,也是上篇博客中所说的interface:[{
"constant": true,
"inputs": [
{
"name": "a",
"type": "uint256"
}
],
"name": "multiply",
"outputs": [
{
"name": "d",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}]
bytecode
中的object
对应使用solc
命令编译sol文件产生的.bin
文件:{
"linkReferences": {},
"object": "6080604052348015600f57600080fd5b5060a58061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063c6888fa114602d575b600080fd5b605660048036036020811015604157600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390f35b600060078202905091905056fea165627a7a7230582089854092b53019c2f9ce782c5ac5f44bef34a519544f6fa8fca0a0f952dd090a0029",
...
}
web3 deploy
的代码可以在detail中找到,他是用于部署智能合约的代码:var multiply_testContract = web3.eth.contract([{"constant":true,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]);
var multiply_test = multiply_testContract.new(
{
from: web3.eth.accounts[0],
data: '0x6080604052348015600f57600080fd5b5060a58061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063c6888fa114602d575b600080fd5b605660048036036020811015604157600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390f35b600060078202905091905056fea165627a7a7230582089854092b53019c2f9ce782c5ac5f44bef34a519544f6fa8fca0a0f952dd090a0029',
gas: '4700000'
}, function (e, contract){
console.log(e, contract);
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})
参考链接:
安装remix-ide
Remix 搭建与简单使用
以太坊remix-ide本地环境搭建
Remix 以太坊Solidity IDE搭建与初步使用