General Thread for practicing question formatting! #2
Replies: 41 comments 21 replies
-
Sample Answer (take this as reference for future answers) function fund() public payable {
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
} I hope this info might help. |
Beta Was this translation helpful? Give feedback.
-
function fund() public payable{
// Want to be able to set a minimum fund amount in USD
//1. How do we send ETH to this contract
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough!");// 1e18 == 1 * 10 * 18 == 1000000000000000000 WEI
// got 18 decimal
funders.pu(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
} On this function I'm running into an error:
Can someone help me understanding it ? |
Beta Was this translation helpful? Give feedback.
-
pragma solidity ^0.8.4;
function fund() public {
require(msg.value.getConversionRate() > MINIMUM_USD);
funders.push(msg.sender);
AmountToAddress[msg.sender] = msg.value;
}
This is a sample question, only testing if I am asking questions in the best way, if not please do help. Error:
|
Beta Was this translation helpful? Give feedback.
-
function fund() public {
require(msg.value.getConversationRate() >= MINIMUM_USD,"Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
}
I'm getting the following error in this function, can anyone help? Thanks
|
Beta Was this translation helpful? Give feedback.
-
function fund() public {
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
} On this function, I'm running into an error: TypeError: "msg.value" and "callvalue()" can only be used in payable public functions. Can someone tell me what's going on? |
Beta Was this translation helpful? Give feedback.
-
//practice answer "Just add payable to the fund function. That should fix it."
function fund() public payable{
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
} |
Beta Was this translation helpful? Give feedback.
-
function fund() public {
require((msg.value).getConversionRate() >= MIN_USD, "Min amount is 50 USD");
funders.push(msg.sender);
fundAmountList[msg.sender] += msg.value;
} On this function I run into the following error:
Can somebody help me with this? |
Beta Was this translation helpful? Give feedback.
-
Praticing function fund() public payable {
require(msg.value.getConversionRate() >= MINIMUM_USD, "You need to spend more ETH!");
// require(PriceConverter.getConversionRate(msg.value) >= MINIMUM_USD, "You need to spend more ETH!");
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
} Thanks Patrick |
Beta Was this translation helpful? Give feedback.
-
***For practice only function fund() public {
require((msg.value).getConversionRate() >= MIN_USD, "Min amount is 50 USD");
funders.push(msg.sender);
fundAmountList[msg.sender] += msg.value;
} On this function I'm running into this error:
Can someone please explain what's going on? |
Beta Was this translation helpful? Give feedback.
-
Practice function fund() public {
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
}
On this function I'm running into this error: "msg.value" and "callvalue()" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error. Can someone please explain what is going on |
Beta Was this translation helpful? Give feedback.
-
Practise: function withdraw() onlyOwner{
// for (/* starting index, ending index, step amount */) // Funderindex + 1 is same as Funderindex++
for (uint256 funderIndex = 0; funderIndex < funders.length; funderIndex++){
// code
address funders = funders[funderIndex];
addressToAmountFunded[funders] = 0;
}
On this function I am getting this error:
Can somebody tell he what is going on? |
Beta Was this translation helpful? Give feedback.
-
Practise formatting: modifier onlyOwner {
//require(msg.sender == i_owner, "Sender is not owner!");
if(msg.sender != i_owner) {revert NotOwner();}
_; // to run the rest of the code after the statement above
} Im running into an error with this code snippet. Can someone help me?
|
Beta Was this translation helpful? Give feedback.
-
Practice formatting: Running into an error on my receive function: receive() external payable {
fund()
} Error Message:
Anyone know what this means? |
Beta Was this translation helpful? Give feedback.
-
Hi Patrick, I'll be glad to help you (I wish I could haha), you are been asked to add payable to the function, I did add it and it looks like this: function fund () public payable {
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough ETH!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
} You will not receive any error after adding "payable", I hope it helps you. Thx Patrickkkkkk!!! |
Beta Was this translation helpful? Give feedback.
-
Lesson 5 Practice
I was running into the same error until I added payable keyword into the function. function fund() public payable {
require(msg.value.getConversionRate() >= MINIMUM_USD, "You need to spend more ETH!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
} Hope this helps! ;) |
Beta Was this translation helpful? Give feedback.
-
this is the message I get at the top left on line 1. any help would be appreciated // SPDX-license-Identifier: MIT contract SimpleStorage { That is what i have so far, but getting an error on line 1 about SPDX license.. Thank you in advance |
Beta Was this translation helpful? Give feedback.
-
function fund() public {
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
} On this function I'm running into an error: TypeError: "msg.value" and "callvalue()" can only be used in payable public functions. Can someone please tell me what's going on? |
Beta Was this translation helpful? Give feedback.
-
receive() external {
fund();
} I'm having this type of error
Can someone help me understand? |
Beta Was this translation helpful? Give feedback.
-
Hi hardhat-freecodecamp - you need to make the public function function fund() public payable {
//we want to be able to set a minimum fund amount in USD
//How do we send ETH to this contract? => payable keyword allows contract to hold ETH
require(msg.value.getConversionRate() >= MINIMUM_USD, "Feed me more."); //1e18 == 1 * 10 ** 18 == 1000000000000000000 wie = 1 ETH
//18 decimal places
funders.push(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
} Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
This should fix it: function fund() public payable {
require(
msg.value.getConversionRate() >= MINIMUM_USD,
"Didn't send enough!"
);
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
} |
Beta Was this translation helpful? Give feedback.
-
function getConversionRate(uint256 ethAmount) view returns(uint256){
uint256 ethtodollarPrice = getPrice();
uint256 ethAmountInUsd = (ethtodollarPrice * ethAmount) / 1e18;
return ethAmountInUsd;
} I'm running into the error below on this function:
Can someone help? |
Beta Was this translation helpful? Give feedback.
-
TEST ANSWER: Hey! The problem is that you didn't add a "payable" to your function, which is necessary when you're receiving funds in a smart contract. Specifically, your function header should look like this: function fund() public payable {} |
Beta Was this translation helpful? Give feedback.
-
function fund() public {
require(msg.value.getConversionRate() >= MINIMUM_USD, "Please send more!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
}
Just testing a thread ;) |
Beta Was this translation helpful? Give feedback.
-
Testing formatting. function fund() public {
//Want to be able to set a minimum fund amount
//1. How do we send ETH to this contract?
//Contracts can hold funds like wallets do
require(msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough"); //1e18 == 1 eth in wei, also need to get ETH to USD for this (oracle)
funders.push(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
} On this function I am running into an error (below)
|
Beta Was this translation helpful? Give feedback.
-
Practicing question formatting: pragma solidity ^0.8.8;
function fund() public {
require(msg.value.getConversionRate() > MINIMUM_USD);
funders.push(msg.sender);
AmountToAddress[address] = msg.value;
} On the above function, I am receiving the following error upon deployment:
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone, running into this issue with my solidity function. Can anyone help me out? pragma solidity ^0.8.0;
contract MyContract {
event Log(string message);
function myFunction() public {
emit Log("
P is for his Programming skills, so top-notch
A is for his Ability to teach with grace and watch
T is for his Tenacity, always pushing us to learn
R is for his Resourcefulness, making concepts easy to discern
I is for his Insight, always knowing the best path
C is for his Coolness, keeping us calm in the aftermath
K is for his Knowledge, which he shares so freely
Patrick, our instructor, with his help we'll surely see
Solidity and Web3, a world that's now less scary
Thank you Patrick, for making it all so very merry!"
);
}
} |
Beta Was this translation helpful? Give feedback.
-
Practice test:
Can someone help me with this function, the error i'm getting is:
|
Beta Was this translation helpful? Give feedback.
-
Practice test: Help! function fund() public {
//msg.value.getConversionRate();
require(msg.value.getConversionRate().help >= minimumUSD, "Didn't send enough! MOAR!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
} Error in question: from solidity:
When I was younger, so much younger than today
NeedError: "help.value" and "helpvalue()" cannot be used when you need nobody's help in any way.
Ensure that those days are gone and you're not so self-assured.
Then you'll find function "changeYourMind()" or open up the doors in the internal function to avoid this error.
--> Contracts/32 Hour Course Projects/Lesson 4/FundMe.sol:30:17:
|
30 | require(msg.value.getConversionRate() >= minimumUSD, "Didn't send enough! MOAR!");
| ^^^^^^^^^ Help me if you can, I'm feeling down |
Beta Was this translation helpful? Give feedback.
-
function getVersion() internal view returns (uint256){
AggregatorV3Interface pricefeed = AggregatorV3Interface(0x694AA1769357215DE4FAC081bf1f309aDC325306);
return pricefeed.version();
} Im not really sure what to do with this
|
Beta Was this translation helpful? Give feedback.
-
Practice test function fund() public {
require (msg.value.getConversionRate() >= MINIMUM_USD, "Didn't send enough");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] = msg.value;
} Pls can someone help me with this, i am getting this error message
|
Beta Was this translation helpful? Give feedback.
-
On this function, I'm running into an error:
Can someone tell me what's going on?
Beta Was this translation helpful? Give feedback.
All reactions