Anon
Anon

Reputation: 1

How to send a file to the ton storage provider?

I'm trying to send file to the ton storage provider

First I generated file, using storage-daemon-cli. Command like this:

new-contract-message <BagID> <file> --query-id 0 --provider <address>

Then trying to send file, using ton-core JS SDK

const tempFilePath = './storage/tempFile' // tempFile - file generated by daemon-cli

const payload = await fsPromise.readFile(tempFilePath, {encoding: 'base64'});

const payloadBase64 = Cell.fromBase64(payload)

const messageBody = beginCell()
        .storeUint(0x107c49ef, 32)
        .storeUint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
        .storeSlice(payloadBase64.beginParse())
        .endCell();

await provider.internal(via, {
        value: "0.5",
        body: messageBody
});

But then execution smart contract crashes with 1009 error

const error::provider_params_changed = 1009;

Smart contract code on GitHub

Can anybody explain how to make right message body?

Thank you all in advance!

Upvotes: -1

Views: 252

Answers (1)

Anon
Anon

Reputation: 1

I found solution. Maybe it will be helpful for somebody:

const tempFilePath = './storage/saved2' // tempFile - file generated by daemon-cli

const payload = await fsPromise.readFile(tempFilePath, {encoding: 'base64'});
        
const payloadBase64 = Cell.fromBase64(payload)

await provider.internal(via, {
    value: "0.5",
    body: payloadBase64
});

Upvotes: 0

Related Questions