New answers tagged

0

Assuming you have been activated personal rpc of your geth, to do this programatically without hardcoding the keystore file directory path in python, do the following: from web3 import Web3 import eth_keys from eth_account import account w3 = Web3(Web3.HTTPProvider('http://127.0.0.1')) password = 'password' address = web3.personal.newAccount('password') ...


0

Assuming you have been activated personal rpc of your geth, to do this programatically without hardcoding the keystore file directory path in python, do the following: from web3 import Web3 import eth_keys from eth_account import account w3 = Web3(Web3.HTTPProvider('http://127.0.0.1')) address = '0x...' password = 'password' wallets_list = w3.geth.personal....


0

I don't know if you got this fix but in case someone else needs it. on your deploy_lottery.py you need to return the lottery variable. on your deploy_lottery.py you need to return the lottery variable. def deploy_lottery(): account = get_account() lottery = Lottery.deploy( get_contract("eth_usd_price_feed").address, get_contract("...


1

I found the answer myself! (Not sure if it's the best thing to do but here's how) Step 1: Get the ABI for the contract you want to create a source of. In my case, it was a contract that was importable through brownie so: from brownie import AstroSwapExchange, AstroSwapFactory [...] exchangeAbi = AstroSwapExchange.abi Step 2: Use Contract.from_abi to create ...


2

Is there a way for me to build the transaction without the smart contract validation, package it up and send it. This risks my contract failing on the chain and costing me gas fees, but it's a risk I'm willing to take. If I understand correctly, you are almost there, just remember that what you call "smart contract validation" is just the gas ...


1

If you read Brownie's Account class documentation you will find out that the parameters for transfer() are: Account.transfer(self, to=None, amount=0, gas_limit=None, gas_price=None, max_fee=None, priority_fee=None, data=None, nonce=None, required_confs=1, allow_revert=None, silent=False) You are passing data_to_send to amount. Amount is the ETH amount ...


0

I did a brownie pm install for both the packages and also added following in the settings.json for Solidity { "workbench.colorTheme": "Default Dark+", "editor.formatOnSave": true, "python.formatting.provider": "black", "solidity.compileUsingRemoteVersion": "0.6.0", "editor.minimap....


0

Another thing you can do is to retrieve the hash, and look up transaction by hash and it will give you details. Slow though as every hash in transactions needs to be looked up.


3

The way how to do this depends on the contract that you want to extract the variable from. If the contract normally provides a function to query this variable you just need to know the correct function id to query it. If this is not the case then you can use eth_getStorageAt to query the storage at a specific slot for that contract, but for this you will ...


0

I think you first have to pass the arguments into TimesLock.deploy and then last the dictionary {"from":account}. So maybe something like times_lock = TimesLock.deploy(_beneficiary, _releaseTime, {"from": account})


0

You have misplaced an parenthesis pancakeswap2_txn = contract.functions.swapExactTokensForTokens( buyamount, int(minimum), path,sender_address, (int(time.time()) + 10000) /// <--- 1 parenthesis was missing here ).buildTransaction({ 'from': sender_address, 'gasPrice': web3.toWei(float(gas), 'gwei'), 'nonce': web3.eth....


0

From the docs: When creating a new log filter, the filter_params should be a dictionary with the following keys. address: string or list of strings, each 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate. Have you tried address instead of from?


0

My service Trading Strategy gives you pool liquidity information you are looking for. You can get both historical and real time liquidity added over an API. You can also interactively view this on the website. A liquidity chart example for KLIMA-USDC pair. Read our introduction post on liquidity charts and API. Here is a partial Python example how to get ...


0

Will these two gas APIs help you? https://docs.etherscan.io/api-endpoints/gas-tracker https://docs.ethgasstation.info/


0

This is for those who might want to be clarified on the wallet/account concepts on Ethereum, thanks to @mikko-ohtamaa. The answer is YES and NO. Wallets have nothing to do with the structure being used in blockchains to track down the balances or handle transactions. It is just a file containing accounts' info(public/private keys) and web3.eth.accounts....


0

This is for those who might want to be clarified on the wallet/account concepts on Ethereum, thanks to @mikko-ohtamaa. Wallets have nothing to do with the structure being used in blockchains to track down the balances or handle transactions. It is just a file containing accounts' info(public/private keys) and web3.eth.accounts.wallet-based commands mentioned ...


1

You do not need geth to create a wallet. Ethereum account is just a private key that is a large 256-bit random integer. Then this private key can be imported to any wallet software or your own program.


1

Any suggestions for an architecture to reach to Bitcoin's wallet structure for Ethereum? My suggestion is don't. Ethereum is not a UTXO blockhain, but an account-based one. Any Bitcoin like wallet structure on Ethereum is not practical, or not needed. For creating a hot wallet please see this answer.


0

I had seen other mint functions before. But this one is a bit unusual. However, as far as I can read this all three variables have a clear definition. Address(0) -> Is null address, and the function is making sure you do not mint coins on null address, as any tokens minted there would be invalid/unusable by default. Account -> Is a valid address to ...


0

Your script is importing dotenv but not actually using it. You must actually call load_dotenv(), not just import it.


1

The issue is that you're using .call() method which is meant to be used when you only want to read the blockchain. If you want to write on the blockchain ( and usually transfer method means you want to transfer particular amount from one wallet to another which is basically writing on the blockchain ) then you have to use the .transact() method. In your case ...


0

Your script establishes a network connection to an Ethereum node running at Infura. This means that you can use the JSON-RPC API to send commands to the node which lets you execute transactions, check balances, etc. web3.py is using that API to let you deploy contracts and interact with them. MetaMask is a browser extension that can also establish a ...


0

The function selector or method id is the first 4 bytes of the hash of the method name and the parameters. This is documentend here https://solidity-by-example.org/function-selector/ More details are also available here What is a function selector? There are also database where you can look these up. For example https://www.4byte.directory/


1

I think you need to specify the router address and not the factory address to execute a trade....


0

For this it is important to understand how function calls are encoded. The first part is to calculate the function selector. This is a 4byte identifier of the method that starts the calldata. (See https://docs.soliditylang.org/en/v0.8.11/abi-spec.html?highlight=Function%20id#function-selector). For you example the function selector would be the keccak hash ...


0

You set _address to msg.sender when you define it. Therefore the value is set on deployment of the contract to the deployer and after that never updated. If you want to have the msg.sender of the call to registerUser you need to read msg.sender inside this function. A possible change could look this way: function registerUser( string memory _name,...


1

Create a config.py in the same directory with the file you want to import config, put to this file private="xxxxx" In the file you want to import import config ... print(config.private) // xxxxx And add config.py to .gitignore file


Top 50 recent answers are included