ethereum

How to call a Smart Contract function using Python and web3.py

别等时光非礼了梦想. 提交于 2021-02-19 04:59:10
问题 I have a contract deployed on Ethereum test network which has some functions in it and they all happen to work while using the Remix interface. When trying to call those functions using web3.py in Python, I'm able to call only for public functions and that part works fine. The problem is calling a function with a "restriction" such as having an "owner requirement", meaning only the address which created the contract can call that specific function. I've Googled it but no luck. I'm guessing

Regular, repeating, interaction between an oracle and a smart contract

青春壹個敷衍的年華 提交于 2021-02-11 12:27:09
问题 This is just an example. I'm building this dapp where I have a start date and an end date and every day I want to get a random number from an oracle. If at some point the sum of the numbers I get every day exceeds a threshold then an OK message returns to my backend. Let's assume we have a range of 7 days. Day 1: My backend sends a request to the "smart contract Number" and calls the requestOk () method. The smart contract Number calls the gethNumber () method of the oracle smart contract and

Regular, repeating, interaction between an oracle and a smart contract

醉酒当歌 提交于 2021-02-11 12:25:59
问题 This is just an example. I'm building this dapp where I have a start date and an end date and every day I want to get a random number from an oracle. If at some point the sum of the numbers I get every day exceeds a threshold then an OK message returns to my backend. Let's assume we have a range of 7 days. Day 1: My backend sends a request to the "smart contract Number" and calls the requestOk () method. The smart contract Number calls the gethNumber () method of the oracle smart contract and

encode three integers into single integer

非 Y 不嫁゛ 提交于 2021-02-10 09:40:07
问题 I have to encode 3 numbers into the same integer. I have these 3 measurements uint256 carLength; uint256 carWidth; uint256 carDepth; and i want to encode these 3 numbers into the same integer with the possibility to decode. My problem is that I'm not very experienced at this low level. i think about functions like this function encodeNumbers(uint256 a, uint256 b, uint256 c) public view returns(uint256); function decodeNumber(uint256) public view returns (uint256, uint256, uint256); advice on

How do I notify the client application when a chaincode is invoked?

前提是你 提交于 2021-02-10 07:53:22
问题 When a chaincode is invoked, is there a way to call a REST API (external) so that the client application can be notified on the new transaction. Apart from REST, is there any other option? 回答1: It's better to use events https://github.com/hyperledger/fabric/blob/master/docs/protocol-spec.md#35-events Validating peers and chaincodes can emit events on the network that applications may listen for and take actions on. There is a set of pre-defined events, and chaincodes can generate custom

How to deposit ether to an account using solidity and web3?

孤人 提交于 2021-01-29 05:49:21
问题 I am building a sample smart contract . I am trying to deposit ether from 1 account to another but the issue is amount is deducted from the sender's account but not able to deposit to receiver's account. Here is my contract code : pragma solidity ^0.5.0; contract ApprovalContract{ address public sender; address public receiver; function deposit(address _receiver) external payable { require(msg.value > 0); sender = msg.sender; receiver = _receiver; address payable _rec = receiver.make_payable(

How to listen for incoming transactions not yet mined for a single address?

丶灬走出姿态 提交于 2021-01-28 00:04:34
问题 Using OpenEthereum, which is the json rpc call allowing to do it? I found the parity_pubsub module but I ve no idea of the parameter for getting not yet confirmed transactions. I also found https://web3js.readthedocs.io/en/v1.2.11/web3-eth-subscribe.html#subscribe-pendingtransactions in the web3 module but it doesn t allows to filter transactions and the documentation doesn t explains how to use the full web3 api along OpenEthereum. The purpose The aim is to frontrun transactions for

Uncaught Error: Returned values aren't valid, did it run Out of Gas?

家住魔仙堡 提交于 2021-01-27 05:54:49
问题 I'm listening to events of my deployed contract. Whenever a transaction gets completed and event is fired receiving the response causes following error: Uncaught Error: Returned values aren't valid, did it run Out of Gas? at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (index.js:227) at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeLog (index.js:277) Web3 version: 1.0.0-beta36 Metamask version: 4.16.0 How to fix it? 回答1: Try the

Uncaught Error: Returned values aren't valid, did it run Out of Gas?

让人想犯罪 __ 提交于 2021-01-27 05:54:10
问题 I'm listening to events of my deployed contract. Whenever a transaction gets completed and event is fired receiving the response causes following error: Uncaught Error: Returned values aren't valid, did it run Out of Gas? at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (index.js:227) at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeLog (index.js:277) Web3 version: 1.0.0-beta36 Metamask version: 4.16.0 How to fix it? 回答1: Try the

npm solc: AssertionError [ERR_ASSERTION]: Invalid callback specified

泪湿孤枕 提交于 2020-12-29 09:24:11
问题 I am trying to compile solidity smart contract using npm solc. I tried to follow different examples. Link to example: https://medium.com/coinmonks/how-to-compile-a-solidity-smart-contract-using-node-js-51ea7c6bf440 I wrote my code like following: const path = require('path'); const fs = require('fs'); const solc = require('solc'); const helloPath = path.resolve(__dirname, 'contracts', 'hello.sol'); console.log("First" + helloPath); const source = fs.readFileSync(helloPath, 'UTF-8'); console