Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

0

1st lets clear a few things for you. Past events are not stored in contract. There are no built in functions like getPastEvents() and events.allEvents() to get all events. Events are fired only where you emit them. Here is an example contract pragma solidity ^0.5.11; contract SillyOwner { address owner; constructor() public { owner = msg....


0

use pyethereum for illustrative purpose, see check_pow function which validates the PoW result of a block. note that when running ethash, the main input is nonce (together with unchangeable header hash) and outputs are result and mixhash to summarize, block is valid if result matches the block difficulty (result <= 2**256 // difficulty), and mixhash is ...


1

In theory once a transaction hash is given it stays forever. However in the case of testnets the rule of thumb is that you should never rely on something staying forever. They are called test nets for a reason. They may get screwed up (and have been screwed up many times in the past) for whatever test reasons. Typically they get screwed due to a test of an ...


0

You can build a DApp to inspect the environment and: use a local node if one is present fall back to use one or more node-as-a-service pools. The latter offers the convenience of an install-and-go user experience. Many new users will be unfamiliar with the deeper design issues of decentralization such as removing a single point of failure or the ...


0

First let's get the fundamentals sorted. You connect to a blockchain through a node which implements the blockchain. So a node is a client program which runs code that makes up the blockchain - the blockchain consists of nodes. There is no way to connect to the blockchain without a node (be it yours or somebody else's). So a dapp uses some web3 library (...


0

try using this link. It is the cdn <script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@0.18.2/dist/web3.min.js"></script>


0

Solved issue when added "ByzantiumBlock": 0, to genesis.json. Otherwise geth node is not capable of calling contracts from another contract. More details on https://github.com/alastria/alastria-node/issues/278


0

Try: const contract = await new web3.eth.Contract(JSON.parse(interface)) .deploy( { data:"0x"+bytecode} ) .send( { gas: '300000', gasPrice: 10, from:accounts[0]}); Otherwise please make sure that your accounts array includes actual values.


0

There isn't as of yet, but Istanbul (the upcoming hardfork) includes eip-1344, which includes a CHAINID opcode that pushes the chain id to the stack. I assume Solidity will add block.chainId or something similar, or at least add it to Solidity Assembly so that libraries can access it.


0

You don't have to use push with an array. You can add a new element modifying its length. Candidate[] public candidates; function addCandidate(string memory _name) public { uint idx = candidates.length; candidates.length += 1; candidates[idx].name = _name; } Another option is to use a mapping. You will need to keep the length separately. mapping (...


0

Account won't be persistent when you rerun the ganache-cli


0

Maybe use Metamask because as of March 2019 Mist(Ethereum wallet) has been deprecated. So it is natural that while using it you might run into problems. Metamask can be added as an extension in your browser and you can use Remix along with it. Using Metamask you can connect to your local or public blockchain. And use it to interact with the smart contracts ...


0

For most IoT project incorporating Smart Contracts, one will make use of an external oracle to input data into the Smart Contract. Try http://www.oraclize.it/ Hope this helps


0

I would go for the Arduino and here is why: The Arduino is "easier" to connect to sensors or electronic components which will work great in the IoT environment. Arduino's work great for projects in which one must quickly obtain data from sensors and perform an activity from it. I assume an external oracle, such as the Arduino, will input this data into the ...


0

The result of a view (read-only) function in web3.js and ethjs are object-like types, with string keys for the integer positions of the return values. If you stringified it, it would look like {'0': BN<some balance here>} Try balance['0'].toNumber() If your view functions return multiple values, it would look like `{'0': val0, '1': val1, ... }`


2

Your Javascript code should be asynchronous (either with async/await, or using Promise objects), because both contract.new and object.showNumber return a Promise. For example: async function run() { var contract = eth.contract(ABI); var bytecode = '0xBIN'; var deploy = {from: eth.coinbase, data: bytecode, gas: 2000000}; var object = await ...


0

Hope this helps. Create geth.service file (/etc/systemd/system/geth.service): sudo nano /etc/systemd/system/geth.service Paste the below (Change config in ExecStart to TestNet): [Unit] Description=Geth [Service] Type=simple User={$USER} Restart=always RestartSec=12 ExecStart=/bin/geth --syncmode "full" --rpc --rpcaddr "0.0.0.0" [Install] WantedBy=...


0

QTUM is a now a separate blockchain. Similarly to other projects like EOS and Tron they used Ethereum to lauch their ICO. And afterward they lauched a separate blockchain.


0

Interesting question, and I agree with the previous respondent that it's a broad question, and would involve some kind of reputation network and staking, such that people who report false information are penalized by losing their stake, and "truth" is reached by majority vote either by participants or some trusted judges (often called "validators" in Proof-...


1

In this context, "consensus" means agreement about transaction order, not the state. In case it is not clear, nodes can agree on the result after they agree on transaction order because they can work out, independently, what the state must be. It's similar to a replay log that enables reconstruction of a database. Nodes learn about proposed transactions at ...


0

Because of the open, public and decentralized nature of blockchain, there exists no scope for authenticating the participants in the blockchain network. It becomes difficult to guarantee the legitimacy and genuineness of a participating entity. The proof-of-work (PoW) mechanism solves this problem by exploiting the characteristics of practical resource-...


0

Yes, it is a very broad question, so this will be a broad answer. I have lost track of the number of individuals I have encountered who have conceptually mixed up blockchain's "proof" with magical powers that extend into the off-chain world of inputs. This is sometimes called the "onboarding problem" and most applications have it in one form or another. ...


0

The solution using ether.js library - const ethers = require('ethers'); let provider = ethers.getDefaultProvider(); // WALLETS const DAIUserWalletObj = new ethers.Wallet(DAIUserPrivateKey, provider); const AUDCWalletObj = new ethers.Wallet(AUDCPrivateKey, provider); //CONTRACTS const contractDAI = new ethers.Contract(DAIContractAddress, DAIContractABI, ...


0

This is more of a question for the ubuntu stackexchange. You have two options: Execute with sudo. This will work for sure: sudo geth --datadir blokchain init genesis.json There might be a problem with permission (chmod set incorrectly). Try setting it on the entire folder. sudo chmod -r 777 myFolderThatContainsEntireChain. This isn't the best solution but ...


0

I'm not sure if some client supports this but at least in theory you could start downloading the blockchain only from a certain block number. As the contract (most likely) won't have transactions into it before it was created you only need to check blocks after that. If you're saying that the blockchain is several terabytes in size then you must mean an ...


1

It depends on what would be in the place of PoW. There has to be some logic/algorithm. PoW and consensus are closely related: consensus needs some mechanism to limit the block production and in Ethereum it's currently PoW. If everyone was allowed to add blocks to the blockchain at will it would be very hard to reach consensus as basically every node would ...


0

First, add "web3": "1.2.1" to your package.json file and run npm install (or simply run npm install web3). Second, try the following node script: const Web3 = require("web3"); async function run() { const abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}...


Top 50 recent answers are included