常见问题
配置文件路径错误
- 如下错误是提示配置文件路径错误
error: You must set rpcpassword=<password> in the configuration file:
/root/.WaykiChain/WaykiChain.conf
If the file does not exist, create it with owner-readable-only file permissions.
- 如果是运行 ./coind -datadir=. 则配置文件WaykiChain.conf应该在coind所在同级目录下
- 如果是运行 ./coind 后面不带-datadir=. 则配置文件WaykiChain.conf应该在当前用户目录的.WaykiChain文件夹下
节点启动失败
- 出现如下错误
root@ubuntu:/home/jk/workspace/wicc/WaykiChain_deply1# ./coind -datadir=.
************************
EXCEPTION: N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_6system12system_errorEEEEE
bind: Address already in use
Coin in AppInit()
Shutdown : done
root@ubuntu:/home/jk/workspace/wicc/WaykiChain_deply1#
- 解决方法:先kill掉正在运行的节点进程,再重新启动
root@ubuntu:/home/jk/workspace/wicc/WaykiChain_deply1# ps -ef|grep coind
root 20588 1794 6 Dec25 ? 08:46:04 ./coind
root 29810 29768 93 11:51 pts/0 04:55:05 ./coind -datadir=.
root 30489 30322 0 17:05 pts/25 00:00:00 grep --color=auto coind
root@ubuntu:/home/jk/workspace/wicc/WaykiChain_deply1# kill 29810
root@ubuntu:/home/jk/workspace/wicc/WaykiChain_deply1# ./coind -datadir=.
WaykiChain version v1.1.0.1-075db0b-dirty-release-linux (2018-12-26 15:47:51 +0800)
Using OpenSSL version OpenSSL 1.0.1f 6 Jan 2014
Using Lua version Lua 5.3.1
Using Boost version 1.54
Using Level DB version 1.17
Using Berkeley DB version Berkeley DB 4.8.30: (April 9, 2010)
Startup time: 2018-12-31 09:06:01
Default data directory /root/.WaykiChain
Using data directory /home/jk/workspace/wicc/WaykiChain_deply1/./testnet
Using at most 125 connections ( 1024 file descriptors available)
节点同步中止
解决方法
1. 重启
2. 如果经常出现区块同步长时间中止时,可通过crontab
命令添加定时执行脚本进行重启的任务
不了解crontab
使用的可以先参考crontab教程
本地部署
/root/wayki/checkblock.sh
脚本内容如下:
#!/bin/bash
echo "start check to blockcount:"
date
blockfile="wicc.blocks"
touch $blockfile
past_blockcount=`tail -n 1 $blockfile`
echo "past blockcount:$past_blockcount"
current_blockcount=`docker exec -it waykicoind-main /opt/wicc/coind getblockcount`
echo "current blockcount:$current_blockcount"
if [ $current_blockcount = $past_blockcount ]
then
echo "current blockcount equal to past blockcount, so restart the waykicoind."
docker restart waykicoind-main
else
echo "current blockcount does not equal to past blockcount, so go ahead."
past_blockcount=$current_blockcount
fi
echo $current_blockcount>$blockfile
echo "Now the past blockcount is $past_blockcount "
echo "end!"
- 使用
crontab -e
添加定时任务
example
1小时做一次检测
0 */1 * * * /root/wayki/checkblock.sh >> /root/wayki/checkblock.log
Docker本地部署
/root/wayki/auto_restart.sh
脚本内容如下:
#!/bin/bash
echo "native start check to blockcount:"
date
echo $1
cd $1
blockfile="wicc.blocks"
touch $blockfile
past_blockcount=`tail -n 1 $blockfile`
echo "past blockcount:$past_blockcount"
current_blockcount=`./coind -datadir=. getblockcount`
echo "current blockcount:$current_blockcount"
if [ $current_blockcount = $past_blockcount ]
then
echo "current blockcount equal to past blockcount, so restart the waykicoind."
./coind -datadir=. stop
sleep 3
./coind -datadir=.
else
echo "current blockcount does not equal to past blockcount, so go ahead."
past_blockcount=$current_blockcount
fi
echo $current_blockcount>$blockfile
echo "Now the past blockcount is $past_blockcount "
echo "end!"
- 使用
crontab -e
添加定时任务
example
1小时做一次检测
0 */1 * * * /root/wayki/auto_restart.sh >> /root/wayki/auto_restart.log
Note: shell脚本后面接的参数current_blockcount
为coind所在文件夹路径
区块同步时间久问题
手动使用下载已经同步好的区块 从0开始下载区块估计要10多个小时,如果希望快速同步区块,可以通过如下链接下载同步好的数据,将文件夹blocks的数据拷贝到main(主网)文件夹下,然后重新启动
- mainnet: http://waykichain.oss-cn-shenzhen.aliyuncs.com/mainnet/wicc-main-blocks-190408.tar.gz
WTIMES
- wtimes是维基时代重要的流通通证,未来可兑换维基链周边礼品以及社区相关福利,请持续关注维基时代。
- wtimes 按一分钱一个的价值来运营,只能兑换礼品,不支持提现
WiccWallet
钱包插件WaykiMax
为开发者提供了WiccWallet
接口。开发者可以在开发DAPP时集成WiccWallet
接口,方便开发者签名和广播WaykiChain交易。从而用户可以在浏览器中使用DAPP。
注1:WaykiMax 会为每个网站的站点注入一个全局变量:WiccWallet
注2:如果开发者需要在移动端和Web端使用同一套代码(H5)调用钱包,请使用WaykiBridge
getDefaultAccount
取得当前默认的账户,使用方法如下:
WiccWallet.getDefaultAccount().then((account) => {
console.log(account)
}, (error) => {
console.log(error)
})
如果钱包已经解锁,并且创建过账户,则会返回类似下面的结果:
{
"account": {
"address": "WTTqpSPZ9JHQJAPsmJQb1kXcMz5HvRWJLv",
"id": "eddd9578-8264-4f62-b215-da22a455152b",
"testnetAddress": "wQREsAsRAV1j133FHK4M5XQPPG3n4W23P1"
},
"network": "testnet",
"address": "wQREsAsRAV1j133FHK4M5XQPPG3n4W23P1"
}
network 为当前网络,address 为当前地址。如果需要获取正式环境的地址,使用 account.address;如果需要获取测试环境地址,使用 account.testnetAddress 。
UCoinContractInvoke (多币种合约调用)
amount=100000000//1WICC金额 coinSymbol=WUSD//币种类型 appid=450687-1//合约注册id contractMethod=”f001”//contractmethod调用合约方法 memo=”invokememo”//memo
WiccWallet.UCoinContractInvoke(amount,coinSymbol,appid,contractMethod,memo,(error, data)=>console.log(error,data)).then(()=>{ },(error)=>{ console.log(error) }) 返回 { "result":{ "coin_amount":100000000,//单位10^8sawi "fee":1000000, "arguments":"f001", "to_uid":"450687-1", "fee_symbol":"WICC",//小费类型(WICC) "txid":"029c86a648030e2b28ccc64c5ed60c96a0c61de95a30cab82159a476ceeeaf3d", "coin_symbol":"WICC", "txType":null, "from_addr":"wLnwB9n9PCdP2sWAF3R3KvMujxGnVsE6aa", } "errorCode":0 }
callContract
打开调用合约窗口,目前支持四个参数:regId
contract
value
callback
。
方法定义为WiccWallet.callContract(regId, contract, value, callback)
,使用方式为:
WiccWallet.callContract('13103-1', 'f0', 0, (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
对于 callback 参数,是用户在点击「确定」按钮之后的一个回调,第一个参数为 error,第二个参数为 data。如果 error 为 null,则可认为调用成功。 data 的数据结构类似下面这样(其中 txid 为这次交易的 hash):
{
amount: 0,
fee: 1000000,
contract: "f0",
txid: "55ec1c7abe38c492894a09f0c99e16d7c8d68608a2f1f6d334d0fd101b503e5b",
regId: "9109-1",
…
}
对于 value 参数,需要原始值乘以10的8次方。比如需要使用 0.1 WICC,则value
需要写 1000000。
publishContract
打开发布合约窗口,目前支持三个参数:script
scriptDesc
callback
。
WiccWallet.publishContract('mylib = require "mylib"', '33333', (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
关于 callback,请参照 callContract 。
requestPay
打开调用转账窗口,目前支持四个参数:destAddress
value
desc
callback
。
WiccWallet.requestPay('wYXV7QzHZnb8LuWw7Xa24dfUTqmH2tNZBq', 0.01 * Math.pow(10, 8), 'desc', (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
对于 value 参数,需要原始值乘以10的8次方。比如需要使用 0.1 WICC,则value
需要写 1000000。
关于 callback,请参照 callContract 。
requestVote
打开节点投票窗口,目前仅支持一个参数 votes
,每个 votes 下面有两个属性 address
和 votes
,示例如下:
WiccWallet. requestVote([{
address: 'wNQ8bTNN9eRj4U5hawdRJhvoGpMAfHfrZP',
votes: 2000001
}, {
address: 'wfhKnmXbE3n49trwd9CsvnzGqScJLLf4Jb',
votes: 2000002
}], (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
对于 votes 参数,需要原始值乘以10的8次方。比如需要使用 0.1 WICC,则value
需要写 1000000。
关于 callback,请参照 callContract 。
genCallContractRaw
打开调用合约窗口,目前支持四个参数:regId
contract
value
callback
。
方法定义为WiccWallet.genCallContractRaw(regId, contract, value, callback)
,使用方式为:
WiccWallet.genCallContractRaw('13103-1', 'f0', 0, (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
对于 callback 参数,是用户在点击「确定」按钮之后的一个回调,第一个参数为 error,第二个参数为 data。如果 error 为 null,则可认为调用成功。 data 的数据结构类似下面这样(其中 txid 为这次交易的 hash):
{
rawtx: "0401809ad912058086b1100103e52f01bc834a0001f0473045…faf6143b3b60ea6ab4e9afb312d9a81ddcaac55d03ef639fb"
}
对于 value 参数,需要原始值乘以10的8次方。比如需要使用 0.1 WICC,则value
需要写 1000000。
genPublishContractRaw
打开发布合约窗口,目前支持三个参数:script
scriptDesc
callback
。
WiccWallet.genPublishContractRaw('mylib = require "mylib"', '33333', (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
关于 callback,请参照 genCallContractRaw 。
genRequestPayRaw
打开调用转账窗口,目前支持四个参数:destAddress
value
desc
callback
。
WiccWallet.genRequestPayRaw('wYXV7QzHZnb8LuWw7Xa24dfUTqmH2tNZBq', 0.01 * Math.pow(10, 8), 'desc', (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
对于 value 参数,需要原始值乘以10的8次方。比如需要使用 0.1 WICC,则value
需要写 1000000。
关于 callback,请参照 genCallContractRaw。
genVoteDelegateRaw
打开节点投票窗口,目前仅支持一个参数 votes
,每个 votes 下面有两个属性 address
和 votes
,示例如下:
WiccWallet.genVoteDelegateRaw([{
address: 'wNQ8bTNN9eRj4U5hawdRJhvoGpMAfHfrZP',
votes: 2000001
}, {
address: 'wfhKnmXbE3n49trwd9CsvnzGqScJLLf4Jb',
votes: 2000002
}], (error, data) => console.log(error, data)).then(() => {
}, (error) => {
console.log(error)
})
对于 votes 参数,需要原始值乘以10的8次方。比如需要使用 0.1 WICC,则value
需要写 1000000。
关于 callback,请参照 genCallContractRaw 。
WaykiChain 公共节点
Testnet 公共节点,仅供测试
url: https://testnode.wiccdev.org
RPC username: wiccuser
RPC password: 123456
example
// Request
~$curl -u wiccuser:123456 -d '{"jsonrpc":"2.0","id":"curltext","method":"getinfo","params":[]}' -H 'content-type:application/json;' https://testnode.wiccdev.org
// Response
{
"result": {
"version": 1010101,
"fullversion": "v1.1.1.1-ee173ce-release-linux (2019-01-23 10:37:43 +0800)",
"protocolversion": 10001,
"walletversion": 0,
"balance": 1999749.99679999,
"timeoffset": 0,
"proxy": "",
"nettype": "TEST_NET",
"genblock": 0,
"chainwork": "000000000000000000000000000000000000000000000000000000000000876e",
"tipblocktime": 1548490510,
"paytxfee": 0.0001,
"relayfee": 0.00001,
"fuelrate": 1,
"fuel": 0,
"data directory": "/root/.WaykiChain/testnet",
"tip block hash": "c28bef6d3029ba6149235f27eb482a67d6202194a3d139b3a2e0bc59159aea8f",
"syncheight": 34670,
"blocks": 34670,
"connections": 4,
"errors": ""
},
"error": null,
"id": "curltext"
}
~$
如何判断交易是否上链成功
1. coind gettxdetail $txid找到对应的confirmed_height (H1)
2. coind getinfo里面找到finblock_height (H2)
3. 如果 H1 <= H2,那么交易已经准确无误的上链成功