(QTUM) 我部署了一个合约,使用 jsonrpc 调用合约设置了一个值,但是得到了 null
(QTUM) I deployed a contract, used the jsonrpc callcontract to set a value, but got null
set 'hello world' for description() to contract
qcli callcontract 816e13de2966cc56ca330d089aab849e5928eed5 90c3f38f 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000
getDescription()
qcli callcontract 816e13de2966cc56ca330d089aab849e5928eed5 7284e416
输出:00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
为什么return与set
方法不一样?无论我设置什么,它 returns 000.
我已经在这上面花了一整天了,请大家帮忙。
我不是QTUM专家,但你好像用错了API。
Mostly, you'll be using two RPC calls to interact with a contract's
methods:
- callcontract to invoke a method in "query" mode, using data from your
local blockchain, but not making changes to it. This is free.
- senttocontract to invoke a method in "commit" mode, creating a
transaction that changes the blockchain. This costs you gas.
callcontract
似乎是为了调用常量函数。如果您正在对区块链进行更改(发送交易),则需要使用 sendtocontract
.
首先,callcontract不能改变数据,应该调用sendtocontract
然后这是一个错误的调用
qcli sendtocontract 8a0795de06d66bf20940f5ee35b9092483af82a5 90c3f38f 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000
应该是
qcli sendtocontract 8a0795de06d66bf20940f5ee35b9092483af82a5 90c3f38f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000
方法和参数不应该有 space
set 'hello world' for description() to contract
qcli callcontract 816e13de2966cc56ca330d089aab849e5928eed5 90c3f38f 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000
getDescription()
qcli callcontract 816e13de2966cc56ca330d089aab849e5928eed5 7284e416
输出:00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
为什么return与set
方法不一样?无论我设置什么,它 returns 000.
我已经在这上面花了一整天了,请大家帮忙。
我不是QTUM专家,但你好像用错了API。
Mostly, you'll be using two RPC calls to interact with a contract's methods:
- callcontract to invoke a method in "query" mode, using data from your local blockchain, but not making changes to it. This is free.
- senttocontract to invoke a method in "commit" mode, creating a transaction that changes the blockchain. This costs you gas.
callcontract
似乎是为了调用常量函数。如果您正在对区块链进行更改(发送交易),则需要使用 sendtocontract
.
首先,callcontract不能改变数据,应该调用sendtocontract
然后这是一个错误的调用 qcli sendtocontract 8a0795de06d66bf20940f5ee35b9092483af82a5 90c3f38f 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000
应该是 qcli sendtocontract 8a0795de06d66bf20940f5ee35b9092483af82a5 90c3f38f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000 方法和参数不应该有 space