neodix42 / MyLocalTon

Personal local TON blockchain
GNU General Public License v3.0
119 stars 21 forks source link

How to deploy a contract on LocalTon? #40

Open AiDaiP opened 3 weeks ago

AiDaiP commented 3 weeks ago

Hello, I started LocalTon like this

java -jar MyLocalTon-x86-64.jar ton-http-api

Then I tried to deploy A simple counter contract (FunC)

WALLET_VERSION=v4 WALLET_MNEMONIC="spoon key tower goat diesel labor camera movie chaos entry panic ceiling panel move sibling genius grunt rival buzz just velvet medal butter foam" npx blueprint run

The result is

{ ok: false, error: 'Method Not Allowed', code: 405 }

Through the log, I found that the request sent was:

curl -X POST http://127.0.0.1:8081 --header 'Content-Type: application/json' -d '{"id":"1","jsonrpc":"2.0","method":"getAddressInformation","params":{"address":"EQDuu9SscZ8DpR53608hLNMz1cpQ3HTbM4MRJC36G_y4Q7YX"}}'

This will return

{"ok":false,"error":"Method Not Allowed","code":405}%

The command for LocalTon to start ton-http-api is:

ton-http-api --liteserver-config myLocalTon/genesis/db/my-ton-global.config.json --port 8081

This does not disable any Method, why does it return Method Not Allowed? Or maybe I used the wrong method to deploy the contract to LocalTon. What should I do?

neodix42 commented 3 weeks ago

You have to top up initial wallet address and then send a stateInit of that wallet to non bounceable address. You can do it using various SDK libraries, e.g. ton4j.

AiDaiP commented 3 weeks ago

Thanks for your answer, is there any documentation for these operations? If you know, please give me the link, thank you very much.

neodix42 commented 3 weeks ago

this is an example using ton4j library - https://github.com/neodix42/ton4j/blob/main/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV3R1Short.java