- Mastering Ethereum
- Merunas Grincalaitis
- 160字
- 2021-06-24 15:01:07
The fallback function
This is a special type of function that doesn't have a name. It is executed whenever someone uses the .send() or .transfer() function to this contract address, similar to a default function. It is often used in ICOs to receive Ether and return the specified number of tokens for the Ether received. This allows anybody to buy tokens without having to understand and deploy the contract instance, with just the address of the contract.
Here's how it looks:
function () external payable {}
Fallback functions must be marked external to help people understand that it shouldn't be executed inside this contract by mistake. If you don't add the payable modifier, it will reject all the transactions sending it Ether.
I recommend that you should write and try different functions using the remix.ethereum.org IDE, which will show you errors and notifications about things that must be verified. That way, you'll be able to write your own contract securely.
- 數(shù)學(xué)星球:人類文明與數(shù)學(xué)(萬物皆數(shù)學(xué))
- 線性代數(shù)
- 下金蛋的數(shù)學(xué)問題
- 奧妙的數(shù)學(xué)問答
- 瘋狂的數(shù)學(xué)游戲
- 有限自動機(jī)理論
- Ethereum Smart Contract Development
- 開悟:數(shù)學(xué)黑客的生活之旅
- 妙趣橫生博弈論:事業(yè)與人生的成功之道(白金版)
- 走近費(fèi)曼叢書:費(fèi)曼講物理:相對論
- 中國數(shù)學(xué)雙基教學(xué)的史與思
- 數(shù)學(xué)與決策:數(shù)學(xué)教你做決定
- ANSYS 12.0有限元分析完全手冊
- 數(shù)字、代數(shù)和圖象(全彩版)
- 微積分Ⅱ