importing and using confusion #1045
Replies: 4 comments 9 replies
-
The directive
Here type of msg.value, which is uint256 is used implicitly for method getConversion() to tell it that: Hey function, the implicit parameter So at top if you declare it as 👉 Here is the resource you can go through more. https://www.tutorialspoint.com/solidity/solidity_libraries.htm Thanks |
Beta Was this translation helpful? Give feedback.
-
Hello Master of Blockchain 🙂 It is not necessary to add For example, if you're importing a function which adds 2 uint numbers: function add(uint256 a, uint256 b) internal pure returns (uint256) Without sum = add(a, b); With sum = a.add(b); |
Beta Was this translation helpful? Give feedback.
-
So it's just for the code to look good and clean. Right!? |
Beta Was this translation helpful? Give feedback.
-
@MasterofBlockchain I would like to clarify the concept here about Libraries. For using a library in our contract we need to use data-type represents all of the returns types of functions for that you are using library (in our case it is uint256). If you have functions with different return types for example one function's return type is uint256 and another function's return type is a string and you want to use a library for both functions to access inside the contract then you specify two times And about the import statement so it is only required when your Library and contract are in separate files but if they both are in the same file you do not need that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! If we have already this
import "./priceconvertor.sol";
in the contract then why we are usingusing priceconvertor for uint256;
.can anyone please help me to understand this?
Beta Was this translation helpful? Give feedback.
All reactions