{"id":18625643,"url":"https://github.com/varugasu/ether-deploy_contract","last_synced_at":"2025-07-04T09:36:03.592Z","repository":{"id":112596706,"uuid":"154729704","full_name":"varugasu/Ether-Deploy_Contract","owner":"varugasu","description":"Simple Contract deployment into Rinkeby Test Network","archived":false,"fork":false,"pushed_at":"2018-10-25T19:57:41.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-29T10:57:32.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/varugasu.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-25T19:57:37.000Z","updated_at":"2018-10-25T19:57:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7568885-2983-4813-831a-1f1fb4aa2a8d","html_url":"https://github.com/varugasu/Ether-Deploy_Contract","commit_stats":null,"previous_names":["varugasu/ether-deploy_contract"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/varugasu/Ether-Deploy_Contract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varugasu%2FEther-Deploy_Contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varugasu%2FEther-Deploy_Contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varugasu%2FEther-Deploy_Contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varugasu%2FEther-Deploy_Contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varugasu","download_url":"https://codeload.github.com/varugasu/Ether-Deploy_Contract/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varugasu%2FEther-Deploy_Contract/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263483954,"owners_count":23473670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T04:35:29.366Z","updated_at":"2025-07-04T09:36:03.526Z","avatar_url":"https://github.com/varugasu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contract Deployment in Web3.py\n\n## Deploying contract in Rinkeby Test Network through Infura API\n\n### Requirements:\n\n- web3.py 4.7.2\n- API Key from [infura.io](https://infura.io)\n- Source account and its private key\n\n```\ninfuraApi = 'API'\naccount = 'SRC ACCOUNT'\nkey = 'PRIVATE KEY'\n```\n\n#### Contract:\n\n```\npragma solidity ^0.4.22;\n\ncontract HelloWorld {\n    string public message;\n\n    constructor() public {\n        message = \"Hello, World!\";\n\n    }\n\n    function setMessage(string text) public payable{\n        require(msg.value \u003e= 0.01 ether);\n        message = text;\n    }\n\n}\n```\n\nA simple \"Hello, World\" program that allows to change its message which call be called with \u003ccode\u003e\".message().call()\"\u003c/code\u003e.\n\n#### Compiling the Contract:\n\n```python\nfrom utils import contractSource\nfrom solc import compile_source\n\ncontractCompiled = compile_source(contractSource(\"HelloWorld\"))\ncontractInterface = contractCompiled['\u003cstdin\u003e:HelloWorld']\n```\n\n###### Note: \u003ccode\u003econtractSource\u003c/code\u003e is a function defined in src/utils.py and its read the HelloWorld.sol file's content.\n\n#### Creating the Contract:\n\n```python\nhelloWorld = w3.eth.contract(abi=contractInterface['abi'], bytecode=contractInterface['bin'])\n```\n\n\u003ccode\u003econtractInterface\u003c/code\u003e returns a \u003ccode\u003edict\u003c/code\u003e with the Contracts inside of .sol file. In this cenario there is only one \"HelloWorld\".\n\n#### Building the transaction and sending it:\n\n##### Defining the transaction's parameters:\n\n```python\ntxParams = {\n    'gas': 2000000,\n    'gasPrice': w3.eth.gasPrice,\n    'nonce': w3.eth.getTransactionCount(account),\n    'chainId': 4,  # Rinkeby Test Network\n    'from': account\n}\n```\n\n##### Associating transaction's parameters with the Contract:\n\n```python\ntx = helloWorld.constructor().buildTransaction(txParams)\n```\n\n##### Signing the transaction with creator account's private key:\n\n```python\nsignedTx = w3.eth.account.signTransaction(tx, key)\n```\n\n##### Sending the transaction to the Rinkeby Test Network:\n\n```python\ntxReceipt = w3.eth.sendRawTransaction(signedTx.rawTransaction)\n```\n\nIf \u003ccode\u003esendRawTransaction\u003c/code\u003e is successful it returns a hash: \u003ccode\u003e0xea1bb31684fa63f13008f11c3ddbfed444835e9e8d0a279ff806e52b8e527b95\u003c/code\u003e\n\nwhich can be used to get the transaction's detail. Check in [rinkeby.etherscan.io](https://rinkeby.etherscan.io/tx/0xea1bb31684fa63f13008f11c3ddbfed444835e9e8d0a279ff806e52b8e527b95).\n\n##### Getting transaction's detail:\n\n```python\nreceipt = w3.eth.waitForTransactionReceipt(txReceipt)\n```\n\nThe function above returns the following dictionary:\n\n```python\nAttributeDict({'blockHash': HexBytes('0x68dc9bc28a5e8fa2f5ff6325f13e8bd2f0560ca543bf011d71f9e1ed00f86e5c'),\n 'blockNumber': 3224432,\n 'contractAddress': '0x327fE98DaF48836e982396cF3cf4Bf468Ca11Ea8',\n 'cumulativeGasUsed': 5460633,\n 'from': '0xf31a44312c4cc8cfd207e5baa654f5597e461552',\n 'gasUsed': 282543,\n 'logs': [],\n 'logsBloom': HexBytes('a lot of zeros'),\n 'status': 1,\n 'to': None,\n 'transactionHash': HexBytes('0xea1bb31684fa63f13008f11c3ddbfed444835e9e8d0a279ff806e52b8e527b95'),\n 'transactionIndex': 9})\n```\n\nThe 'contractAddress' field will be used to interact with the deployed contract in the next section.\n\n#### Defining the interface and interacting with it:\n\n```python\nhelloWorldInstance = w3.eth.contract(\n   receipt.contractAddress,\n   abi=contractInterface['abi'],\n)\n```\n\n```python\nhelloWorldInstance.functions.message().call() # returns \"Hello, World!\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarugasu%2Fether-deploy_contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarugasu%2Fether-deploy_contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarugasu%2Fether-deploy_contract/lists"}