Created
November 1, 2022 11:14
-
-
Save Th0rgal/ff5195a2c5ed9b71b51828768d9c65d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from starknet_py.net.gateway_client import GatewayClient | |
from starknet_py.net import AccountClient | |
from starknet_py.contract import Contract | |
from starknet_py.net.signer.stark_curve_signer import KeyPair | |
from starkware.starknet.definitions.general_config import StarknetChainId | |
from starkware.starknet.public.abi import get_selector_from_name | |
import asyncio | |
abi = [ | |
{ | |
"inputs": [], | |
"name": "is_challenge_done", | |
"outputs": [{"name": "res", "type": "felt"}], | |
"stateMutability": "view", | |
"type": "function", | |
}, | |
{ | |
"inputs": [{"name": "password", "type": "felt"}], | |
"name": "test_password", | |
"outputs": [{"name": "res", "type": "felt"}], | |
"type": "function", | |
}, | |
] | |
async def start(): | |
# Local network | |
client = GatewayClient( | |
"http://[email protected]:5050" | |
) | |
account = AccountClient( | |
"0x2abac55b073938ea0529f2ef5fc69a44571f3266d4cbf528e596849526833e0", | |
client, | |
key_pair=KeyPair.from_private_key(0x8E15C2EA93934A21A2272A5D7A91FBDC), | |
chain=StarknetChainId.TESTNET, | |
supported_tx_version=1, | |
) | |
contract = await Contract.from_address( | |
"0xcd75fd5002b65b800ad41249311007f4ef47116bb19e4d11633c8618a898b7", account | |
) | |
invocation = await contract.functions["test_password"].invoke(7, max_fee=int(1e16)) | |
print(invocation) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(start()) | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment