Hi, I am trying to get started with learning FunC. I am following this guide to write my first contract but not understanding how to test and deploy with typescript as I am beginner in TS as well.
https://society.ton.org/ton-hello-world-step-by-step-guide-for-writing-your-first-smart-contract-in-func
Aug 7, 2022, 7:11 PM
I am able to write contract and compile to counter.cell but not able to test and deploy after that
Aug 7, 2022, 7:12 PM
what happens when you run "npm run test" ?
Aug 7, 2022, 9:48 PM
Hi Tal Kol. it runs and tests the deployed correctly but in your blog post you mentioned an address we could search to check if the app was active
also can I use the test suite and start writing smart contracts for the TON contest?
Aug 8, 2022, 9:35 PM
“npm run test” does not deploy the contract to the chain. It runs the tests locally in a simulation.
To deploy the contract to the chain and receive an address for it, you will need to deploy it with “npm run deploy”. You will need some TON for gas. What happens when you try to run it?
To deploy the contract to the chain and receive an address for it, you will need to deploy it with “npm run deploy”. You will need some TON for gas. What happens when you try to run it?
I’m not familiar with the rules of the contest but these tests are as good as running your contract in mainnet. If what you need to show works in these tests I can’t imagine it won’t be accepted
Aug 8, 2022, 9:39 PM
oh my bad.
npm run test works fine.
I ran npm run deploy with my wallet mnemonic in a .env file and it seemed to work but could not find any address to check the app
npm run test works fine.
I ran npm run deploy with my wallet mnemonic in a .env file and it seemed to work but could not find any address to check the app
I will have to write new tests for the contest tasks right?
Aug 8, 2022, 9:43 PM
are you using the deploy script from the blog post? Or are you using the ones from the repo https://github.com/ton-defi-org/tonstarter-contracts?
Aug 8, 2022, 9:45 PM
cannot get the deploy script in blog to work(don't know ts) but I used
npm run build, npm run test and npm run deploy from the repo
npm run build, npm run test and npm run deploy from the repo
Aug 8, 2022, 9:47 PM
Great, the repo scripts are good. Can you share the output of “npm run deploy”? What does it print on screen?
This line in the script https://github.com/ton-defi-org/tonstarter-contracts/blob/main/build/_deploy.ts#L126 should print the address of your deployed contract in an explorer
This line in the script https://github.com/ton-defi-org/tonstarter-contracts/blob/main/build/_deploy.ts#L126 should print the address of your deployed contract in an explorer
Aug 8, 2022, 9:50 PM
on running npm run deploy:testnet
> [email protected] deploy:testnet
> ts-node ./build/_deploy.ts
=================================================================
Deploy script running, let's find some contracts to deploy..
* We are working with 'testnet' (https://t.me/testgiver_ton_bot will give you test TON)
* Config file '.env' found and will be used for deployment!
- Wallet address used to deploy from is: (my wallet address)
- Wallet balance is 3.972985786 TON, which will be used for gas
* Found root contract 'build/main.deploy.ts - let's deploy it':
- Based on your init code+data, your new contract address is: EQC-QTihJV_B4f8M2nynateMLynaRT_uwNYnnuyy87kam-G7
- Looks like the contract is already deployed in this address, skipping deployment
- Running a post deployment test:
# Getter 'counter' = 33
# Sent 'increment' op message
# Getter 'counter' = 34
> [email protected] deploy:testnet
> ts-node ./build/_deploy.ts
=================================================================
Deploy script running, let's find some contracts to deploy..
* We are working with 'testnet' (https://t.me/testgiver_ton_bot will give you test TON)
* Config file '.env' found and will be used for deployment!
- Wallet address used to deploy from is: (my wallet address)
- Wallet balance is 3.972985786 TON, which will be used for gas
* Found root contract 'build/main.deploy.ts - let's deploy it':
- Based on your init code+data, your new contract address is: EQC-QTihJV_B4f8M2nynateMLynaRT_uwNYnnuyy87kam-G7
- Looks like the contract is already deployed in this address, skipping deployment
- Running a post deployment test:
# Getter 'counter' = 33
# Sent 'increment' op message
# Getter 'counter' = 34
i checked the contract address on tonwhales but it is showing as not active
Aug 9, 2022, 10:21 AM
This is one of the most self explanatory script output ever designed 😅
I think the issue is the testnet
You need to check in a testnet explorer
Aug 9, 2022, 10:22 AM
i checked here, is this the right place?
https://sandbox.tonwhales.com/explorer/address/EQC-QTihJV_B4f8M2nynateMLynaRT_uwNYnnuyy87kam-G7
https://sandbox.tonwhales.com/explorer/address/EQC-QTihJV_B4f8M2nynateMLynaRT_uwNYnnuyy87kam-G7
Aug 9, 2022, 10:23 AM
I’m personally against using testnets, I think they’re counter productive. Deploy on mainnet will cost a few cents, your time is worth more :)
I think TonWhales launched their own test net at some point that is different from where you deployed
This is why I hate testnets, they’re a mess and wallets don’t work well with them
Try a different explorer for testnet
Aug 9, 2022, 10:25 AM
hmm i dont know any
😅
Aug 9, 2022, 10:25 AM
https://ton.app/explorers
Just make sure to click on the testnet version of each one
In any case, just deploy to mainnet. Much easier and much more stable. My philosophy that after testing locally using “npm run test” the next step is deploy to mainnet so you have a beta in the real world
You can deploy your contracts 100 times to mainnet, it costs nothing
Aug 9, 2022, 10:33 AM
is contract deployed in mainnet permanent?
Aug 9, 2022, 10:34 AM
Yes, but it’s just an address. Deploy again and get a different address
Unless you publish this address to users, nobody will know it exists
Aug 9, 2022, 10:35 AM
i checked the tonscan testnet, redeployed and it shows activity as just now
the address is the same address i used above so its working fine right?
Aug 9, 2022, 10:43 AM
That's not quite true. Someone could know if they would inspect the new blocks.
Aug 9, 2022, 10:54 AM
I meant that they wouldn’t care
Aug 9, 2022, 10:54 AM
Who knows :)
Aug 9, 2022, 10:55 AM
Anyone that sees your contract on mainnet can take its bytecode and deploy it 10 more times.. so the fact the contract is singular is meaningless
Aug 9, 2022, 10:56 AM
It could lead to a premature disclosure of some product for example.
Aug 9, 2022, 10:56 AM
but you have this problem on testnet too
Aug 9, 2022, 10:56 AM
If it's public then yes.
Aug 9, 2022, 10:57 AM
he deployed originally to a public testnet. I have yet to find any case where that would be advisable to do
Aug 9, 2022, 10:57 AM
you can read more from talkol about it. They're so cheap so better to test on mainnet directly
Aug 11, 2022, 12:52 PM
for contest tasks i would have to write my own tests right? that are different from ones in repo
Aug 11, 2022, 1:40 PM