Hi @chim4us,
Please post a copy of your code (both contracts) so we can see exactly what the problem is, and what you have/haven’t managed to do so far. Then we can provide you with the help you need
Hi @chim4us,
Please post a copy of your code (both contracts) so we can see exactly what the problem is, and what you have/haven’t managed to do so far. Then we can provide you with the help you need
On my external contract i wantt o use below to get person details
function ExGetPrs() public returns (string memory name, uint age,uint hight,bool senior){
string memory Name = instance.getPerson().Name;
People[Creator].Name, People[Creator].Age, People[Creator].Hight,People[Creator].senior
}
On my main contract thats the person function
function getPerson ()public view returns (string memory name, uint age,uint hight,bool senior){
address Creator = msg.sender;
return(People[Creator].Name, People[Creator].Age, People[Creator].Hight,People[Creator].senior );
}
Hi @chim4us,
Sorry for the delay in getting back to you on this.
Are you trying to recreate the code from the video lesson on external contracts from the OLD Ethereum Smart Contract Programming 101 course? Or is this your own extension and experiment with the code from that lesson? I’m asking, because without seeing your full code from both contracts, it’s difficult to understand what the overall context is. And depending on that, I may need to make different suggestions.
The contract with the external function you are calling (getPerson) is the external contract.
Do you already have the following?
Once you have those, you can call your external function within exGetPrs() with:
instance.getPerson()
If getPerson() is the only external function you’re calling from your contract — and you’re not also making an external function call to create a Person instance mapped to the contract address you’re calling from — I can only assume that you want the same addresses, which have already created Person instances in the external contract, to be able to call getPerson() from the other contract to retrieve the data about the person they created. Is that correct? To be able to do that you will have to add an address parameter to getPerson() so that the caller of exGetPrs() has their own address passed to getPerson() and not the contract address. If there is no parameter, then msg.sender in getPerson() refers to the contract address (which hasn’t created a Person) and not the caller of exGetPrs() who wants to retrieve the person mapped to their address (not the contract address) in the mapping in the external contract. You can do this like this:
/* getPerson() called from within exGetPrs() */
instance.getPerson(msg.sender)
/* External contract */
function getPerson(address _recordHolder) public view
returns(string memory _name, uint _age, uint _height, bool _senior) {
return(
People[_recordHolder].name, People[_recordHolder].age,
People[_recordHolder].height, People[_recordHolder].senior
);
}
If you want to return all of the data for a person, without manipulating it in any way, then the only code you need to put in your exGetPrs() function body is…
return instance.getPerson(msg.sender);
You can’t extract the individual values returned, by using dot notation to append their property names to the function call. Instead, you need to extract them, and assign them to separate local variables, using destructuring assignment, as follows:
(string memory _name, uint _age, uint _height, bool _senior) =
instance.getPerson(msg.sender);
You can then reference each of these local variables separately, by their name, to manipulate them before returning the values you want to return.
If you don’t want to extract all of the returned values, or if you just want to exact one of them, then you can omit the declarations of the local variables you don’t need, but leave the commas, so that both sides of the assignment operator have the same number of components e.g.
(string memory _name,,,) = instance.getPerson(msg.sender);
return _name;
// or
(string memory _name,, uint _height,) = instance.getPerson(msg.sender);
return (_name, _height);
You can read about this technique and syntax in the documentation:
https://docs.soliditylang.org/en/latest/control-structures.html#destructuring-assignments-and-returning-multiple-values
I really don’t understand what it is you’re trying to do with this line of code in exGetPrs()…
Hello Jesus, how have you solved the problem? Share the solution in the foro to help when others have the same problem. Thank you!
The solution was just to refresh the Remix page (using Chrome) …
Are you experiencing problems that you need help with? If so, then let us know so we can help you.The post you are referring to is from over a year ago.
Thanks, I have achieved the popup that requests a metamask connection to the game. At the end of the game I get a prompt asking for my eth address, I put my eth address but I do not receive the confirmation of “transaction completed”, Looking at Etherscan and there is no minted tokens. Any idea what happens? Thank you!
If your question is related to the Ethereum Game Programming, then that’s a different course, and you need to post this question here. This discussion topic is for students who have been following the Ethereum Smart Contract Programming 101 course, and involves deploying a more straightforward contract on the testnet. I would gladly help you but, unfortunately, I’m not familiar with the Game Programming course. I’m tagging the Specialist @thecil who I think should be able to answer your question, once you’ve re-posted it, or who will be able to get the right person to help you
Hey @Valeria_dos_Santos, hope you are ok.
Could you please explain me a little bit about the issue?
Are you trying to deploy a contract on a testnet from remix?
In Ethereum Smart Contract Programming 101 we do not explain how to deploy contracts on the network on a testnet.
Which process are you trying to follow for achieve that?
Carlos Z
Hi Carlos, I wrote now to the other group “Game development”, sorry I was a bit confused about how this foro works.
Don’t worry, I’ve alerted him and he is looking at it for you in the other topic
Hello guys,
I`m trying to deploy by truffle to testnet polygon Mumbai a smart contract ,
However it does not work with my contract.
It worked with another smaller contract , but with this one which imports different libraries it doesnt work .
Any ideas ?
Compiling .\contracts\TenesseERC20.sol
Compiling .\contracts\interfaces\IERC20.sol
Compiling .\contracts\libraries\Address.sol
Compiling .\contracts\libraries\Counters.sol
Compiling .\contracts\libraries\SafeMath.sol
Compiling .\contracts\types\ERC20.sol
Compiling .\contracts\types\Ownable.sol
Artifacts written to C:\Users\John\polygon-truffle\build\contracts
Compiled successfully using:
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
code: -32603,
message: ‘Too Many Requests’,
data: { originalError: {} }
})
at new NodeError (internal/errors.js:322:7)
at Web3ProviderEngine.emit (events.js:389:17)
at C:\Users\John\node_modules\web3-provider-engine\index.js:54:14
at afterRequest (C:\Users\John\node_modules\web3-provider-engine\index.js:148:21)
at C:\Users\John\node_modules\web3-provider-engine\index.js:174:21
at C:\Users\John\node_modules\web3-provider-engine\index.js:232:9
at C:\Users\John\node_modules\async\internal\once.js:12:16
at replenish (C:\Users\John\node_modules\async\internal\eachOfLimit.js:61:25)
at C:\Users\John\node_modules\async\internal\eachOfLimit.js:71:9
at eachLimit (C:\Users\John\node_modules\async\eachLimit.js:43:36)
at C:\Users\John\node_modules\async\internal\doLimit.js:9:16
at end (C:\Users\John\node_modules\web3-provider-engine\index.js:211:5)
at C:\Users\John\node_modules\web3-provider-engine\subproviders\rpc.js:52:18
at Request._callback (C:\Users\John\node_modules\web3-provider-engine\subproviders\rpc.js:53:11)
at Request.self.callback (C:\Users\John\node_modules\request\request.js:185:22)
at Request.emit (events.js:400:28)
Hey @builder9999, hope you are well.
Please share your truffle config file and the contract you are trying to deploy in the following way so we can help you
Carlos Z