Reputation: 182
Working on contract fabric, starting with the sample.
TvmCell stateInit = tvm.buildStateInit(templateCode, templateData);
code
and data
are TvmCell
s of a template contract and must be passed as parameters.
We can get those info from a template contract this way: (tvm.code(), tvm.getData());
or tonos-cli decode
. And then convert to TvmCell
like this
TvmBuilder cb;
cb.store(code);
TvmBuilder db;
db.store(data);
templateCode = cb.toCell();
teamplteData = db.toCell();
Woking with the TONOS SE command line tools, the workflow essentially looks like this:
tondev c r Contract GetCodeAndData | pcregrep -M -o1 'value0\": \"(.+?)\"' | base64 -d | xxd -p | tr -d '\n' > code.hex
tondev c r Contract GetCodeAndData | pcregrep -M -o1 'value1\": \"(.+?)\"' | base64 -d | xxd -p | tr -d '\n' > data.hex
tondev c r Fabric deployWithCodeAndData -i code:$(cat code.hex),data:$(cat data.hex)
and this looks like working as expected, a new contract address is returned. However, an attempt to run any method of the deployed contract results in
Running...
Error: Contract execution was terminated with error: Compute phase isn't succeeded, exit code: -5 (integer overflow).
Possible reason: Contract did not accept message (integer overflow).
The same runs on the original contract, which code is used for templating, work with no error. It looks like serialization or deserialization are not correct. What's wrong?
Upvotes: 1
Views: 111
Reputation: 182
Get the tvm code and data via
code=$(tonos-cli decode stateinit --tvc contract.tvc | pcregrep -o1 'code": "(.+?)"')
data=$(tonos-cli decode stateinit --tvc document.tvc | pcregrep -o1 'data": "(.+?)"')
Call the function function setCodeAndData(TvmCell c, TvmCell d)
:
tondev c r Fabric.abi.json setTemplate -i c:$ddcode,d:$dddata
Upvotes: 0