tonweb
Version:
TonWeb - JavaScript API for TON blockchain
64 lines (56 loc) • 3.53 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="../dist/tonweb.js"></script>
<script>
async function test() {
const publicKey = TonWeb.utils.hexToBytes('82A0B2543D06FEC0AAC952E9EC738BE56AB1B6027FC0C1AA817AE14B4D1ED2FB');
const secretKey = TonWeb.utils.hexToBytes('F182111193F30D79D517F2339A1BA7C25FDF6C52142F0F2C1D960A1F1D65E1E4');
const keyPair = TonWeb.utils.nacl.sign.keyPair.fromSeed(secretKey);
const tonweb = new TonWeb();
const wallet = tonweb.wallet.create({publicKey: publicKey, wc: 0});
const msg = await wallet.createInitExternalMessage(keyPair.secretKey);
const address = msg.address;
const my = `
Creating new advanced v3 wallet in workchain ${wallet.options.wc}
with unique wallet id ${wallet.options.walletId}
Loading private key from file new-wallet.pk
StateInit: ${msg.stateInit.print()}
new wallet address = ${address.toString(false)}
(Saving address to file new-wallet.addr)
Non-bounceable address (for init): ${address.toString(true, true, false, true)}
Bounceable address (for later access): ${address.toString(true, true, true, true)}
signing message: ${msg.signingMessage.print()}
External message for initialization is ${msg.message.print()}
${TonWeb.utils.bytesToHex(await msg.message.toBoc(false)).toUpperCase()}
(Saved wallet creating query to file new-wallet-query.boc)
`;
// fift -s new-wallet-v3.fif 0 698983191
const fift = `
Creating new advanced v3 wallet in workchain 0
with unique wallet id 698983191
Loading private key from file new-wallet.pk
StateInit: x{34_}
x{FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED54}
x{0000000029A9A31782A0B2543D06FEC0AAC952E9EC738BE56AB1B6027FC0C1AA817AE14B4D1ED2FB}
new wallet address = 0:2cf55953e92efbeadab7ba725c3f93a0b23f842cbba72d7b8e6f510a70e422e3
(Saving address to file new-wallet.addr)
Non-bounceable address (for init): 0QAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi4-QO
Bounceable address (for later access): kQAs9VlT6S776tq3unJcP5Ogsj-ELLunLXuOb1EKcOQi47nL
signing message: x{29A9A317FFFFFFFF00000000}
External message for initialization is x{880059EAB2A7D25DF7D5B56F74E4B87F2741647F0859774E5AF71CDEA214E1C845C6119529DEF4481C60CD81087FC7B058797AFDCEBCC1BE127EE2C4707C1E1C0F3D12F955EC3DE1C63E714876A931F6C6F13E6980284238AA9F94B0EC5859B37C4DE1E5353462FFFFFFFFE00000001_}
x{FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED54}
x{0000000029A9A31782A0B2543D06FEC0AAC952E9EC738BE56AB1B6027FC0C1AA817AE14B4D1ED2FB}
B5EE9C72410203010001000002DF880059EAB2A7D25DF7D5B56F74E4B87F2741647F0859774E5AF71CDEA214E1C845C6119529DEF4481C60CD81087FC7B058797AFDCEBCC1BE127EE2C4707C1E1C0F3D12F955EC3DE1C63E714876A931F6C6F13E6980284238AA9F94B0EC5859B37C4DE1E5353462FFFFFFFFE000000010010200C0FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED5400500000000029A9A31782A0B2543D06FEC0AAC952E9EC738BE56AB1B6027FC0C1AA817AE14B4D1ED2FB56AD484D
(Saved wallet creating query to file new-wallet-query.boc)
`;
console.assert(my === fift);
}
test();
</script>
</body>
</html>