question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`deployContract` of the `RpcProvider` throws an error

See original GitHub issue

Issue Description

From Consensys:

When using the “deployContract” function of the “RpcProvider” class, we always get the following error:

Error: -32602: More than 64 digits found: 76 at line 1 column 147
  at RpcProvider.eval (eval at <anonymous> (eval at <anonymous> (lockdown.umd.min.js:1:18455)), <anonymous>:70169:35)

I think the root cause is that inside the function, constructorCalldata was converted to decimal string and passed to starknet_addDeployTransaction, but they should instead be in hex string…

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dkillencommented, Aug 26, 2022

@jonesho & @ivpavici I came to a similar solution and have submitted a PR to fix this bug.

1reaction
dkillencommented, Aug 23, 2022

Hi @ivpavici

The project I am working on is currently using the OZ Cairo contracts v0.3.1. I am just using the basic Account preset:

%lang starknet

from openzeppelin.account.presets.Account import constructor

I am first instantiating a Provider based on the users config (either rpc or sequencer):

let starkNetProvider;
if (network.rpc_url) { // instantiate an RPCProvider
  starkNetProvider = new Provider({
    rpc: {
      nodeUrl: network.rpc_url
    }
  });
} else { // instantiate a SequencerProvider
  starkNetProvider = new Provider({
    sequencer: {
      baseUrl: network.base_url,
      feederGatewayUrl: network.feeder_gateway_url,
      gatewayUrl: network.gateway_url
    }
  })
}

The configuration file provides the following:

    testnet: {
      network_id: "goerli-alpha",
      rpc_url: "https://starknet-goerli.infura.io/v3/" + infuraApiKey,
      // StarkNet sequencer endpoints.
      // base_url: "https://alpha4.starknet.io",
      // feeder_gateway_url: "feeder_gateway",
      // gateway_url: "gateway",
      block_explorer_url: "https://goerli.voyager.online"
    },

Account keys are generated with the following:

const accountKeyPair = ec.genKeyPair();
const accountPublicKey = ec.getStarkKey(accountKeyPair);
const accountPrivateKey = `0x${accountKeyPair.getPrivate('hex')}`;

Contract is deployed with the following:

const callData = [
  accountPublicKey
];
const deployContractResponse = await starkNetProvider.deployContract({
  contract: compiledAccountContract,
  constructorCalldata: callData,
  addressSalt: accountPublicKey
});

This pattern works to successfully deploy an account with the sequencer provider. It fails with the following error when using the rpc provider:

/Users/david/dev/trufflesuite/boxes/starknet-box/node_modules/starknet/dist/provider/rpc.js:90
                            throw new Error("".concat(code, ": ").concat(message));
                                  ^

Error: -32602: More than 64 digits found: 76 at line 1 column 149
    at RpcProvider.<anonymous> (/Users/david/dev/trufflesuite/boxes/starknet-box/node_modules/starknet/dist/provider/rpc.js:90:35)
    at step (/Users/david/dev/trufflesuite/boxes/starknet-box/node_modules/starknet/dist/provider/rpc.js:33:23)
    at Object.next (/Users/david/dev/trufflesuite/boxes/starknet-box/node_modules/starknet/dist/provider/rpc.js:14:53)
    at fulfilled (/Users/david/dev/trufflesuite/boxes/starknet-box/node_modules/starknet/dist/provider/rpc.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Thanks @janek26 I will take a look into this myself if I can make some time to do so. I have submitted a PR previously, albeit just a minor documentation fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: cannot estimate gas; transaction may fail or may require ...
I frequently get errors like the following: Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: ...
Read more >
Replacement fee too low - node.js - Stack Overflow
I run the script with truffle with truffle exec script.js --network testnet and I get this error and I don't know why I...
Read more >
Why is an 'UNPREDICTABLE_GAS_LIMIT' error thrown when ...
In my case, I got that exact error message because I instantiated a contract using an incorrect address. Fixing the address made the...
Read more >
Documentation - Ethers.js
If the current environment does not have a secure entropy source, an error is thrown. Wallets created using this method will have a...
Read more >
hardhat cannot estimate gas; transaction may fail or ... - You.com
The "function selector was not recognized" error message is thrown when you're ... Hardhat deploy contract error: Error: cannot estimate gas; transaction ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found