NEWTON

NEWTON


Popular tags

    How to setup local Starknet node with Account contracts?

    Asked

    4 months ago

    65

    views


    1

    does anybody have a working local setup ? I find myself having to run tests on the testnet...

    I tried both nile and protostar. the problem is that I can set it up but I don't know how to get access to the accounts that are pre-loaded with ETH. new accounts that I create don't have ETH and I don't have a way to transfer ETH to them..

    if anybody has a go-to setup that they can share that'd be much appreciated 🙏

      starknetcairo

    ggballas

    asked

    4 months ago


    1 answers

    1

    Accepted answer

    So if you are testing on Goerli, you can use the faucet to get some testnet Eth (https://faucet.goerli.starknet.io/)

    If you are testing locally, you can load the starknet-devnet private keys using this sample code (if you are happy to use starknet-py):

    from starknet_py.net.gateway_client import GatewayClient
    from starknet_py.net.networks import TESTNET
    from starknet_py.net import AccountClient, KeyPair
    from starknet_py.net.models.chains import StarknetChainId
    from starknet_py.net.signer.stark_curve_signer import StarkCurveSigner
    from starknet_py.contract import Contract
    
    node_url = "http://localhost:5050" 
    private_key = "ENTER HERE"
    address = "ENTER HERE"
    key_pair = KeyPair.from_private_key(key=int(private_key, 16))
    signer = StarkCurveSigner(address, key_pair, StarknetChainId.TESTNET)
     account_client = AccountClient(client=gateway_client,
           address=player_address, signer=signer)
    
    contract_address = "ENTER HERE"
    abi = "LOAD YOUR ABI"
    testing_contract = Contract(address=contract_address, abi=abi, client=account_client)
    

    Otherwise, you can use starknet-devnet faucet to get some funds:

    https://github.com/Shard-Labs/starknet-devnet#mint-token---local-faucet

    I don't know about Protostar, but if you are using Nile I would recommend you deploy your account contract, and then use the faucet to send funds to that address.

    answered

    4 months ago

    Your answer

    NEWTON

    NEWTON