Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use HTTPProvider #284

Merged
merged 1 commit into from
Feb 6, 2025
Merged

fix: use HTTPProvider #284

merged 1 commit into from
Feb 6, 2025

Conversation

0xRAG
Copy link
Contributor

@0xRAG 0xRAG commented Feb 6, 2025

What changed? Why?

Basically a typo

Tested with:

if __name__ == "__main__":
    w3 = Web3()
    private_key = os.environ.get("PRIVATE_KEY")
    assert private_key is not None, "You must set PRIVATE_KEY environment variable"
    assert private_key.startswith("0x"), "Private key must start with 0x hex prefix"

    account: LocalAccount = Account.from_key(private_key)
    w3.middleware_onion.inject(SignAndSendRawMiddlewareBuilder.build(account), layer=0)

    print(f"Your hot wallet address is {account.address}")

    wallet = EthAccountWalletProvider(
        config=EthAccountWalletProviderConfig(
            private_key=private_key,
            rpc_url="https://sepolia.base.org",
            chain_id=84532,
        )
    )

    print(wallet.read_contract(
        contract_address=Web3.to_checksum_address("0x4200000000000000000000000000000000000006"),
        abi=ERC20_ABI,
        function_name="balanceOf",
        args=[wallet.get_address()],
    ))

    print(wallet.sign_message("Hello, world!"))

Output was:

Your hot wallet address is 0x9Dcd61940a94c921d8CC77472ac396deB112852E
0
67167234f530abed8ea1b4877da92f3fd25eb45ddce89752e1aae5f7045e07705909237a97fc245ea3216a06fcabd23a427ab1eacc8b96654d69823f1e9d5d721b

@0xRAG 0xRAG merged commit 3cec836 into 0.1.0-python Feb 6, 2025
8 checks passed
@0xRAG 0xRAG deleted the fix/wallet-provider branch February 6, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants