Ever wondered how to add blockchain or transaction information to your Smart Contract❓
🌐Use Global Variables
👇Here's how ( 🧵)
In Solidity, there are certain global variables that are used mainly to provide information about the blockchain or for general-purpose utility functions.
Let's review some of them👇
⚡️'msg' Global Variable:
-msg.data (bytes calldata): complete calldata
-msg.sender (address): sender of the message
-msg.sig (bytes4): first four bytes of the calldata
-msg.value (uint): number of wei sent with the message
Example:
⚡️'this' Global Variable:
Refers to the current smart contract and the returned value can be typed to an address.
⚡️'block' Global Variable:
-block.coinbase (address payable): current block miner’s address
-block.difficulty (uint): current block difficulty
-block.number (uint): current block number
-block.timestamp (uint): current block timestamp as seconds since unix epoch
⚡️'tx' Global Variable:
-tx.gasprice (uint): gas price of the transaction
-tx.origin (address): sender of the transaction (full call chain)
If you found it useful, please engage with the tweet below:
🔁 Retweet
👍 Like
💬 Comment
Drop a 👋 if you are interested in #Solidity and #Web3 content
Here are 10 concepts you need to MASTER if you want to become a Web3 developer.
🧵👇 Thread
1) WEB3:
Web 3.0 is the third generation of the Internet, based on blockchain technology, incorporating concepts such as decentralization and token-based economy and providing autonomy, privacy and security to users.
Users are in control of their own data and applications.
2) ETHEREUM:
Ethereum is an open source blockchain platform that enables developers to write Smart Contracts and deploying decentralized applications or dApps.