Reputation
Badges 5
Editor Freshman Enthusiast Supporter NewbieThe following is from a test file in tonweb. Here's the entire file. https://github.com/toncenter/tonweb/blob/master/src/test-jetton.js
It should be enough for your needs!
const transfer = async () => {
const seqno = (await wallet.methods.seqno().call()) || 0;
console.log({seqno})
console.log(
await wallet.methods.transfer({
secretKey: keyPair.secretKey,
toAddress: JETTON_WALLET_ADDRESS,
...
Two issues:
- You should read address from slice via
load_msg_addr
, notload_bits
- Store address to builder via
Addr
, notaddr
addr
, is an alias for 256uint. Meanwhile full address serialization with Addr
also includes address format tag, workchain, 256bit part and some additional fields.
It is definitely feasible to implement the logic of your game as a smart contact and then it’s guaranteed to be secure for all users.
Each transaction to change the game state will cost a few cents as gas. If this cost is an issue (for example your game has tens of thousands of transactions per player), then you can use payment channels to reduce this cost.
One of the interesting things mentioned is randomness, which is difficult in the Web3 space. A verifiable randomness function (VRF)...
I haven't heard of 10 video lessons, but I do know of the Ten Lessons GitHub repository for FunC. They have since then grown to 19 lessons.
It really depends on the smart contract code. The standard for NFTs (TEP-62) does not include deletion, however.
https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md
You could always just transfer it to the null address, or if that doesn't work, some other random address.
There are plenty of projects out there to try. Here are 3 suggestions:
- Rock paper scissors game that require deposits to play (think about how to keep data private in between moves)
- Try deploying a custom Jetton (token)
- Try making a basic swap/IDO contract
The answer is likely "no". Smart contracts are for on-chain logic, and the server is off-chain. The actions taking place on a smart contract will not be determined solely by the TVM.
You could have a smart contract act as an interface for the server to listen to: for example, account A communicates with smart contract B, and sends an event to delete a file of ID C on server D. But there is nothing that guarantees that file C exists, or that the server D's logic will listen to B.
When added to a liquidity pool protocol, a jetton is defined by supply and demand. If you are looking for a way to sell a jetton at a single fixed price, then you're likely looking for an ICO smart contract:
https://github.com/ton-blockchain/token-contract/blob/main/ft/jetton-minter-ICO.fc#L56
Where the amount of TON sent with the transaction is multiplied by some value of jetton to mint to the sender.
int jetton_amount = buy_amount; ;; rate 1 jetton = 1 toncoin; multiply...
This post has JS code that does it as well as explanations how it all works: https://ton-community.github.io/tutorials/01-wallet/
You should be able to get the wallet address like so:
import { mnemonicToWalletKey } from "ton-crypto";
import { WalletContractV4 } from "ton";
async function main() {
// open wallet v4 (notice the correct wallet version here)
const mnemonic = "unfold sugar water ..."; // your 24 secret words (replace ... with the rest of the words)
...
Yes, anyone can deploy a Jetton. Jettons are just smart contracts, similar to ERC-20s on Ethereum. The network wouldn't be very decentralized if that wasn't the case!
Technically, there is no "official" deployment of ETH because anyone can create their own bridge and their own ETH token. So it's up to you to do the research to figure out which Jetton smart contract is the best to use as your ETH representation. That being said, ton.org currently uses the [TON Bridge](https://bridge.ton.org...
As far as I am aware, there are no complete user-friendly interfaces to create a DAO on TON. That being said, there are smart contract and repositories examples for you to potentially work off of.
Probably the closest to what you want:
https://github.com/orbs-network/dao-vote
Fift implementation of a multisig wallet:
https://github.com/mir-one/dao-multisig
This is a good suggestion for a dedicated step-by-step tutorial. I imagine that the TON community will focus on this in the coming months.
Here are some resources to help with creating NFTs:
- TON-NFT-deployer: created by TON Diamonds, this is a complete project that can help the technically minded developer deploy an NFT
- Disintar: an NFT marketplace for TON. You might want to look into here if you want...
It is possible to do this, but you would have to generate thousands of different private and public key pairs. I have yet to see one configured specifically for TON, though.
Essentially, you would generate thousands of random mnemonics and filter for ones that are like the parameters that you want.
You can generate key pairs with TonWeb:
const nacl = TonWeb.utils.nacl; // use nacl library for key pairs
const tonweb = new TonWeb();
const key...
The documentation surrounding TON DNS is here:
https://ton.org/docs/participate/web3/dns
Its official site is here:
https://dns.ton.org/
I must stress that this is not the same DNS as what you would find when registering a .com domain address on a typical domain registrar. There is currently no ".ton" nameserver that can be connected to the rest of the world wide web. Instead, these are essentially nicknames for addresses. This is helpful because addresses are hard to memorize, bu...
A source of randomness is required, and there are plenty of ways to do it: https://docs.ton.org/ko/develop/smart-contracts/guidelines/random-number-generation
A basic version of a lottery script exists here, which uses the randomize_lt
function:
https://github.com/pyAndr3w/ton-lottery-smc/blob/main/func/code.fc
You're looking for the dump_stack()
function.
https://ton.org/docs/develop/func/stdlib/#dump_stack
It dumps the last 255 values in the stack and shows the total stack depth.
() dump_stack() impure asm "DUMPSTK";
There's also the ~dump
and ~strdump
built-ins.
There is a Telegram payments bot, but it has yet to integrate TON:
There are some community example projects of TON bots that accept TON payments:
https://github.com/Gusarich/ton-bot-example
https://github.com/LevZed/ton-payments-in-telegram-bot
But if you want something better, you'll have to develop one yourself. You can try starting here:
https://ton.org/docs/develop/dapps/asset-processing/
In JavaScript, you can use the ton
package. I have adapted an example from a community-led TON tutorial. Please use at your own risk.
What it does is:
- Generate multiple mnemonics
- Find the addresses of the generated mnemonics
- Fund the addresses of these mnemonics with a pre-funded wallet
- Send a transaction out of these mnemonnics to automatically deploy the contract
im...
The best solution is likely the TON Contract Executor. It allows you to run the TON Virtual Machine locally, and thus execute smart contracts. You should be able to debug and fully test contracts before launching them to the network. I don't believe it forks networks like HardHat can, however.
There is also MyLocalTON which is a community led solution that runs not only the virtual machine b...
Unfortunately, the TON http-api does not allow you to specify a block when using getAddressBalance.
https://toncenter.com/api/v2/#/accounts/get_address_balance_getAddressBalance_get
I suppose one way you could go about it is reconstructing the balance over time. Get all of the transactions until the block you're looking at is surpased:
https://toncenter.com/api/v2/#/accounts/get_transactions_getTransactions_get
You can try this with the getTransactions endpoint, just make sure t...
There is such an operator; the documentation calls ita "conditional operator".
https://ton.org/docs/develop/func/statements#conditional-operator
This is the example provided:
;; <condition> ? <consequence> : <alternative>
x > 0 ? x * fac(x - 1) : 1;
There is no such layer or toolkit. You would have to build such primitives yourself using the TON virtual machine and potentially FunC.
Slices are the way to store strings. At the end of the day, strings are just a bunch of bytes that are interpreted in an ASCII format. You'll have to interpret strings as such when working with them in the smart contract.
https://ton.org/docs/develop/func/literals_identifiers#string-literals
You can define strings with quotation marks like in other languages, but they are stored in such a way that they become a slice of bytes.
Non-bounceable messages will allow coins to stay on the contract's side. This is used on a wallet's deploy, when passing state initialization.
Unfortunately, there currently isn't something like the Remix IDE for TON. The best alternative would likely to load up a generic online IDE to play with smart contracts based on Glitch.
As always, I would recommend simply developing smart contracts on a local machine.
As a Solidity developer, one of the best articles for you to understand the differences between the EVM and the TVM is:
https://society.ton.org/six-unique-aspects-of-ton-blockchain-that-will-surprise-solidity-developers
This is a very good introduction. Afterwards, the whitepaper is where you will have to go along with the developer documentation.
TON is a decentralized blockchain, and rarely is there a developer console for blockchains like there is in Web2 (private blockchains might have these sorts of features). Some blockchains might have third party deployment tools for smart contracts that act as infrastructure, but that's not necessary for creating a wallet. What you're likely looking for is a way to query information off of the blockchain and to send transactions, which will require an http-api endpoint. Some of these endpoints...
You likely can. Just use:
pip install pytonlib
If that doesn't work, you can try a community member's python version of tonsdk.
Standard token contracts can be found on the main GitHub profile of the TON blockchain. You can generally look for FunC smart contracts on the TON blockchain and TON foundation profiles.
There are also some snippets that users provide, such as the FunC snippets provided by TonoxDeFi on GitHub.
"MessageAny" is a type that refers to type Message.
https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L155