ton icon indicating copy to clipboard operation
ton copied to clipboard

How to create a new currency

Open Kyborg2011 opened this issue 4 years ago • 11 comments

Hello, everyone!

As I see in documentation and white paper, there is an ability to create my own currency in TON, based on smart-contract, but I have not found any true guide about this option in any of current official documents, shared by TON creators. I have searched in: white paper, tblkch.pdf, tvm.pdf, fiftbase.pdf and in other text documents on a website (test.ton.org).

So, can you help me with it? Also, is it real right now, in testnet2?

P.S.: I am asking this, as a participant in Blockchain contest (stage 2) ;)

Kyborg2011 avatar Dec 08 '19 01:12 Kyborg2011

Yes. You have to send an internal message with a predefined amount of (test) grams to a special "minter" smartcontract, indicating an unused currency ID and the total amount of the new currency to be minted. You get the new tokens in an answer message.

What is your expected use of the new currency? If you just want to have some tokens distinct from test Grams, we can send you some.

ton-blockchain avatar Dec 08 '19 13:12 ton-blockchain

@ton-blockchain Thank you! I am thinking about an idea for a smart contract in 2nd stage of a competition, so I think about creating of a full Token by smart contract, like in Ethereum Blockchain - the most of smart contracts have it unique currency.

So, particular for a contest, is it needed - a unique currency, or not? If not I think I can make a work, based simply on a base currency (GRM).

I have a test grams ) Thank you! I have got it from an official Telegram account, when I was getting my prize In a 1st stage of a competition.

Kyborg2011 avatar Dec 08 '19 15:12 Kyborg2011

@ton-blockchain And another simple question: I need for my idea of a smart contract some functions for a pseudo random numbers generation. I have found in tvm.pdf that in Fift assembler there are some random generation functions, but I do not see there any real examples of them. Can you help me with that, too? )

Kyborg2011 avatar Dec 08 '19 15:12 Kyborg2011

What kind of random number generating functions would you like to have? Random 256 bits? Random number 0 .. n-1 for any n?

ton-blockchain avatar Dec 09 '19 12:12 ton-blockchain

@ton-blockchain Any of these variants is good for me, but right now for my idea - random generator of numbers 0 ... n-1 is enough for me,

Kyborg2011 avatar Dec 09 '19 14:12 Kyborg2011

^, I also am currently in need of those pseudorandom primitives, 0 .. n-1 is also fine for me.

danog avatar Dec 11 '19 15:12 danog

Well, the new RAND primitive might be what you want. It is documented in A.11.3 of tvm.pdf.

ton-blockchain avatar Dec 14 '19 13:12 ton-blockchain

@ton-blockchain I have found it ) Thank you for so fast improvement!

Kyborg2011 avatar Dec 14 '19 15:12 Kyborg2011

@ton-blockchain does such kind of minting work at all? I checked throughtly in the C++ source code and can't find correct message layout.

root@megaton:~# lc -c 'getconfig 2'
...
ConfigParam(2) = ( minter_addr:x0000000000000000000000000000000000000000000000000000000000000000)
x{0000000000000000000000000000000000000000000000000000000000000000}

Moreover, looking at a glance at -1:0 contract and looking at gen-zerostate I can see that -1:0 contract is just a very fat simple wallet.

// SmartContract #1 (Simple wallet)
...
AllOnes 0 * // address
...
dup make_special dup constant smc1_addr  
...
...
smc1_addr config.minter_smc!

Tried sending some kind of message carrying 32-bit key, 32-bit amount, but expectedly, the "minter" contract swallowed it. Is it correct that currently minting is not supported?

Skydev0h avatar Dec 19 '19 07:12 Skydev0h

Automatic minting is not enabled now, that's true. If you need some extra currencies (different from test grams) just to test something, we can send you some in the testnet. If you want to test the automatic creation of new currencies, you'll have to wait a bit.

ton-blockchain avatar Dec 30 '19 09:12 ton-blockchain

Can you send me please for testing purposes extra currency (id:241, amount:1000000000000) to wallet kQDEysEvW8fu9M9eyE7mjM-GCSGgbKA5XsVY5T43sTw7CLt1

plexar88 avatar Mar 11 '20 14:03 plexar88