How do I limit the max supply of an Elrond NFT collection? - blockchain

I'm currently working with the Elrond blockchain, and I've successfully registered a new NFT collection & created an NFT following the documentation example here.
However, I need to limit the amount of NFTs that can be created for a specific collection. The documentation says:
The ESDT manager can stop the creation of an NFT for the given ESDT forever by removing the only ESDTRoleNFTCreate role available.
So I guess I could just create the max supply of a collection (e.g 100 NFTs for collection1) and then remove the creation role. But this means I have to create all NFTs beforehand, which is not ideal.
Is there another way to limit the max supply, maybe when registering/issuing the collection itself?
On a separate note, is there good documentation on the difference between EGLD / ESDT / SFT / NFT. I'm particularly interested in SFTs, but I don't understand how the state change from fungible -> non-fungible works (e.g once the SFT becomes non-fungible, is it stuck in that state or can it become fungible again?). Documentation on that is quite unclear.
Thanks in advance for your help!

There is no optionnal "limit supply" for an NFT collection.
After you created the collection and give the ESDTRoleNFTCreate to your adresse or a contract you can call X time the function mint
Eventually, if you use a SC to mint the NFT, you can set a variable to limit the maximum allowed mint.
You cant convert NFT in SFT or SFT in NFT
The only operation allowed is converting an SFT into Meta-ESDT with no way back. This is possible only because SFT are really close to META-ESDT but with no decimals :)

Related

How to restrict PancakeSwap users from adding new pair on my new token's LP?

Hi there
(I'm new to the world of crypto and I'm still a noob and confused so please help me with your answer)
As a note I have read this:
How to restrict pancakeswap users from adding initial liquidity for my issued token?
Let's look at this scenario:
Bob created and launched a new token on BSC with 1000 total supply with name "test".
Bob also created a new pair with 80% of the total supply with 800 wbnb (test800 / 800 wbnb).
So each test token worth 1 wbnb and Instead, he receives 20 new LP-tokens.
Bob burned all the LP tokens by sending them to Dead-Wallet (or used any other locking platform), so far so good.
As nowadays everybody know, whenever someone trades on PancakeSwap, the trader pays a 0.25% fee, of which 0.17% is added to the Liquidity Pool of the swap pair they traded on.
https://docs.pancakeswap.finance/products/pancakeswap-exchange/pancakeswap-pools
A new buyer arrives, buys 100 of my tokens (test) and opens a new pair 100test/300wbnb (Or the same old LP is used) what will happen ?
Will my token price increase?
What if a new buyer creates a new pair with USDT?
How do I create an initial price for my new token?
Is it my first LP that creates my initial token price or the second
LP?
My most important question is:
How can I limit and restrict my LP from adding new pairs by others?
with thanks
I searched a lot on the internet, but no one mentioned it, or at least it was not simple or understandable for an amateur like me. I tried it myself on the Testnet network. The initial price of my coins was built according to my initial pool, but apparently everything changed when I built the second pool.
How can I limit and restrict my LP from adding new pairs by others?
You cannot. If a token is transferable, it is also freely tradeable.

How to sign miners rewards on a blockchain?

Don't kill me if I'm about to ask something stupid. But I'm very noobish in this whole crypto world, and I'm terribly fascinated about its technology.
So just for education purposes I've decided to build my own blockchain following more or less the bitcoin principles (ECC keypair generation using the secpbk1 curve, SHA256 as hashing algo, dynamic diff based on the timestamp of the previous block, p2p connectivity etc..). But I've came to a point where I'm pretty confused about the blockchain's wallet itself.
For what I've learned so far, each transaction has to be signed by a wallet. So my transactions has basically three fields: input, outputs and id. Since the user's wallet signs the outputs field of the transaction, this can't be changed anymore without being signed again by the same private key that belongs to the public key contained in the input field, how can I reward the miners?
If I got it right, the miner creates a transaction signed somehow by the chain using the fee in the outputs field, or by asking the chain itself to generate and sign a special reward transaction for that miner.
The guide that I was following was using the second approach, and was generating a blockchain wallet each time the program was executed on a client. This approach left me perplexed:
wouldn't a client generate a new wallet for "his" blockchain each time it goes back online? If so, wouldn't this create a mess on the transactions signed on the chain? Since each miner (therefore peer) signing its own reward would use a different blockchain wallet than the other peers? Wouldn't this lead to any problems?
The first one that I might think of, is that if we generate a new blockchain wallet that signs rewards for miners, each peer would create a different wallet, so wouldn't this lead to many "ghosts" wallets in the chain, that spits out rewards tokens from nowhere? Is this supposed to happen?
For what I think is definitively more straightforward to use the fee amount to reward the miner, but this doesn't solve my doubts at all. Since the outputs of the transactions are signed upon creation, how could the peer initiating the transaction know upfront the possible miner who finds the block? And if he can't know it, how could possibly the miner "extract" its reward without tampering the transaction itself? Of course it could create a new transaction, and add that to the block. But who would sign that transaction? From where those reward tokens come?
And if the answer is not to generate a new wallet each time, where could you possibly store that very first private key of the chain's wallet where no one can see it, but still be able to use it, without having to put a server in the middle?
Which in my opinion breaks the whole decentralized concept and would add a single point of failure.
I've also implemented a transactions pool, that automatically filters out invalid (tampered) transactions, whenever a miner requests a sub set of them to stamp in a block. But does this mean that the miner for that only exception can tamper the transaction since it'll be "forged" in the block? So who gives a *** if it was tampered once it got in the chain? MEEEEEH that doesn't sound nice at all.
I'm terribly confused, and I'm dreaming key pairs at night. Please help me.
wouldn't a client generate a new wallet for "his" blockchain each time it goes back online? If so, wouldn't this create a mess on the transactions signed on the chain? Since each miner (therefore peer) signing its own reward would use a different blockchain wallet than the other peers? Wouldn't this lead to any problems?
You don't say what problems you think this will lead to. I can't think of any.
For what I think is definitively more straightforward to use the fee amount to reward the miner, but this doesn't solve my doubts at all. Since the outputs of the transactions are signed upon creation, how could the peer initiating the transaction know upfront the possible miner who finds the block? And if he can't know it, how could possibly the miner "extract" its reward without tampering the transaction itself?
The simplest solution to this is for the transaction itself to just contain its inputs and outputs. The fee is the difference between the total inputs and the total outputs.
The miner just includes the transaction in the block of transactions they mine. They also add one additional transaction into the block, sending themselves the reward. Obviously, they know their own destination address. Every participant who receives the newly-mined block checks to make sure this transaction is valid (just as they check every other one) and doesn't claim a larger reward than is allowed.
And if the answer is not to generate a new wallet each time, where could you possibly store that very first private key of the chain's wallet where no one can see it, but still be able to use it, without having to put a server in the middle?
Typically in a file on the local disk. The private key isn't really needed anyway -- you only need it to send. You don't need it to mine or report. So it can be prompted for or decrypted only when actually needed.
Of course it could create a new transaction, and add that to the block. But who would sign that transaction? From where those reward tokens come?
The usual rule is that the reward transaction has no inputs, one output, and no signature. The tokens come from the pool of unclaimed miner reward tokens which can be finite or infinite depending on the blockchain's design. (For bitcoin, this pool is finite.)

write tiny amount of data to block chain? and what block chain are available

I need to write my hash to block chain to make my document legit for life time (want to know how to do that)? Want to know how many block chains are out there and which few are the best ones with least expenses?
You can make a commitment in a Bitcoin transaction in at least a few ways.
1 - including your preimage in OP_RETURN data in an zero value output. This can be done by creating your own transaction manually, but you will have to pay the transaction fee. You could also use a service which aggregates many commitments into one final hash, then you share the fee (or don't pay one at all). One example is OpenTimestamps.
2 - Pedersen commitment - use your preimage to generate an EC public key along with a blinding factor. Does not use extra space in your transaction, therefore can be included in a transaction without additional fees.
3 - Pay-to-contract signature - including another preimage the nonce used in your transaction signature. This also does not take extra space in your transaction, therefore can be included in a transaction without additional fees.
Resources
A good resource is waxwing's blog: https://joinmarket.me/blog/blog/finessing-commitments/
Another good readup on this subject can be found here: https://blog.eternitywall.com/2018/04/13/sign-to-contract/
James Chiang's Teach Bitcoin curriculum: https://teachbitcoin.io/presentations/ecdsa.html#/
And wikipedia: Commitment Scheme
Save your data in any cloud server or ipfs and then deploy any sample smart contract
contract MyToken {
constructor(){}
string my_doc;
function set(string memory link) public{
my_doc=link;
}
function get() public view returns (string memory ){
return my_doc;
}
}```
//and you can use polygon you can do all the stuff in les then one dollar
//by way you watch a simple tutorial how deploy smart contract using remix ide

HD wallet (bip32) addresses derivation path

I am creating an application that needs to generate a new address from a provided XPUB key.
For instance xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz
I am using the Electrum wallet and a key provided by this app.
My application allows users to add their own xpub keys, so my application will be able to generate new addresses without affecting users privacy, as far as xpub keys are only used by my application and not exposed to public.
So I am looking for a way to generate new addresses correctly, I have found some libraries, however I am not sure about the derivation path, how should it look like ?
Consider the following path example
Is the derivation path is more a convention rather than a rule?
Bitcoin first external first m / 44' / 0' / 0' / 0 / 0 is this is a valid path? I have found it here https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
I have also found out that Electrum wallets uses another schema https://bitcoin.stackexchange.com/questions/36955/what-bip32-derivation-path-does-electrum-use/36956 in the following format. It uses m/0/ for receiving addresses, and m/1/ for change addresses.
What is the maximum number (n) of addresses? How online tools calculate the balance of an HD wallet, if the N number is quite large it will require a lot of processing power to calculate sum.
So all in all, I wonder what format of the derivation path should I use in order to have no problems with compatibility?
I would be grateful for any help.
question 1-3:
It's bip44 convention, electrum isn't following it therefore it's not compatiable with other wallets which support bip44.
question 4:
the number can be infinite, if you are talking about the maximum number for a certain parent key, answer is:
Each extended key has 2^31 normal child keys, and 2^31 hardened child
key
-https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
if your application design leads to a very large quantity of addresses, that's your own issue which you need to handle it by better design, and if you mean the compatibility with other wallets, according to bip44,
Address gap limit is currently set to 20. If the software hits 20
unused addresses in a row, it expects there are no used addresses
beyond this point and stops searching the address chain.
https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#Address_gap_limit

How to decide cost to launch ethereum smart contract on MainNet

I have written and launched a smart contract of solidity in ropsten network. And it is working well. Now I want to launch that on main net. I know few things like
1- Cost to launch depends on the opcodes. Well I have written about 50 lines of smart contract and when seeing opcodes its too large. It is tedious to calculate the approximate cost to launch on main net seeing opcodes.
2 - There is a function in web3js named estimateGas. But it used for only transaction not for launching contract.
3 - There is something like gasPrice and maxGasAmmount which can be used by a miner. Also gasPrice varies from 2 gwei to n gwei.
4 - It also depends upon the variables used in constructor.
I have also refered to this website https://ethgasstation.info/index.php and https://www.myetherwallet.com but couldn't get much info. What can be the gas price and max gas price which can be kept for an ideal contract having some basic functionalities like transfer tokens, check balance, maintain owner and transfer owner etc.
I want to make around 10 billion tokens on main net. Is it possible? If yes what can be the approximate cost for that considering March 2018 for that. I don't mind waiting for 5-15 minutes to launch the contract.
estimateGas will tell you exactly how much gas you need, but pretty much any tool you use to deploy will call that for you. (Yes, that's for estimating the gas usage of a transaction, but deploying a contract is a transaction.)
You already launched to Ropsten, so presumably you managed to use a sensible gas amount then. Do whatever you did to deploy that time.
For the gas price, https://ethgasstation.info/ is indeed a good resource. Right now 2 gwei looks good if you're not in a hurry.