NEWTON

NEWTON


Popular tags

    Declaring a StarkNet contract on DevNet with Account(), but I get GatewayError in StarkNetJS

    Asked

    1 month ago

    67

    views


    0

    Hey! With starknetjs(4.15.1) I am trying to declare a contract on devnet(0.4.2) using one of predeployed accounts:

    const account = new Account(
      provider,    '0x33507ff2edf12c12c73d0b6d1d90de9fac12a355de1097ab305249612451919',
      ec.getKeyPair('0x1de9ea6670d3da1fc735df5ef7697fb9')
    );
    ...
    const response = await account.declare({contract, classHash})
    

    In return I get:

         GatewayError: Error at pc=0:124:
    Signature (190318159909676960154007463740407923762489366165178197276822367516441018681, 1481560316189074241501727945883196969140908548840364106059171525936237675551), is invalid, with respect to the public key 1739835831186746845112715264902076958080619051586179661985458614041125785393, and the message hash 1015445806423683747697120201561835375586563571781789449937604429244570518935.
    Cairo traceback (most recent call last):
    Unknown location (pc=0:615)
    Unknown location (pc=0:600)
    Unknown location (pc=0:245)
    
      cairostarknetjsstarknet

    0x4529...d70f89

    asked

    1 month ago


    1 answers

    0

    Accepted answer

    Account and declare code look fine. I can see two possible issues: The first one is an issue with reading the JSON contract file and the second one is a mismatch in the Account - Key Pair.

    It is good practice to run devnet with a flag

    -seed 0
    

    so that we can reproduce the same account and key.

    This is how we parse json

      json.parse(
        fs.readFileSync(path.resolve(__dirname, `../__mocks__/${name}.json`)).toString('ascii')
      );
    

    json needs to support bigint we use

    'json-bigint'
    

    https://github.com/0xs34n/starknet.js/blob/develop/src/utils/json.ts

    Toni Tabak

    answered

    1 month ago

    Your answer

    NEWTON

    NEWTON