logo

Intro to Ethereum and Smart Contracts

PDF Publication Title:

Intro to Ethereum and Smart Contracts ( intro-ethereum-and-smart-contracts )

Previous Page View | Next Page View | Return to Search List

Text from PDF Page: 057

contract Mapper { event AddressMapped(address primary, address secondary); event Error(uint code, address sender); mapping (address => address) public primaryToSecondary; mapping (address => bool) public secondaryInUse; modifier secondaryAddressMustBeUnique(address secondary) { if(secondaryInUse[secondary]) { Error(1, msg.sender); throw; } _; } function mapAddress(address secondary) secondaryAddressMustBeUnique(secondary) { // If there is no mapping, this does nothing secondaryInUse[primaryToSecondary[msg.sender]] = false; primaryToSecondary[msg.sender] = secondary; secondaryInUse[secondary] = true; AddressMapped(msg.sender, secondary); } } Although this contract is a bit more complex than we have seen so far, it remains fairly accessible. Let’s break it down: • There are two events: AddressMapped and Error. The AddressMapped event is generated any time a user’s primary Ethereum address is mapped to a secondary, login-only, address. The Error event is only generated in case of errors, such as when a mapping using an existing secondary address already exists. • Thentwovariablesaredeclared:primaryToSecondaryandsecondaryInUse.primaryToSecondary is a map of addresses: given the primary address, it can tell the secondary address mapped to it. secondaryInUse is a map of addresses to booleans, used to check whether a secondary address is already in use. • Next comes secondaryAddressMustBeUnique. This special function is a modifier. Mod- ifiers in Solidity are special functions that can be attached to contract methods. These run before the method code and can be used to modify their behavior. In this case, secondaryAddressMustBeUnique uses the secondaryInUse variable to confirm whether the secondary address passed as parameter is in use. If it is, this is flagged as an error and the Error event is emitted. If it is not in use, then execution continues. The _ placeholder is where the code from the modified function is logically inserted. • And lastly there is the mapAddress method. This method takes a secondary address and maps 55

PDF Image | Intro to Ethereum and Smart Contracts

intro-ethereum-and-smart-contracts-057

PDF Search Title:

Intro to Ethereum and Smart Contracts

Original File Name Searched:

intro-to-ethereum.pdf

DIY PDF Search: Google It | Yahoo | Bing

NFT (Non Fungible Token): Buy our tech, design, development or system NFT and become part of our tech NFT network... More Info

IT XR Project Redstone NFT Available for Sale: NFT for high tech turbine design with one part 3D printed counter-rotating energy turbine. Be part of the future with this NFT. Can be bought and sold but only one design NFT exists. Royalties go to the developer (Infinity) to keep enhancing design and applications... More Info

Infinity Turbine IT XR Project Redstone Design: NFT for sale... NFT for high tech turbine design with one part 3D printed counter-rotating energy turbine. Includes all rights to this turbine design, including license for Fluid Handling Block I and II for the turbine assembly and housing. The NFT includes the blueprints (cad/cam), revenue streams, and all future development of the IT XR Project Redstone... More Info

Infinity Turbine ROT Radial Outflow Turbine 24 Design and Worldwide Rights: NFT for sale... NFT for the ROT 24 energy turbine. Be part of the future with this NFT. This design can be bought and sold but only one design NFT exists. You may manufacture the unit, or get the revenues from its sale from Infinity Turbine. Royalties go to the developer (Infinity) to keep enhancing design and applications... More Info

Infinity Supercritical CO2 10 Liter Extractor Design and Worldwide Rights: The Infinity Supercritical 10L CO2 extractor is for botanical oil extraction, which is rich in terpenes and can produce shelf ready full spectrum oil. With over 5 years of development, this industry leader mature extractor machine has been sold since 2015 and is part of many profitable businesses. The process can also be used for electrowinning, e-waste recycling, and lithium battery recycling, gold mining electronic wastes, precious metals. CO2 can also be used in a reverse fuel cell with nafion to make a gas-to-liquids fuel, such as methanol, ethanol and butanol or ethylene. Supercritical CO2 has also been used for treating nafion to make it more effective catalyst. This NFT is for the purchase of worldwide rights which includes the design. More Info

NFT (Non Fungible Token): Buy our tech, design, development or system NFT and become part of our tech NFT network... More Info

Infinity Turbine Products: Special for this month, any plans are $10,000 for complete Cad/Cam blueprints. License is for one build. Try before you buy a production license. May pay by Bitcoin or other Crypto. Products Page... More Info

CONTACT TEL: 608-238-6001 Email: greg@infinityturbine.com | RSS | AMP