import { Address, beginCell, Cell, Dictionary, Message, storeMessage } from '@ton/core';
import { SimpleLibraryValue } from '@ton/core/dist/types/SimpleLibrary';
async function compare_vm() {
const cell = Cell.EMPTY;
const ADDRESS0 = Address.parse('0:0000000000000000000000000000000000000000000000000000000000000000');
let extraCurrency = Dictionary.empty(Dictionary.Keys.Uint(32), Dictionary.Values.BigVarUint(32));
extraCurrency.set(1, 100n);
let libraries = Dictionary.empty(Dictionary.Keys.BigUint(256), SimpleLibraryValue);
libraries.set(BigInt('0x' + cell.hash().toString('hex')), {
public: false,
root: cell,
});
const message: Message = {
info: {
type: 'internal',
ihrDisabled: true,
bounce: true,
bounced: false,
src: ADDRESS0,
dest: ADDRESS0,
value: {
coins: 0n,
other: extraCurrency,
},
ihrFee: 0n,
forwardFee: 0n,
createdLt: 0n,
createdAt: 0,
},
init: {
code: cell,
data: cell,
libraries: libraries,
},
body: beginCell().storeRef(cell).endCell(),
};
let builder = beginCell();
storeMessage(message)(builder);
console.log(builder.endCell().toBoc().toString('base64'));
}
compare_vm().catch(console.log);
Error: Too many references
at Builder.storeRef (/home/igor/src/everx/sol2tvm/solidity-ton-samples/node_modules/@ton/core/dist/boc/Builder.js:248:19)
at /home/igor/src/everx/sol2tvm/solidity-ton-samples/node_modules/@ton/core/dist/types/Message.js:78:21
at compare_vm (/home/igor/src/everx/sol2tvm/solidity-ton-samples/tests/compare_vm2.ts:39:25)
at <anonymous> (/home/igor/src/everx/sol2tvm/solidity-ton-samples/tests/compare_vm2.ts:43:1)
at Object.<anonymous> (/home/igor/src/everx/sol2tvm/solidity-ton-samples/tests/compare_vm2.ts:43:31)
at Module._compile (node:internal/modules/cjs/loader:1730:14)
at Object.transformer (/snap/clion/397/plugins/nodeJS/js/ts-file-loader/node_modules/tsx/dist/register-DfubRCxM.cjs:2:823)
at Module.load (node:internal/modules/cjs/loader:1465:32)
at Function._load (node:internal/modules/cjs/loader:1282:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14
Function
storeMessagethrows an exception if there areinfocode,dataandlibrariesininitThe function throws
Error: Too many referenceswhen it tries to store the body.You can contact with me via telegram: @IgorKoval
Example:
Output: