Newbie question. On every contract I made, I have ability to create token, which will become 'the money' exchange in my smart contract. What I don't understand is, how to specify exchange rate of my token to Ether? When people want to buy my token, how to specify the amount of ether or money?
1 Answer
Two main options.
- A standing offer in your contract. The simplest policy is a peg: "we buy and sell these tokens for one ETH each". It can literally be any policy you can define since it will be enforced by the token contract.
- Get the token listed on an exchange. Token value is discovered in a bid/ask marketplace. If that sounds interesting, investigate ERC20 standard interface. This is appropriate if the token represents some sort of bearer instrument with "backing" that convincingly gives the holder a claim. Any form of asset, privilege or revenue steam you can code is a candidate for the property that gives the token value. The market will discover the value of a token.
Hope it helps.
msg.value
field at the time of dispersing tokens.