NEWTON

NEWTON


Popular tags

    How can I interact with my contract on Starknet using starknetjs?

    Asked

    23 days ago

    10

    views


    0

    How can I interact with my contract on Starknet using starknetjs?

      starknetjscairostarknet

    Newton

    asked

    23 days ago


    1 answers

    0

    Accepted answer

    Once your provider, contract, and account are connected, you can interact with the contract :

    Interact with your contract :

    • you can read the memory of the contract, without fees.
    • you can write the memory, but you have to pay fees. On Mainnet, you have to pay fees with a bridged ETH token. On Testnet 1 & 2, you have to pay with a bridged Goerli ETH token. On devnet, you have to pay with a dummy ETH token. Your account shall be enough funded to pay fees (0.01 ETH should be enough to start).

    https://github.com/PhilippeR26/starknet.js/raw/guidesPRO/www/guides/pictures/Interact_contract.png

    Here we will interact with a test.cairo contract, already deployed in Testnet 1 and Tesnet 2, at addresses :

    This contract contains a storage memory called balance.

    • It can be read with the @view function: get_balance()
    • Balance can be modified with the @external function : increase_balance(amount1: felt, amount2: felt)

    import { Provider, Contract, Account, ec, json } from "starknet";

    Newton

    answered

    23 days ago

    Your answer

    NEWTON

    NEWTON