web3 js

初始化
if (typeof web3 !== ‘undefined’) {
web3 = new Web3(web3.currentProvider);
} else {
web3 = new Web3(new Web3.providers
.HttpProvider(“http://localhost:8545”));
}

以太单位转换
web3.fromWei web3.toWei
数据类型转换

web3.toString web3.toDecimal web3.toBigNumber
字符编码转换

web3.toHex web3.toAscii web3.toUtf8 web3.fromUtf8
地址相关

web3.isAddress web3.toChecksumAddress

同步:web3.eth.accounts

web3.eth. blockNumber

web3.eth.sendTransaction(transactionObject [, callback])

web3.eth.contract
var MyContract = web3.eth.contract(abiArray);
// 通过地址初始化合约实例
var contractInstance = MyContract.at(address);
// 或者部署一个新合约
var contractInstance = MyContract.new([constructorParam1]
[, constructorParam2], {
data: ‘0x12345…’,
from: myAccount,
gas: 1000000
});

myContractInstance.myMethod.call(param1[, param2, …][,
transactionObject
][, defaultBlock][, callback]);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值