Cannot invoke contract functions
See original GitHub issueIssue Description
Hello, I am new to starknet js. I’m trying to invoke a function of a contract using this code :
const { transaction_hash: transferTxHash } = await account.execute(
{
contractAddress: eykarCommunityContract.address,
entrypoint: "completeQuest",
calldata: [questId, player],
},
undefined,
{ maxFee: "0" }
);
But I get this error:
TypeError: Cannot read properties of undefined (reading '0')
at Account.<anonymous> (/home/nicolas/Desktop/Nico/eykar/API/node_modules/starknet/dist/account/default.js:125:92)
So I went to /home/nicolas/Desktop/Nico/eykar/API/node_modules/starknet/dist/account/default.js:125:92
the error is here:
Account.prototype.getNonce = function () {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.callContract({
contractAddress: this.address,
entrypoint: 'get_nonce',
})];
case 1:
result = (_a.sent()).result;
// ------------------------------------------I Added a console.log -----------------------------------------
console.log(_a.sent())
return [2 /*return*/, (0, number_1.toHex)((0, number_1.toBN)(result[/* THIS IS THE ERROR */0]))];
}
});
});
};
So I printed the source of the “result” variable in the console (_a.sent()), and I get this:
[Object: null prototype] {
code: 'StarkErrorCode.MALFORMED_REQUEST',
message: "can't use a string pattern on a bytes-like object"
}
So there’s definitely something I missed (this is the first time I’ve done this). If you have an idea of the problem, don’t hesitate. Thank you in advance
Issue Analytics
- State:
- Created 9 months ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Cannot invoke contract function from console using truffle
In the contract the function is called getHelloMessage , but you are calling getHelloWorld . You should type in the console
Read more >Cannot call function within deployed contract - Stack Overflow
Yes it is a function, defined in my contract, though console.log(contract.displayMessage) will return the object posted above. If I run console.
Read more >Unable to call other contract function · Issue #19752 - GitHub
It should allow calling other contract function using low-level call. Actual behaviour. It doesn't allow to call other contract function. My ...
Read more >Interact with your contracts - Truffle Suite
When you execute a contract's function via a transaction, you cannot receive that function's return value because the transaction isn't processed ...
Read more >How to call another smart contract from your solidity code
1. Smart contracts are the most popular feature of the Ethereum network. Smart contracts have functions ... 2. Smart contracts are computer code,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I solved the problem by changing my account. I used an account generated on ArgentX. (and the .toLowerCase() helped me with the address given by ArgentX)
I just faced this issue too, like you did I was able to track it down to
getNonce
(link)I noticed that this call fails if the address has capital letters (checksumed):
looks like Starknet fails to make calls to contracts with checksumed address, the weird thing is that executing calls works without needing to lowercase the address 🤔
when I updated my account initialization it worked
PS: I copied the address straight from Argent wallet without noticing it was checksumed.