小编E_c*_*les的帖子

该交易声明链 ID 5777,但连接的节点位于 1337

我正在尝试通过使用 python 进行交易,将我的 SimpleStorage.sol 合约部署到 ganache 本地链。连接到链条似乎有问题。

from solcx import compile_standard
from web3 import Web3
import json
import os
from dotenv import load_dotenv

load_dotenv()

with open("./SimpleStorage.sol", "r") as file:
    simple_storage_file = file.read()

compiled_sol = compile_standard(
    {
        "language": "Solidity",
        "sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
        "settings": {
            "outputSelection": {
                "*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
            }
        },
    },
    solc_version="0.6.0",
)

with open("compiled_code.json", "w") as file:
    json.dump(compiled_sol, file)


# get bytecode
bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"][
    "bytecode"
]["object"]


# get ABI
abi = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]

# to …
Run Code Online (Sandbox Code Playgroud)

python ethereum solidity smartcontracts ganache

13
推荐指数
3
解决办法
1万
查看次数

标签 统计

ethereum ×1

ganache ×1

python ×1

smartcontracts ×1

solidity ×1