How many CKB bytes needed

Hi, guys! From your experience, how much CKB needed for the working project? How to make the right calculation? Any advice would be appreciated. Thanks

3 Likes

It is a good question.And I believe it depends on how many bytes your script need.
For example,a sUDT contract need around 29000 ckbytes ,and if you want to deploy a crypto primitive on chain it may need more than 100000 ckbytes.
The CKB Studio is a good dev programming tool that could estimate how many ckbytes you should use with a friendly UI.Be free to have a look the guide I paste below .

2 Likes

I would like to add some more details from my recent experiences.

When creating basic on-chain smart contract scripts in Rust, the smallest was usually about 17k bytes. My alternate implementation of SUDT is also 17k bytes. On Nervos’ Layer 1, 1 byte of data storage requires 1 CKByte, so approximately 17k CKBytes would be required to launch a new script.

The number of bytes needed for a script can vary greatly depending on a lot of factors, including which compiler and language are used. Rust scripts are larger, but compiler optimizations continue to make binaries smaller. When space savings are absolutely critical, C can be used instead of Rust. However, for most developers, we recommend using Rust.

It’s also worth noting that the fees involved with smart contract deployment are not directly comparable to other platforms. If your script is 20k, you will need 20k CKBytes to deploy on-chain. However, if you later remove the script because it is no longer needed, you get your CKBytes back.

3 Likes

Appreciate for your experience sharing. It makes me understand more about the real situation of ckybte consumption on L1 when developing .And I also believe that it is meaningful and helpful to general devs who are on the road to learn programming on CKB.

2 Likes

Thanks guys @WilliamsBlock @jm9k for your replies.
As I understood from posts, size depends on the compiler first of all. So, what about SDKs, for example, Go SDK or JavaScript, what compilers are used?

And finally, do you think the question about an efficient way to use CKB is crucial in development?

2 Likes

Even though it is technically possible to make an on-chain script using something like JavaScript, it is not recommended. The Go and JavaScript SDKs you see are for the off-chain components of a dapp. We only recommend Rust for on-chain script development. This is similar to how Ethereum is; the on-chain portion uses Solidity, and the off-chain portion often uses JavaScript (or NodeJS).

Efficiency is always an important question when developing on-chain smart contracts on any platform. This is one of the reasons that Rust is the recommended language on Nervos. It is one of the most efficient and safe languages in existence. In the past, some developers tried to use JavaScript for their on-chain scripts, and it was so inefficient that it wasn’t worth using.

1 Like

Efficiency is always an important question when developing on-chain smart contracts on any platform. This is one of the reasons that Rust is the recommended language on Nervos. It is one of the most efficient and safe languages in existence. In the past, some developers tried to use JavaScript for their on-chain scripts, and it was so inefficient that it wasn’t worth using.

If the number of bytes needed for the simple script about 17000, it will cost by the current price of about $420, and this just a simple script! Wow, looks like an efficient way of using CKBytes very very important.

1 Like

Hi
~18000

2 Likes

Correct. Storage with global consensus (a.k.a common knowledge byte) is a scarce resource.

Be aware that the “cost” of CKBytes is different from the transaction fee or gas cost. When a developer buys some CKbytes to store a script, the payment goes to the previous CKBytes owner not the miner. When the developer decides that the script is no longer useful he/she can free the storage, reclaim and sell those CKBytes. If the script is used by many, the reclaim decision should be made by all stakeholders instead of the developer. In short, CKBytes is more like a means of production which you acquired before and liquidate after production.

3 Likes

It is also worth pointing out that a simple token on Nervos does not require you to redeploy the contract. Everyone can use the existing SUDT contract, so you don’t have to worry about redeploying like you would have to on Ethereum. Users only have to pay for the cell that is used to store the tokens, not for the cell that holds the contract.

Even if you have to deploy a contract, it is still far less expensive on Nervos than it is on Ethereum today. Here is the cost of deploying the most basic token right now.

2 Likes

What better for a successful growing ecosystem - cheap and unlimited resource or scarce and expensive? How to find this golden line?

1 Like

Neither extreme is good, a balance must be found and only the market knows where the line is.

Initially the common storage is cheap, and people will use it to store low-value data. As more applications emerge and more users join, the need for ckbytes rises and people must bid for limited supply. Those who use the storage for high-value data are willing to pay more than those who use it for low-value data. Low-value data will gradually be forced to layer 2, L1 value-density will rise.

The economic pressure means the ecosystem will not grow unlimitedly on layer 1, unlike on blockchains which abuse global consensus and common storage. Instead the ecosystem will grow horizontally and vertically simultaneously, with layer 1 always in healthy condition. The market will apportion storage usage and transaction processing on different layers dynamically.

4 Likes