texts: What are the flaws of this example contract?

texts:
I am currently writing a paper/article on tokenization, in the beginning of which I introduce smart contracts.
To this end, I present the following contract as an example:

pragma solidity ^0.6.0;

contract SplitPot {
  address payable[] beneficiaries = [
    0x498898b3F52DAba1bB304a4b4D2EA31a111484B1,
    0xAcb19c763EB67ea757Efd8Cd8b6ecceb28F1284B,
    0xD5d3f3650C4DdE7B8034671129443A596Ce8ed57
  ];

  receive() external payable {
    uint individualAmount = msg.value / beneficiaries.length;

    for (uint i = 0; i < beneficiaries.length; i++) {
      beneficiaries[i].transfer(individualAmount);
    }
  }
}

Obviously, the purpose of the contract is to evenly distribute all Ether sent to it among the three beneficiaries (all of which are testnet accounts I created). It works on testnet.

For this specific purpose, i.e., explaining what smart contracts are, I believe this is a very good contract:

It is very short and easy to understand.
It does something that is usually facilitated by a trusted third party -- which is now obsolete.

I also know this is a very bad contract, as it has severe shortcomings. For example: What if a transaction fails? Afaik, the beneficiaries have no way of recovering their share of Ether, and the contract doesn't re-attempt to send it to them. Also: I don't know whether the contract would execute correctly on mainnet, too.

I want to inform my readers that this is, in fact, a flawed contract, and I want to let them know what specifically can go wrong. As I just started learning about Ethereum, I'd be very thankful if you helped me identifying these flaws -- especially with regards to gas economics and coding style.

The paper/article will be licensed CC BY-SA 4.0, so I am not asking for help on commercial work!


texts:
What is the default txpool memory size in geth? How can I change the txpool memory size?

According to What is the max size of transactions can clients like geth keep in txpool?, "The number of transactions in the pending transaction pool is effectively limited by memory." I wonder what the default setting is and how to change it.


texts: Is it possible to to send out more ether than account has while compensating for it by another transaction in the same block

texts:
Is it possible to have the following scenario?

Account A has 20 ether,  account B has 20 ether
In transaction 1.  Account A sends 25 ether to account B
In transaction 2.  Account B sends 10 ether to account A
Both transactions are submitted almost at the same time so they will be a part of the same block

After the block is mined the net effect is account A sends 15 ether to account B. So there is enough ether in both accounts to satisfy the account balances.

But does Ethereum infrastructure allows for such operations?


texts: How to queue up simultaneous signed transactions

texts:
I have written a simple API server in NodeJS that uses web3 (version 1 beta 27) to interact with a remote Parity node.

The guts of the call is as follows

const invoke = async (req, res) => {
  const { params: { address } } = req
  try {
    const theContract = new web3.eth.Contract(abi, contractAddress, { from: SENDER_ADDRESS })
    const fn = theContract.methods.doTheThing(address)
    const account = web3.eth.accounts.privateKeyToAccount(PRIVATE_KEY)
    const data = fn.encodeABI()
    const nonce = await web3.eth.getTransactionCount(SENDER_ADDRESS, 'pending')
    const payload = {
      nonce,
      data,
      gas,
      from: SENDER_ADDRESS,
      to: contractAddress
    }
    const signedTx = await account.signTransaction(payload, account.privateKey)
    const { rawTransaction } = signedTx
    const response = await web3.eth.sendSignedTransaction(rawTransaction)
    const { transactionHash: tx } = response
    res.json({ tx })
  } catch (err) {
    res.status(500).json({ error: err.message })
  }
}

This works perfectly if I only make one call to the API at a time, and it even works fine if I make a few calls that roughly overlap. (tested it with curl using a number of terminal windows)

But if I use a script to call the API many times simultaniously (which is a reasonable simulation of a real-world condition) most of the calls fail, saying There is another transaction with same nonce in the queue.

One solution that's been recommended to me is to create a personal address within Parity itself rather than creating an address in the form of a public/private key pair on my machine, but that does not seem like a best-practice solution.

The issue is that web3.eth.getTransactionCount(SENDER_ADDRESS, 'pending') is returning the same nonce if the API is invoked too quickly. One thought is that I could simply retry if the caught error includes the There is another transaction with same nonce in the queue. message but that seems fragile to say the least.

What is the correct way to queue up simultaneous requests like this?


texts: What is the best way to report scam/fraud token

texts:
Recently I've bought small amount of some token with good overall idea as it seems for the first look. Then I go deeper to the source code and found that product is fraudulent, with differences between written in the whitepaper and actual product implementation.

How can I complain about token effectively? Want others to not repeat my mistakes


texts:
Installing on windows 10.

did install chocolatey
did choco install git
did choco install golang
did choco install mingw

Now i need to install go language as specific in the docs by using

git clone https:/github.com/lexansoft/ethcracker
?? command git not recognised

Also next steps fail

PS C:\WINDOWS\system32> go get github.com/ethereum/go-ethereum
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/ethereum/go-ethereum: exec: "git": executable file not found in %PATH%

Who can help?


texts: Should I give names to return values, when a function returns several of them?

texts:
I am currently working with solc v0.4.25, where it is not possible to return structures, so the only way to return multiple values is in a tuple.

I've been advised to give names to each one of the returned values, in order to make the code easier to read and less prone to errors.

However, it would ultimately force me to give names to every return value in my system, even when only a single value is returned.

In order to clarify the above, here are two examples:

function withoutNames(uint x) pure returns (uint, uint) {
    uint y = 2 * x;
    uint z = 3 * x;
    return (y, z);
}

function withNames(uint x) pure returns (uint y, uint z) {
    y = 2 * x;
    z = 3 * x;
}

My question:

Is there an official coding convention (or an accepted standard among the community) for how to deal with return-value naming?

The way I see it, the options are:

Do not name any return value
Name every return value in every function
Name every return value in every function which returns more than one value

Thank you very much for your suggestions.


texts: Storage arrays with nested mappings do not support .push()

texts:
I have a struct with a nested mapping which I am instantiating and trying to push to an array, but I'm receiving the following error on the line i try to push:
Storage arrays with nested mappings do not support .push(<arg>).
Its obvious what the compiler is complaining about, my struct has a mapping and im trying to perform a push. Is this fundamentally not allowed or is there something I can change in my implementation to make this work? I'm using solidity 0.8.0.
Code:
struct Dividend {
    mapping(address => bool) claimed;
    uint256 pool;
}
Dividend[] public dividends;

function createDividends() public {
    Dividend storage d;
    d.pool = dividendPool;
    dividends.push(d);
}


texts: How to return tokens from the BEP-20 network from a Geth-based wallet?

texts: Accidentally sent Eth from the exchange in the BEP-20 network (binance) to a wallet that is made on the basis of Geth. How can I send the tokens back?


texts: Private Ethereum blockchain Transaction Issue

texts: Sending ether from one address to another using web3js. Getting issue of "account unlock with HTTP access is forbidden"


texts: According to Dapp the blockchain should distributed, But while we use ganache it runs on a local machine and the clients will be having only their private key and public key (or wallet) with them AFAIK. Will all the clients using dapp have their own copy of blockchain and i'm asking this since ganache is running on the host machine.


texts: Storing hardcoded calldata in a Solidity contract

texts:
I've been trying to store a hardcoded call in a contract, but I'm getting confused on the encoding.

Let's say I have the following bytes:

0x9461d6f7000000000000000000000000000000000000000000000000000000000000000a796f000000000000000000000000000000000000000000000000000000000000

This translates to calling function testData(uint256 testVar, bytes32 otherVar) with 10 & "yo".

If I store this as a bytes like so:

bytes public hardcodedCallData = "0x9461d6f7000000000000000000000000000000000000000000000000000000000000000a796f000000000000000000000000000000000000000000000000000000000000";

And then do a address.call(hardcodedCallData), it does not work. The fallback function is triggered instead, assuming that it is malformed. When storing it as such, it seems it decodes to bytes that look different.

I seem to have a misunderstanding on encoding here somewhere. Given calldata, how do I store it as bytes as hardcoded, so I can do the above?

I tried variations (playing with strings for example), but not able to figure this out.


texts: Question about inline assembly in Solidity

texts:
I've got this line of inline assembly code in a Solidity file and I'm trying to understand what some parameters do.

assembly {
        success := call(sub(gas, 2000), 8, 0, add(input, 0x20), mul(inputSize, 0x20), out, 0x20)
}

I'm struggling to understand how the add() is being used. The input variable is a uint array, and I don't know what 0x20 is referring to. The Ethereum Yellow Paper says it refers to the keccak256 function but that doesn't make sense to be added. My understanding is that the add opcode adds two uint256 values, but its used here to add an array and an address.

The code comes from line 158 in the below github link. The file it is in is an implementation of BLS / BLGS signature verification.

Any help clarifying this would be much appreciated!

Source: https://gist.github.com/BjornvdLaan/ca6dd4e3993e1ef392f363ec27fe74c4#file-blsexample-sol


texts: NFT's environmental/computational cost breakdown?

texts:
I've read the NFT and mining documentation on the Ethereum website, and I can't wrap my head around two things.

If NFT's are not equivalent to Ethereum coins and therefore do not require solving hash problems to generate, where does the energy consumption required to generate them come from?

Once NFT's are on the blockchain, how is the energy consumption (or gas) needed to verify them used?

Thank you all!


texts:
I am trying to divide BN with a constant and I can't find the right function.
Basically I wanted to divide 132876 by 1.30, 132876/1.30 for BN operations.
Here is a snippet of what I tried.
const gasAmount = new BN(132876)
console.log(gasAmount.div(new BN('1.30')).toString()) // 160
console.log(gasAmount.div(new BN(1.30)).toString())   // 132876

// expected: 102212


texts: How increase mining speed in AWS instance?

texts:
I have setup a private blockchain in AWS micro instance using go-ethereum. In that when I start the mining process it was taking nearly 2-3 hours to mine a new block.Whereas on my local machine it was taking 30 mins initially to start after that it took 1 sec to mine a new block.
In Genesis block, I had assign difficulty as 0x400.

{
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "nonce": "0x0000000000000042",
    "difficulty": "0x400",
    "gasLimit": "2100000",
    "alloc": {
        "0xc490758cadb047809fa59df82a2057e6407784ab": { "balance": "100000000000000000000000000" },
        "0xa4f6f95b6cb36025dd09c9f5fe068e401951e963": { "balance": "10000000000000000000" }
    }
}


texts:
This transaction shows that account 0x152ae79400fdeee287849f35e4f687316e27bae6 sent this smart contract 0x14fbca95be7e99c15cc2996c6c9d841e54b79425 a transaction that interally invoked the maker token contract and that as part of that invocation, this event was created (the third one).

Question: When I look at the maker token contract's list of transactions 0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2, I think I should find block 4978662 included in the account's internal transactions list, but it isn't.

Am I missing something? Is this a bug in Etherscan?


texts:
I'm working on a project where I need to implement an ERC721 marketplace. It doesn't work for some reason and wanted to know if I'm doing everything correctly.

The way I approached this was:

The seller approves the contract address to act on their behalf.
The token is listed as available for sale in the marketplace.
Then, when the buyer wants to buy the token, the contract transfers the token from the seller to the buyer, and transfers the payment from buyer to seller.

I couldn't find many resources but found these as references:

https://github.com/status-im/embark-tutorial-erc721/tree/tutorial-series/contracts

Proper way to implement "buyable" ERC721 tokens

So here's the code I implemented:

The code is here:

 struct Token {
        uint id;
        uint price;
        uint prevPrice;
        bool forSale;
    }

function buyMarketplaceToken(uint _tokenId) public payable whenNotPaused() isForSale(_tokenId) {
        address ticketOwner = ownerOf(_tokenId);
        require(msg.value >= tokens[_tokenId].price, "It costs more!");
        ticketOwner.transfer(msg.value);
        safeTransferFrom(ticketOwner, msg.sender, _ticketId);
        clearApproval(this, _ticketId);
        tokens[_tokenId].forSale = false;
    }

    function addTokenForSale(uint _tokenId, uint newPrice) public onlyOwner(_tokenId) whenNotPaused() {
        tokens[_tokenId].forSale = true;
        tokens[_tokenId].prevPrice = tokens[_tokenId].price;
        tokens[_tokenId].price = newPrice;
        approve(address(this), _tokenId);
        emit TokenOnSale(_tokenId, newPrice);
    }

        function removeTokenForSale(uint _tokenId) public onlyOwner(_tokenId) whenNotPaused() {
        tokens[_tokenId].forSale = false;
        tokens[_tokenId].price = tokens[_tokenId].prevPrice;
        clearApproval(address(this), _tokenId);
        emit TokenOffSale(_tokenId, tokens[_tokenId].prevPrice);
    }

So my logic is that seller calls addTokenForSale with tokenId and a price for sale. This function approves the contract to transfer token on owners behalf and sets the forSale boolean for this token to true.

The buyer calls buyMarketplaceToken with tokenId and pays the token price which is transferred to original token owner. The token is transferred to msg.sender by the contract and approval is cleared. Then the token forSale boolean is set to false meaning its not for sale anymore.

The code stops working at safeTransferFrom because even though the contract has approval to transfer token, contract is not msg.sender.

How do I make sure that safeTransferFrom caller is the contract and not msg.sender?

What am I missing here? Any help would be appreciated.


texts: How to use event log in solidity contract using go language

texts: I have created ethereum smart contract using go language. Smart contract successfully deployed. I have a created many transactions on ethereum private network. But I confuse how to get event log.


texts: I got "sandwich attacked" on my transaction

texts:
I see a new kind of arbitrage bot today. As per my research we call that "sandwich attack" ...
Here how the user proceed :

I buy for 7.8ETH of a token, and it look like a bot is buying before me (better gas price) then selling after the price pump due to my buy.
I have some question that i don't find answer on internet.

The bot is monitoring my etherscan account ? or it's monitoring all buy from the token etherscan address?
This kind of bot is really called sandwich attack ? because i don't find lot of documentation about it.
Is it possible to counter them (in other way that spending more fees on transaction)

Thank for your answer !


texts: I know that external is cheaper than public due to how arguments are parsed. Is making a function private or internal cheaper?


texts: How interact with Ethereum without (gas) ether?

texts: Ethereum is not a currency but use ether (gas) to pay the fees, therefore someone will need an Ether account to pay and build the application. But how can someone get an account for each activity previously mentioned (to buy/sell ether and build the app)?


texts: Can a contract know about other transactions in the same block as one of its own?

texts:
I've read that transactions in the same block that call the same contract will execute in an arbitrary order if sent from different accounts.

My question is, for any given transaction that may be calling a contract method, is it possible for that method to:

Know about the other transactions in its block, and if so
Adjust its execution based on what it sees


texts: Encryption with BIP39 specification secp256k1 keys?

texts:
We are making a system where users can share files with other people but nobody should be able to figure out that all these different files belongs to same user on blockchain.

these are the steps we have followed.

bip39 specification for generating master public keys and private keys and their 2**32 -1 child keys.
If a user wants to store this file, A new child key will be generated with a new AES key will be generated. The file will be encrypted with this AES key (GCM) mode,appending nonce and tag with ciphertext.
AES will be encrypted with this child private key.
Now float a contract, with the location of this encrypted data, encrypted AES key and child public key and saved on the address generated from the public key based on some mechanism.
If a user wants to share this file with other user, just generate a key based on the other user public key and users private key, and encrypt the AES with this common key so the other user can decrypt and read it.

My question is, How to encrypt AES key with secp256k1 keys since I couldnt find any implementation of this in either python or golang.
The other question is, Is it safe to encrypt AES keys with child secp256k1 keys.


texts: Can I send transaction to a view|pure function?

texts:
This is the contract:

uint public result;
address public owner;

constructor() public {
    owner = msg.sender;
}

function add(uint a, uint b) public returns(uint) {
    result = a + b;
    return result;
}

Normally we can use contract.add.sendTraction({...}) call the "add" function using Web3.js. However, I found that I can also use contract.add.call(), like this:

I wonder why this can be valid? All I know is that "call" cannot change the state of a contract, but I do change the state in the statement "result = a + b".

Besides, if things like above is possible, can I send transactions to "view" or "pure" functions? If possible, since functions like those won't change the state, would that require any gas?


texts:
Is there an Ethereum rainbow chart showing cryptocurrency cycles, like how there is a Bitcoin rainbow chart?
https://www.blockchaincenter.net/bitcoin-rainbow-chart/


texts: web3.eth.getAccounts() returns empty array

texts:
I'm trying to get accounts like that:

window.web3.eth.getAccounts( (error, accounts) => { console.log(accounts, error) } );

but it keeps returning an empty array. I'm running Ganache and I can see the accounts on MetaMask, but I cannot access them from my frontend Web3 Angular app. This used to work and now doesn't. I didn't change anything. And idea on how to fix this?

Also web3.eth.accounts returns an error Error: Invalid JSON RPC response:

This is how I init my web3:

if (typeof window.web3 !== 'undefined') {
      this.web3Provider = window.web3.currentProvider;
    } else {
      this.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
    }

    window.web3 = new Web3(this.web3Provider);


texts: Error: Returned values aren't valid, did it run Out of Gas based on YT Tutorial

texts:
I red the other Threads about this case, but couldn't fixed the problem.
I got this tutorial for Scmart contracts:

https://www.youtube.com/watch?v=coQ5dg8wM2o&feature=youtu.be

However the problem is that I get this error when I use "truffle migrate:

Error: Returned values aren't valid, did it run Out of Gas?
    at ABICoder.decodeParameters (/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/src/index.js:226:1)
    at Contract._decodeMethodReturn (/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:465:1)
    at Method.outputFormatter (/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:818:1)
    at Method.formatOutput (/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/~/web3-core-method/src/index.js:163:1)
    at sendTxCallback (/usr/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/~/web3-core-method/src/index.js:473:1)
    at /usr/lib/node_modules/truffle/build/webpack:/~/web3-core-requestmanager/src/index.js:147:1
    at /usr/lib/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:112:1
    at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/webpack:/~/web3-providers-http/src/index.js:96:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
    at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:208:1)
    at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:318:1)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:289:47)
    at IncomingMessage.emit (events.js:198:15)
    at endReadableNT (_stream_readable.js:1139:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)
Truffle v5.0.2 (core: 5.0.2)
Node v11.15.0

I use Ubuntu 18.04

Could anyone help me, actually I did the same in the Video, untill the problem in min 18.

Cheers


texts: When does a ERC-20 token transfer should be considered confirmed?

texts:
I'm wondering when you should consider that a transfer of ERC-20 tokens is confirmed. At the beginning I thought that just making sure the transaction calling transfer is confirmed successfully was enough, but then I started to think that maybe I should wait for the Transfer event instead.

I've seen that most tokens out there just emit the Transfer event right there inside of the transfer function. However let's suppose the following contract:

User A calls the transfer function to transfer tokens to address B
The transfer function sends an event to ask for validation of user B
The transfer function will be completed at this point, but tokens haven't been transferred yet and the Transfer event is not triggered either
Someone validates user B and calls another function in the contract that completes the initial transaction (tokens are moved)
The Transfer event is triggered now, indicating that the transfer has been completed

In this case, the correct thing to do would be to wait for the Transfer event to confirm a transaction of tokens, because just waiting for the confirmation of the transaction calling the transfer function is not enough.

However I'm not sure if that's what ERC-20 specification says and what most tools that work with ERC-20 tokens expect. So my questions is if it is fine to create a token where the confirmation of the transfer is done when the Transfer event is triggered instead of when the transaction to call transfer is confirmed.


texts: Transfer WETH from myetherwallet to metamask wallet

texts:
I converted some of my ETH to WETH already, on my hardware wallet. H/w wallet was conected to myetherwallet, and I can see my WETH there under tokens panel.

I also created a metamask wallet and I am looking to transfer WETH over there. But  I can't get a deposit address for WETH on metamask even after adding WETH in tokens. I tried with some other ERC-20 tokens as well, but can't see deposit address for those other tokens as well. I only see a deposit address for ETH.

How do I get my WETH to metamask wallet?


texts: how can we stop front running for `approve`

texts:
function approve(address _spender, uint256 _value) returns (bool success)

This is the ordinary ERC20 approval method. It's easy to figure out that we have a problem of front-running.

Alice gives allowance of 100 tokens to Bob.
Later, Alice rethinks her choice, changing it to 50. When this happens, Bob watches the chain, transfers his 100 tokens immediatelly with a higher gas price.

As a result, Bob gains 150 tokens overal instead of 50.
How can we avoid the above situation ? can commit-reveal help ? if yes, how ?


texts: Private Transactions (Privacy) in Quorum

texts:
Why is PrivateFor required during contract creation? Would passing privatefor during function calls suffice?
Inconsistent state observed. A contract was created by node 1 intended for node 2 and node 7 (privateFor node 2 and node 7). Node 3 and Node 4 was able to update the state but not retrieve it -- not able to retrieve the variable is understandable but being able to update the state variable cannot be understood as this contract was created intended for node 2 and node 7. After updating the state variable via node 3 & 4, node 2 and node 7 was getting the most updated value i.e., correct. However, node 1 was still getting the old, i.e., stale value.

Any thoughts and ideas for the above questions?


texts: Unknown wallet address on private development chain

texts:
Apologies in advance for the long post. I'm new to Ethereum and don't know which details are significant and which are not.

I'm trying to learn about dapps by following an example in this book. My system is Windows 10-based. The book tells me first to sync an Ethereum node, which I do using

geth --datadir d:\Ethereum\geth

This is not my %APPDATA directory (that drive is too small to host the node).

So that was successful. Next step is to create and configure a private development chain, which I do using this:

geth --dev --datadir D:\SampleDapp\privatenet --ipcpath D:\Ethereum\geth.ipc --networkid 45 --rpc --rpcapi web3,net,eth,personal --rpccorsdomain "*" --mine console

The book tells me that for Mist to interact with the IPC file it must be located with the main node, therefore I set it up that way.

So far, so good. Next I create a simple contract in Solidity, which successfully compiles. Now we come to the deployment, which the book says is done with this Node.js script:

var Web3 = require('web3');
var fs = require('fs');
var exec = require('child_process').execSync;

var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
var walletAddress = web3.eth.accounts[0];
console.log(walletAddress);
web3.personal.unlockAccount(walletAddress, process.argv[2]);

var abi = fs.readFileSync('bin/peerbet.sol:Bet.abi');
var PeerBet = web3.eth.Contract(abi);

var compiled = '0x' + fs.readFileSync('bin/Bet.bin');
var peerbet = PeerBet.new({
    from: walletAddress,
    data: compiled,
    gas: 40e5,
    gasPrice: 20e9
}, function (e, contract) {
    if (e) console.log(e);

    if (typeof contract.address !== 'undefined') {
        console.log('Contract mined! address: ' + contract.address +
            ' transaction hash: ' + contract.transactionHash);
        fs.writeFileSync('contract_address', contract.address);
    }
});

This is where the problem is. The wallet address found at web3.eth.accounts[0] is one I've never seen before. I have two wallets on my system (one set up by Mist, and one by MetaMask), but neither of those addresses correspond to the address I'm getting in this script. Since I don't know where the wallet address came from, I don't know its private key, password, passphrase, or whatever. So, two questions: where did this wallet address come from, and what do I need to provide as an argument to get web3.personal.unlockAccount() to work? Thanks.


texts: How to read solidity events and arguments from web3.py?

texts:
I am trying to create a python filter to read events from Smart contract but I am not successful so far. below is the sample python code and I have used "Instructor" event in solidity and trying to define "my_callback" function below whenever instructor event is fired from solidity program. Can you please help ?

import random
import sys
import os

from web3 import Web3, HTTPProvider, IPCProvider
from web3.contract import ConciseContract
import json
from web3.providers.rpc import HTTPProvider

def my_callback():
    print ('Instructor event  is fired from contract')

contractAddress = '0x2818129b6306be2a337b31d83ff9bdf6da067a41'
web3 = Web3(HTTPProvider('http://localhost:8545'))
#open("C:/Users/XXX/Documents/50_states.csv",mode='w')
with open("C:/Users/XXX/Documents/ourfirsttoken.json", mode='r') as abi_definition:
    abi = json.load(abi_definition)

fContract = web3.eth.contract(abi,contractAddress)

transfer_filter = fContract.on('Instructor',my_callback())

fContract.transact({'from': web3.eth.accounts[0]}).setInstructor('XYsdgdsZ',3255)
print('contract get instructor function ' + str(fContract.call().getInstructor()[0]))


texts: What's the proper way to wait for a transaction to be mined and get the results?

texts:
I'm using react to write the frontend for my dApp, and doing this to (attempt to) update react's state via an asynchronous sendTransaction call:

var thisJS = this
web3.eth.sendTransaction({from: adminAccount, to: contractAddress, value: web3.toWei(funds,"ether")}, function(error, result) {
  if (error) {
    console.error(error)
  } else {
    console.log("Send transaction successful " + result)
    const contractFunds = web3.fromWei(web3.eth.getBalance(contractAddress),"ether").toString()
    thisJS.setState({contractFunds: contractFunds})
  }
})

That doesn't seem to quite work as I hoped as the react setState call doesn't (often) reflect the new funds at the contract's address. I must be doing something wrong - what's the proper way to wait for the transaction to be mined so I can correctly update react's state?


texts:
My source below

pragma solidity ^0.4.17;

contract EtherBox {
    uint balance;

    constructor () public payable  {}

    function SetBalance() public payable {
        balance = balance + 10;
    }

    function GetBalance() public payable returns(uint) {
       return balance;
    }
}

contract UsingCall {
    constructor () public payable  {}

    function SimpleCall(address addr) public payable returns (uint) {
        bool status = true;
        //EtherBox eb = new EtherBox();
        EtherBox eb = EtherBox(addr);
        address myaddr = address(eb);
        status = myaddr.call(bytes4(keccak256("SetBalance()")));
        return eb.GetBalance();
    }

    function SimpleCallwithGas() public returns (bool) {
        bool status = true;
        EtherBox eb = new EtherBox();
        address myaddr = address(eb);
        status = myaddr.call.gas(200000)(bytes4(keccak256("GetBalance()")));
        return status;
    }

    function SimpleCallwithGasAndValue() public returns (bool) {
        bool status = true;
        EtherBox eb = new EtherBox();
        address myaddr = address(eb);
        status = myaddr.call.gas(200000).value(1)(bytes4(keccak256("GetBalance()")));
        return status;
    }

}

It was fine and still working very well. But I have a question. When I execute SimpleCallwithGasAndValue() method, I want to see changes of value and gas in my Geth program. How could I do that? help me awesome guys!!


texts: Will the processing power of the EVM ever be increased?

texts:
From what I understand almost all hash power on the network is used to secure the blockchain, but the processing power of the EVM remains constant even as the hash power of the network increases, and this is by design.

Why is this the case? Wouldn't it benefit everyone if the EVM could scale its power up as more powerful nodes enter the network?

To be clear I fully understand that the blockchain would grow a lot faster if these limits were not in place. Is that the only reason for those limits though?

Are there any plans for this to happen say, after Serenity and the introduction of Casper and PoS? It would seem to make sense to do that at that point since less processing power would be required to secure the blockchain, and nodes with lots of power could contribute that instead towards executing contracts. Is that a part of the plan?


texts:
I have an ether account (whose details I prefer not to disclose here).  I can confirm in etherchain.org that it has the correct amount of funds.  I can also check that the funds were transferred in block 3639426

I am running geth on my linux desktop with the plain command

geth

i.e. no "-fast" or nothing enabled.  At the moment:

 currentBlock: 3953293,
 highestBlock: 4161833,
 knownStates: 62693,
 pulledStates: 58536,
 startingBlock: 3914231

So, at this stage I should be able to check the balance of my account also from geth console using

web3.eth.getBalance("..")

.. right?

However, I get zero all the time.

Starting to feel cold sweat: I think I've been screwed.. just don't know how!  Why I'm getting zero balance?

A Bonus question: what's the essence of "startingBlock" ?

** EDIT **

Phew.. using any account gives me a zero.  So, is it so that the blockchain must be downloaded completely before checking account balances works .. ?  I guess so.

** EDIT EDIT **

OK, it's finally synchronized & everything works as expected. .. I am using

Geth/v1.7.0-unstable-6ca59d98/linux-amd64/go1.8.3

I wonder if "-fast" is now the default..?


texts:
I'm a Python Developer jumping into Solidity and I feel like I'm missing something about variables and scope.

How do I set and access variables outside of a function's scope?

I can't seem to add spins ( simple uint ) to my spin history ( uint[] ) and access them elsewhere. I can use push and get it in an array within the same function, but it doesn't update the State level variable.

contract GoldenEgg{
uint[] public spinHistory;

function spin() constant returns (uint) {
    uint spin = uint8(uint256(keccak256(block.timestamp, block.difficulty))%37);
    addToHistory(spin);
    return spin;
}

function getHistory() constant returns (uint[]) {
    return spinHistory;
}

function addToHistory( uint spin ) constant returns (uint[]) {
   spinHistory.push(spin);
   return spinHistory;
}}


texts: Will forthcoming ability to make transactions private hide gas usage and mining information?

texts:
I understand that people are working on allowing for more private transactions on the public Ethereum mainnet.

This would involve hiding (at the very least) the from, to, value and probably input fields, but I wonder what other information will be hidden, such as gasUsed, gasPrice, winning miner, mining reward, etc.

I, for one, would suggest that this information not be hidden so that broad, chain-wide information can be collected and analyzed.

What parts of a block and/or transaction data be hidden when we can do more private transactions?


texts: Understanding what happens between transaction creation and block creation in Proof of Authority

texts:
I am currently writing my thesis where I'm investigating the potential of blockchain technology to become the underlying technology in a system that is create and record qualifications.

I'm at the stage now where I have to put together a model but I'm struggling to understand what happens before block creation in a blockchain that uses Proof of Authority as a consensus algorithm.

Let me jump straight into where I'm struggling..Bear with me this is going to be very high-level

Just before a block is created

A user node wants to store a piece of information on the blockchain so a transaction is generated.. The transaction contains the information that the user node wants to store. Upon generation of this transaction, the network already knows on which index of this blockchain the next transaction is going to go.
A random validator (node with authority) on the network picks up the transaction should it be its turn to validate transactions and create blocks.
Something happens here? What happens? What does the validator do to 'validate' this transaction?
The validator that picked up the transaction creates the block and adds it to the blockchain.

The step that I'm finding difficult to understand despite the abundance of articles on the Internet is step #3.

Could someone please explain what exactly goes on at step?
Also, please feel free to correct me if my understanding of steps #1, #2 and #4 are not correct.


texts:
I use a VPS where I want to run parity to synchronize the blockchain.

I use this command :

parity --chain frontier.json --rpcapi="eth,net,web3,personal,web3" --rpc --rpcaddr ipAddressPub --rpcport 8545 --rpccorsdomain "*" --author 0x...

I've two ip address on my vps, one public ip and one private
And when I want to run parity with the public ip I've this error :

RPC io error: Cannot assign requested address (os error 99)

And when I run with private address it's working

But I want to get access to to vps to connect to the blockchain from other server, so I must to run the command with public address, isn't it?

How can I do this?


texts: unable to see the first address using web3.eth.getAddress()

texts:
I tried to see all address using
web3.eth.getAccounts()
It's run perfectly. Next I tried to see the first address using
web3.eth.getAccounts().then(function(accounts) {return accounts[0]})
It's also worked well. But now I want to use this address according to their index.
when I use getAccounts[0]or getAccounts[1] sometimes it's work, sometimes not.
So is there any specific way to use those address using index?


texts: If it's possible to change solidity code once deployed in ethereum blockchain

texts: I deployed solidity code in ethereum blockchain. Now my client ask to add some function in the deployed solidity code and need update that code in same contract address but i do no if it's possible or not.If any one know please answer the above question.


texts:
Going through the installation guide I'm at the last step to verify the Embark installation using the embark --version command and I get the embark: command not found message.
npm list -g --depth=0 shows
├── embark@6.0.0
└── jshint@2.12.0

I'm guessing the executable is not in my PATH?
I'm new to LinuxOS. This is on Ubuntu 20.04.2 LTS


texts: Who communicate on a private ethereum network?

texts:
I'm new to Go-Ethereum (GETH) and would like to ask a question that may seem quite dumb.
Let's say that I create my own private ethereum blockchain with GETH (I created accounts, the genesis block...), and deployed a Dapp trought it.
I would like to know if I were to use the JSON-RPC server, can I use this Dapp even if I'm not connected to the same local network as the node running the server?
If not how I can deploy a private ethereum network where people I have chosen and are located all over the world can use my Dapp ?
Thanks in advance to anybody that may help me.


texts:
For seemingly months now, Geth has been really slow for me.  Like, seconds per block:

INFO [07-13|23:35:10] Starting peer-to-peer node               instance=Geth/v1.6.6-stable-10a45cb5/windows-amd64/go1.8.3
....
INFO [07-13|23:37:58] Block synchronisation started
INFO [07-13|23:38:24] Imported new chain segment               blocks=1 txs=94 mgas=4.861 elapsed=10.425s mgasps=0.466 number=4016552 hash=3b3bee…995b29
INFO [07-13|23:38:36] Imported new chain segment               blocks=5 txs=281 mgas=15.577 elapsed=12.221s mgasps=1.275 number=4016557 hash=77d4ff…e550f6
INFO [07-13|23:38:57] Imported new chain segment               blocks=2 txs=149 mgas=7.680  elapsed=20.224s mgasps=0.380 number=4016559 hash=fae889…3ef261
INFO [07-13|23:39:11] Imported new chain segment               blocks=1 txs=199 mgas=6.555  elapsed=14.478s mgasps=0.453 number=4016560 hash=d14151…5631b9

I have ~3300 blocks to go and it feels like it'll take an hour.  Is that normal?  What are normal speeds?

I have a powerful and fast machine.  i7 with six physical cores.  48GB RAM.  My blockchain is stored on a RAID6 array of several 4TB 7200RPM disks hosted by an Areca controller with 4GB cache (battery-backed and write cache enabled).  Synthetic tests on the volume show great random read/write latencies and high sustained throughput.  Since Geth/Mist used to be much faster (aside of course from the well-known "garbage cleanup" period of the chain) I don't think it's a hardware issue.

Any suggestions?

Is my chaindata corrupted and do I need to delete it and resync my whole blockchain from scratch?  Why / how would it become corrupted into a state that still works but is really slow, and should there be any tell-tales in the logs?

If I have to do a full resync, how long ought that take these days?

In case it helps, I also notice either Geth and/or Mist really bog down my machine.  When I'm using my PC I'm forced to bump down their CPU Priority and I/O Priority to "Below Normal" to keep things snappy (which of course further slows down my sync).

Also note typing geth console indicates I'm on the forked chain (so not this issue).

INFO [07-14|00:09:01] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 24 ....

I presently have 11 peers, and this feels more like an I/O bottleneck than network one.  My command line these days is:

start "Mist" "C:\Program Files\Mist\Mist.exe" --datadir L:\Ethereum --node-datadir="L:\Ethereum" --node-keystore="L:\Ethereum\keystore" --node-cache=512


texts: Why do we need to specify constant in the return value

texts:
Referring to the constant below:

  function totalSupply() constant returns (uint256 totalSupply);


texts:
is this code valid? https://ethereum.stackexchange.com/a/8484/10138
I just don't see how Mortal(mortal) - an instantiation of the Mortal contract with one parameter - is possible when Mortal takes no parameters!


texts: Is transfer() still safe after the Istanbul update?

texts:
In other words, is using transfer() safe?

function transfer(address contractB) public
{
    contractB.transfer(1000);
    //balances[msg.sender] -= 1000;
}

How about using call.gas?

function transfer2(address receiver) public
{
    receiver.call.gas(20000).value(1000)();
}


texts: I failed to send FDZ token about 20 times, what happen?

texts:
I'm trying to send my FDZ token to my Exchange wallet, but no luck. I tried to increase the GAS, change the target address, process in an other time...
But everything were failed, still paid all gas price ($0.3 to $1.4$) but the token could not be sent.
Could you please take a look at my transaction history and let me know if you see what's wrong with it:
https://etherscan.io/address/0x5b1fb9f9d548789b3622ec8d74cf27f0d2380d23

Thanks


texts: Why will the new Ethereum 2.0 virtual machine run smart contracts compiled to WebAssembly instead of LLVM IR?

texts: LLVM seems to be a compile target with more mature implementations around it, so I figured LLVM would be a better assembly for the next generation EVM to run natively compared to WebAssembly which is a relatively new specification.


texts: Verifying the authenticity of a customer

texts: One of the strengths of blockchain, and specificallly, Ethereum, is the ability to have a complete record of customer orders from customer setup (for new customers) to customer delivery of goods.  I am trying to develop a use case whereby I can use Ethereum in setting up  to verify the authenticity of new customers for a company.  Currently, there are organizations that are attempting to spoof current customers by attempting to change phony "ship to" addresses.  When the company ships product to the address the "real" customer of course never ordered nor received the product.  Ethereum seems like an ideal way to verify the authenticity of customers. I want to be able to (1) verify that a new customer is who they say they are and (2) verify that any changes to their information is in fact authorized.  The second piece seems fairly straight forward once I have a verifiable address / public key.  I have read a bit about ENS (Ethereum Name Service), which may help to some extent for those who claim to have a particular address.  My question is if there is a straight forward to way verify the authenticity of new customers (or for that matter any other kind of organization I may do business with)?


texts: Cannot delete address value from address array (solidity)

texts:
I've run into some odd behavior of solidity. In the following example:

// Omit corner cases for brevity
contract C {
    address[] addrList;

    function addAddr(address addr) {
        addrList.push(addr);
    }

    function deleteAddr(address addr) {

        for(uint256 i = 0; i < addrList.length; i++) {
             if(addr == addrList[i]) {
                 for(uint256 j = i; j < addrList.length; j++) {
                     addrList[j] = addrList[j + 1];
                 }
                 delete addrList[addrList.length - 1];
                 addrList.length--; // <== This gives Error: Expression has to be an lvalue.
             }
        }
    }
}

it cannot resize the length of the array once the value has been deleted. Why can't the length of the address array be decremented?

Deleting integers from an integer array is possible.


texts: Can Blockchain miners see confidential transaction information? Since they have the public key, they decrypt the transaction for the purpose of verification. So if I am mining in Ethereum, I can tweak the node code to log the transaction details on my hard disk. Is Blockchain not suitable where confidentiality is important?


texts:
Can I use approve/transferfrom function for ETH coin?
Please let me know how to apply approve/transferfrom to ETH as erc20 tokens.

Thank you!


texts: How to add three numbers using safemath?

texts:
I know this might sound obvious but in solidity you can never be too sure.
Let us say I have three numbers 5, 7 and 8. Can I add them like so:
using SafeMath for uint256;

5.add(7.add(8));
// or even like so
5.add(7).add(8);
// or
5.add(7 + 8);

Is there any risk(of overflow or anything else) of using either?


texts:
>geth version
Geth
Version: 1.9.21-stable
Git Commit: 0287d54847d3297f3ced62cd83a4c95ccbe0045b
Git Commit Date: 20200909
Architecture: amd64
Protocol Versions: [65 64 63]
Go Version: go1.15
Operating System: windows
GOPATH=
GOROOT=go

Then I run geth --datadir data0 --networkid 1108 --nodiscover console and go to the console.
> web3.version
WARN [09-24|15:50:44.159] Served shh_version                       reqid=12 t="996.6µs" err="the method shh_version does not exist/is not available"
{
  api: "0.20.1",
  ethereum: "0x41",
  network: "1108",
  node: "Geth/v1.9.21-stable-0287d548/windows-amd64/go1.15",
WARN [09-24|15:50:44.169] Served shh_version                       reqid=16 t=0s        err="the method shh_version does not exist/is not available"
  whisper: undefined,
  getEthereum: function(callback),
  getNetwork: function(callback),
  getNode: function(callback),
  getWhisper: function(callback)
}

There are some warnings interrupting the output. The error may be "the method shh_version does not exist/is not available".
How should it be fixed?


texts: Lost password on parity! I do have the recovery 12-word phrases thankfully

texts:
I was going to transfer all my SAN tokens from parity to another exchange site only to find out I’ve lost my long password. I was traveling for 4 months so I’m pretty sure i left it in one of the hotels I stayed at. However, I did find my 12-word recovery phrases in my phone and now I’m wondering, can i do transactions on my account using these recovery phrases? If so, how do i do it? I read it somewhere that the 12-word phrases is to recover your password in case you lost it , so I’m really hoping to recover my account!!!! please help !!!thank you everyone in advance

update:

I don't have the option to click on "recovery phrase". This is what Im seeing on my version, should I click on "export account"?

UPDATE:

This is what I'm seeing right now after "restoring" my account. A new account "YUQI JIA" is created with 0.000 ETH and 0 SAN tokens in. The new account also had a complete different address. My tokens from the account I wanted to recover are still not transferrable. What do I do from here? Thank you in advance!


texts: Get more than 10 accounts in the truffle develop blockchain?

texts:
How do we get more than 10 accounts in the truffle develop blockchain ?
If someone has an idea about the question in the title, would be of help to many people out there for testing.
Thanks a lot.


texts:
Every time I try to transfer kovan testnet ether from one account to another it says

[-32021] Account password is invalid or account does not exist

while confirming the password for the account.
What to do?


texts: How does a token crowdsale or ICO work for a permissioned Blockchain project?

texts:
Filecoin, for example, ran their highly successful ICO on the Ethereum blockchain, though they are gonna operate on a different chain.

AFAIK, main-net tokens can't be used on a private chain. Makes me wonder how token sales work for a private blockchain project. I understand that a crowdsale is just another fund raising mechanism, and doesn't even need to be related to a 'blockchain project'. However, if a private chain  does use tokens, how would one issue those to crowdsale participants?


texts: Require(...) condition location in wrapped functions

texts:
If I'm wrapping functions, like below, does it make a difference whether I check the input argument in the private function or the external one? Will it save me gas cost to do it in the external one because it will revert the function the earliest?
contract Example {

    function wrapperForFunction(uint256 exampleArg) external {
        //require(...) check best here ?
        _function(exampleArg);
    }

    function _function(uint256 exampleArg) private {
        //require(...) check best here ?
    }
}


texts: How to generate deterministic keypairs using ed25519

texts: I am trying to implement my wallet using ed25519 curve, i was using tweetnacl from this link  "https://github.com/dchest/tweetnacl-js" its working, But i want to generate deterministic key-pair creation  from the 12 word seed.similar to eth-lightwallet/metamask. How i can create it,using edd25519 curve need help.


texts: Simple question, which are the best practices to safely store money collected by ICOs. I know multisig is an option, but after multisig suicide doesn't sound so good. There are more?


texts:
pragma solidity ^0.4.0;

contract DataStore {

   struct DataModel
   {
       uint id;
       bytes32 string1;
       bytes32 string2;
       bytes32 string3;
       uint actorId;
       bytes32 string4;
       bytes32 string5;
       bytes32 string6;
       bytes32 string7;
    }

    mapping(bytes32 => DataModel) dataMapping;
    DataModel datamodel;
    address owner;

    function DataStore()
    {
        owner = msg.sender;
    }

    function storeData(bytes32 hash, uint id, bytes32 string1, bytes32    string2, bytes32 string3, uint actorId, bytes32 string4, bytes32 string5, bytes32 string6, bytes32 string7) returns (bool response)
    {
        if(msg.sender != owner)
        {
            return false;
        }else
        {
            datamodel.id = id;
            datamodel.string1 = string1;
            datamodel.string2 = string2;
            datamodel.string3 = string3;
            datamodel.actorId = actorId;
            datamodel.string4 = string4;
            datamodel.string5 = string5;
            datamodel.string6 = string6;
            datamodel.string7 = string7;

            dataMapping[hash] = datamodel;

            return true;
        }
    }

    function queryData(bytes32 hash) returns (uint, bytes32, bytes32, bytes32, uint, bytes32, bytes32, bytes32, bytes32)
    {
        if(msg.sender != owner)
        {
            throw;
        }

        DataModel model = dataMapping[hash];
        return (model.id, model.string1, model.string2, model.string3, model.actorId, model.string4, model.string5, model.string6, model.string7);
    }
}

I have deployed the contract and received the address.
To store data, I write: DataStore.storeData.sendTransaction("hash", 1,
"instrument", "ccy", "er", 64, "st", "end", "ts", "tz", {from:
eth.accounts[0]}
I receive:

  I1026 18:36:14.659905 eth/api.go:1185]
  Tx(0xcfd97f6c50c4ecca05e8df6939c17b2d9da01107064ccecf943024dabb8998b2)
  to: 0x21f3801411da8b93346bb6e2c216159d1e21ff53
  "0xcfd97f6c50c4ecca05e8df6939c17b2d9da01107064ccecf943024dabb8998b2"

I start mining using miner.start() and let some blocks be mined.
Then I stop mining using miner.stop()
Then I check storage using:
eth.getStorageAt("0x21f3801411da8b93346bb6e2c216159d1e21ff53") and I
get:

  "0x0000000000000000000000000000000000000000000000000000000000000000"

If I try: DataStore.queryData("hash"), I get:

  invalid address


texts: Error InternalCompilerError: Stack too deep, try removing local variables

texts:
pragma solidity ^0.4.23;

contract CareerCertificate {

struct Certificate {

    bytes32 a;// existente - DUDA
    bool b;// existente - DUDA
    uint c;// existente - DUDA

    bytes32 d;
    bytes32 e;
    bytes32 f;
    bytes32 g;
    bytes32 h;

    bytes32 i;//Nuevo
    bytes32 j;//NUEVO
    bytes32 k;//NUEVO

    uint l;
    uint m;

    bool active;
}

address public ceoAddress;
address public employee;

mapping (bytes32 => Certificate) public certificates;//<___________

event CertificateCreated(address creator, string id, string RUT);
event SetActive(address responsable, string id, bool active, string description);

constructor() public {
    ceoAddress = msg.sender;
}

//funcion que crea un certificado recibe los campos y lo convierte en la variable bytes32
function createCertificate(string _a, uint _date, string _completeName, string _RUT, string _institution, string _RutInstition, string _title, string _FechaTitulacion,
string _NroRegistro, string _CodigoVerificacion, uint _completionDate, uint _registerNumber) onlyEmployees {

    bytes32 realId = convert(_a);
    require(!certificateExists(_a));
    certificates[realId].a = a;

.....
.....
....

I have a problem that when I add a variable to the struct it shows me that error. I still have my doubts if I am doing bad mapping, because deleting the mapping or a variable of the struct eliminates the error.


texts: Local variable and state variable, and the difference between them

texts:
I am new  to solidity. When I read the solidity documentation, it says local variable and state variable. But I can't find the definition of the two terms.

Can anyone explain the meaning of local variable and state variable, and the difference between them.


texts: infura web3.js get contract public variable

texts:
I use this easy code to display the public variable of a smart contract:

window.addEventListener('load', function () {

    if(typeof Web3 !== 'undefined'){
        var web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/MY_KEY"));
        console.log('Found web3!');
        startApp();
    }else{
        console.log("No web3!");
    }

    function startApp(){

        var SalesABI = web3.eth.contract([{
          // loads of lines
        }]);
        var SalesAddress      = 'address';
        var SalesContract     =  SalesABI.at(SalesAddress);

    displayETHRaised(SalesContract, web3);
    }

});

function displayETHRaised(_SalesContract,_web3) {
    _SalesContract.tokenRaised((_err,_resp) => {
        if (_err != null) {
            console.log(_err);
        } else {
            $('#DOM_ID').innerHTML = _web3.fromWei(_resp, "ether").toString(10);
        }
    });
}

I do not get the value of the public var and I don't get an error nor warning.

Everything seems to be fine but I do not get the value of the public variable tokenRaised.


texts: perform 2 transactions in same block in truffle

texts:
I'm trying to perform 2 transactions in the same block in truffle. Is that possible?
example
await pool.deposit(0, '0', { from: user1Address });
await pool.deposit(0, '0', { from: user2Address });
await pool.deposit(0, '0', { from: user3Address });

pool being a contract. I'd like to perform these transactions in the same block.


texts:
I am able to get the balance of my custom token with web3 javascript.The code is shown below.

However, when i switch to web3j, I don't find equivalent method like web3.eth.contract(contractABI).at(contractAddress).

Can anyone please advise how can i do the same with web3j?

var web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/<APIKEY>"));

address = "0x0e2e75240c69495d2b9e768b548db381de2142b9" //From Etherscan
contractAddress = "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" //OMG
contractABI = human_standard_token_abi

tokenContract = web3.eth.contract(contractABI).at(contractAddress)

console.log(tokenContract.balanceOf(address).toNumber())


texts: What is the easiest way to view transaction history if a custom token?

texts:
What do you think it's the easiest way to view history of transaction for a custom token ? Like A sent X to be B on XX/XX/XXXX. Especially for people who don't know about Ethereum.

A tool like etherscan falls into the "complicated" category (I don't even know how to recover data from it). Mist is decent, but can a bit tough to parse. Any app ? How hard is it to code one ?


texts: Is it possible to get contract payload/data of a smart contract created via instance?

texts:
I am trying to get contract instance payload created via instance but don't seem to know how. I don't want to save just the contract address. Kindly help. See my code below.

contract LandRegistry {
//Land Details
struct landDetails{
string state;
string district;
string village;
uint256 surveyNumber;
address payable CurrentOwner;
uint marketValue;
bool isAvailable;
address requester;
reqStatus requestStatus;
    }

   landDetails public land;

constructor(
string memory _state,
string memory _district,
string memory _village,
uint256 _surveyNumber,
address payable _OwnerAddress,
uint _marketValue,
uint id) public {
land.state = _state;
land.district = _district;
land.village = _village;
land.surveyNumber = _surveyNumber;
land.CurrentOwner = _OwnerAddress;
land.marketValue = _marketValue;
profile[_OwnerAddress].assetList.push(id);
} }

Contract to call the landregistry

Contract Factory {
//Registration of land details.
function Registration(
string memory _state,
string memory _district,
string memory _village,
uint256 _surveyNumber,
address payable _OwnerAddress,
uint _marketValue, uint id) public returns(LandRegistry) {
require(superAdmin[_village] == _msgSender() || isOwner(),'');
LandRegistry registry = new LandRegistry(_state, _district, _village, _surveyNumber, _OwnerAddress, _marketValue, id);
_LandRegistry[keccak256(abi.encodePacked(_msgSender()))] = registry; return registry;     } }


texts: Where can I just download the entire blockchain data folder after install Mist?

texts:
I'm running Mist for linux and its taking awhile to download the entire blockchain. Is there a place I can just download the entire blockchain folder and just copy it into the /resources folder in the mist folder?

Also where can I specify where to place my /resources folder? Say I want to only download it to my network drive only instead of on my small laptop hard drive.


texts: Read Solidity smart contract private field

texts:
Let's suppose this smartcontract:
contract Test1 {
   string private i_am_private;
   string public i_am_public;
   ...
}

Solidity's compiler is automatically generating a getter function for public fields.
So we can easily read value from another contract or from a DAPP.
But everything is stored on blockchain and everything is public. So it might have a way to read private fields too... We can do that manually by browsing a blockchain explorer for example. But is there a simple way to do that from a DAPP or from another smart contract ?
Thanks


texts: Getting "exceeds block gas limit" regardless of gas value

texts:
My code is below, setting gas to 21000, but I've tried values up to 100000 and nothing works:

eth.sendTransaction({from:eth.coinbase, to:ACCOUNT, value: web3.toWei(30, "ether"), gas:21000})

I've also tried:

eth.sendTransaction({from:eth.coinbase, to:ACCOUNT, value: web3.toWei(30, "ether"), gas:21000, gasPrice:web3.toWei(300, 'gwei')})

Regardless of the gas value I select, I get the error "Exceeds block gas limit"

Any idea how I can get rid of this error?

**This question has been marked as a duplicate of another question, but that question remained unanswered and is pending OP posting their actual code snippet. There aren't helpful answers elsewhere as of yet.


texts:
I'm trying to get all Transfer events from an account of an ERC721 token, I'm currently struggling with the following error. I googled around but couldn't find much helpful things. I'm definitely on the right network (mainnet) and the contracts are deployed and functional as far as I can tell.

getWeb3.js: https://gist.github.com/adrianmcli/2f42dd98f7d900ec7828930a4a7a1e97

transactions.js

  import getWeb3 from "../utils/getWeb3";
  import { MintableNonFungibleToken } from "non-fungible-token-abi";
  import Utils from "web3-utils";
  const web3 = yield getWeb3();

  var myContract = new web3.eth.Contract(
    MintableNonFungibleToken,
    "0x8c9b261faef3b3c2e64ab5e58e04615f8c788099"
  );
  const addr = "0x0a8e20ee171630ef9dfebf02149169f90c133cd8";
  const events = yield myContract.getPastEvents("Transfer", {
    fromBlock: 0,
    toBlock: "latest",
    topics: [
      Utils.sha3("Transfer(address,address,uint256)"),
      Utils.padLeft(addr, 64)
    ]
  });
  console.log(events);

Error

 Error: Couldn't decode uint256 from ABI: 0x
    at SolidityTypeUInt.formatOutputUInt [as _outputFormatter] (http://localhost:3000/bundle.js:48786:15)
    at SolidityTypeUInt.../../node_modules/web3-eth-abi/src/type.js.SolidityType.decode (http://localhost:3000/bundle.js:49746:17)
    at http://localhost:3000/bundle.js:49238:49
    at Array.forEach (<anonymous>)
    at ABICoder.../../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (http://localhost:3000/bundle.js:49237:13)
    at ABICoder.../../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeLog (http://localhost:3000/bundle.js:49281:33)
    at Object.../../node_modules/web3-eth-contract/src/index.js.Contract._decodeEventABI (http://localhost:3000/bundle.js:55150:31)
    at http://localhost:3000/bundle.js:38813:57
    at Array.map (<anonymous>)
    at Method.../../node_modules/web3-core-method/src/index.js.Method.formatOutput (http://localhost:3000/bundle.js:38812:23)

I checked and I'm getting data from the actual RPC call but it seems web3 cannot process the answer from RPC.


texts: Mist 0.9 Freeze: Downloading Swarm binary: 78%

texts:
I am running a fully synched geth 1.7.1 local node on mainnet (--datadir "G:)
Mist 0.8.10 loads and works fine

However when I close Mist 0.8.10 and try to run Mist 0.9.0 or 0.9.1 it seems to freeze with the message: downloading swarm binary:78%

Any suggestions as to how to overcome this?


texts: Is it possible to create, or populate an enum based on a constructors parameter? Or is it possible to append items to an enum?


texts: How to detect transfer of funds from contract?

texts:
I need to determine (programatically) that the contract correctly refunded value. Contract uses this command:

msg.sender.transfer(msg.value)

Of course, I can check balance before and after the transaction (and that works), but I was hoping I could inspect the transaction directly. Is this possible?

As this question shows, I am a bit confused where these "refund transactions" are written. Are they a part of original transaction?


texts: Transaction dropped. How to increase gas fee?

texts:
I sent some ether using Ledger Live, but the gas fee was too low. Id like to increase the gas fee. I was told I can do this via Ledger Etherum Wallet for Chrome. However, when I open Ledger Etherum Wallet it does not show my transaction.

How can I increase the gas fee?
Thanks!


texts: Verifying smart contract on etherscan created through contract factory

texts:
I deployed contract through contract factory and I'm trying to verify it on etherscan.

After failing attempts I have compared the bytecode of deployed contract from contract factory with the bytycode of the contract which etherscan is creating after verification.
They are different within first 20 characters.

I'm sure this is not a problem of mismatch of compiler version or different compiler because I can verify the same contract if deployed directly. I use remix to deploy and I have no problem with verifying contracts if deployed directly.

This is not a problem of constructor arguments because I can verify this contract if deployed directly with the same arguments.

Do you think is it possible to verify contract with constructor arguments on etherscan created through contract factory?

What would you suggest otherwise to solve the problem.


texts:
How can I integrate truffle with swarm or ipfs for permanent document storage?
Are there any libraries?


texts: Is it possible to import a Metamask account to Mist or Ethereum Wallet? Metamask doesn't allow to export UTC file or json file, only pass phrase and private key and I don't see the option to import these in Mist or Ethereum wallet? Thanks.


texts: Access private blockchain from another PC/Laptop?

texts:
I have private block chain on my PC.The private blockchain is configured and deployed using geth. I want to connect to that blockchain from another node(my laptop) to access the smart contract deployed. For that what should I have to do?

Is this possible via Metamask( connect to custom RPC)?or geth is mandatory?If I use geth, How can I download the genesis block to my laptop and become a node in the private network?


texts: Are flash loan attacks possible in layer 2 async blockchain?

texts: Flash loans attack has become a new normal every week. But I have read that it won't be possible in async sharding, but couldn't find enough information about it online. Is the information correct, if yes, why it's not possible in sharded blockchain?


texts: How can i create an array that contains multiple tuples in solidity?

texts:
I am trying to create a smart contract that will store an array containing GPS coordinates such as:

X=[(31.332,54.213),(32.013,54.312), (33.124,56.2134),(34.123, 57.789), (34.789,59.654),(31.332,54.213)]

The goal of this is to create a polygon and compare incoming gps coordinates whether inside or outside this polygon(point in polygon problem). I haven't been able to find any decent solution on how to create this array of a list of lat and long coordinates. Everyone suggests using strucs but they seem to be creating a new data type. I was thinking of nesting the strucs for each vertex into one array, but I can't find a way of doing it. Thanks in advance.


texts:
Are there any current proof of concepts or implementations of zero knowledge proofs in the context of smart contracts?

If not how long until we can store private data on a public blockchain?


texts:
So I am putting together a test for my contract and this is the it() statement:

it('allows one account to enter', async () => {
    await lottery.methods.enter().send({
      from: accounts[0],
      value: web3.utils.toWei('0.02', 'wei')
    });

I am unclear as to why I am getting this error:

  Error: [ethjs-unit] while converting number 0.02 to wei, too many
  decimal places

Does web3.utils no longer take care of the conversion or did I calculate the decimal places wrong?

Here is the snippet of the actual contract that assigns the amount of money:

function enter() public payable {
        require(msg.value > .01 ether);
        players.push(msg.sender);
    }


texts: One contract to another contract interaction analysis

texts:
I tried contract interaction using following code:

contract C2 {
    function aFunction(uint aParameter) returns(uint) {
    return (10);
    }
}
contract C1 {
    function call (uint aParameter) returns(uint){
        C2 c2 = new C2();
    return c2.aFunction(aParameter);
    }
}

It worked for me. Then i changed return c2.aFunction(aParameter); to return c2; It returned me an address (suppose c2_addr). I executed eth.getCode(c2_addr); It just returned "0x". Now i have following questions:

I just called the "call" function of C1 without using sendTransaction(). So how the line C2 c2 = new C2(); is executed.
Contract C2 is mined or not.If yes, then who deployed it as i invoked the function as .call() and why there is no bytecode in blockchain regarding this contract. And if C2 is not mined, how it is possible to invoke its function.


texts: Solidity: How to initialize an array within a struct, passed as a parameter?

texts:
pragma solidity 0.4.25;

contract A{
    struct N{
        string any;
        uint256[] numberArray;
    }

    N[] public numbers;

    function init(uint256[] _numbers) public{
        for (uint256 i = 0; i < _numbers.length; i++) {
            uint256[] memory arr;
            arr[0] = _numbers[i];
            numbers.push(N("anything", arr));
        }
    }
}

This contract compiles but throws:

transact to A.init errored: VM error: invalid opcode.
invalid opcode The execution might have thrown.

What I wish to achieve

Example call:

init([1,2,3,4,5])

Outcome:

N[0] = "anything", [1]

N[1] = "anything", [2]

N[2] = "anything", [3]

N[3] = "anything", [4]

N[4] = "anything", [5]

Afterwards I would like to be able to push to the array within the array.


texts: Rolling a die at some point in the future

texts:
This question has been asked previously by someone else but the answers weren't quite sufficient.

I want to write a simple contract that will yield an immutable 'random' number after a period of time.

My thought is to write it with reference to the hash of a future block of some chain.  So contract will only complete if block height N is available.  If the block is available, the contract will use the bits of the specified block hash to return the outcome of the dice roll.

I'm solidity noob, so wondering if this is a worked example by now...


texts: When is it profitable for a miner to mine non-empty blocks?

texts:
Can someone explain the miner optimization calculus that relates block processing time, gas price, and uncle rate - when is it profitable for a miner to mine non-empty blocks?

This question was asked at https://www.reddit.com/r/ethereum/comments/58smlm/can_someone_explain_the_miner_optimization/ it did not receive an answer and I'd love to know.


texts: How to properly delete the first element in an array?

texts:
Is it possible to delete the first element of an array without shifting all elements later?

My guess is that I can remember the index of the 'current first element', like so:

uint[] public myArray;
uint firstElement;
myArray.push(3);
myArray.push(6);
myArray.push(10);
delete myArray[firstElement];
firstElement++;

but, is there a convention or something built in for this?


texts: Missing File from Mix IDE Install Package for Windows

texts: I tried to install the Mix IDE but MSVCR120.dll is missing from the install package and it won't run. Any ideas what else I could try?


texts: Pancakeswap (sushi swap fork) swapping tokens reverts

texts:
function swapTokenForToken(uint256 amountIn, address tokenIn, address tokenOut, uint256 amountOutMin) public payable returns (uint256){
        address[] memory path = new address[](2);

        path[0] = tokenIn;
        path[1] = tokenOut;

        uint256[] memory amounts = PancakeLibrary.getAmountsOut(Pancakeswap_Factory_Address, amountIn, path);

        require(amounts[amounts.length - 1] >= amountOutMin, 'BSCBB: INSUFFICIENT_OUTPUT_AMOUNT');

        assert(IERC20(tokenIn).transfer(PancakeLibrary.pairFor(Pancakeswap_Factory_Address, path[0], path[1]), amounts[0]));

        (address input, address output) = (path[0], path[1]);
        (address token0,) = PancakeLibrary.sortTokens(input, output);
        uint amountOut = amounts[1];
        (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));

        IPancakePair(PancakeLibrary.pairFor(Pancakeswap_Factory_Address, input, output)).swap(
                amount0Out, amount1Out, address(this), new bytes(0)
        );

        return amountOut;
    }

I am trying to swap two tokens utilising the following code. The only problem is that the transactions revert, with error code: Pancake: INSUFFICIENT_OUTPUT_AMOUNT. What am I doing wrong?
Thanks.
Edit: It behaves quite strangely, as the code works with some high liquidity tokens, but stops working with less known tokens.


texts: How come this ETH wallet has transactions but 0 in fees?

texts:
This might be a stupid question but as far as I knew as soon as you send a transaction on ethereum you pay a transaction fee. However this wallet has a total of 1,388,802 transactions but 0 in fees.
This is the wallet
0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2


texts:
I made own ethereum token for test and i tried buy some tokens. But there is some issue.
When i sent 0.2 ethereum i didnt get any tokens and tokens still have only owner. Is anything wrong in my contract code?

There is my source code: https://ropsten.etherscan.io/address/0x2e52b4d709196011bfcbe9f34838d01cd92ee2ff#code

There is the test transaction

https://ropsten.etherscan.io/tx/0xd5774eba8f46cec3fd85ab4a086d59fef46de8f2e8800fbad1d15520ed82b19a


texts: Fatal error in initialization of genesis.json file

texts:
I am using geth 1.6.7 stable release. During initialization of genesis block for priavte network it throws an error which is

  Fatal: invalid genesis file: invalid character '"' after object key:value pair

My genesis.json

{
 "nonce": "0x0000000000000042",
 "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "difficulty": "0x400",
 "alloc": {},
 "coinbase": "0x0000000000000000000000000000000000000000",
 "timestamp": "0x00",
 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "extraData": "ChainSkills Genesis Block",
 "gasLimit": "0xffffffff"
 "config": {
    "chainId": 59,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
 }
}


texts: How Can I Use Javascript to Accept ERC20 Token Payments on My Site?

texts:
I would like to accept my own ERC20 token as payment on my website. The current way I'm doing it requires 2 transactions and a 3rd party plugin that requires a fee. For security's sake, I'd rather have no 3rd party plugin. This will also likely prove cheaper for my customers and overall peace of mind for me.

Conceptually, I'd think it would be as simple as just sending the tokens to my address with a memo.

But would like it to be as easy as possible for anyone. I don't mind using metamask as I think that is an easy route for most people to follow. The goal is to make this so simple, someone who doesn't know much about crypto could use it. Thanks!


texts:
I created an env file as named '.env' for kept the project keys. But I could not see in folder this file. how do i update this file later on Mac?

how do I update this file if I want to add anything else later?
thank you.


texts: Sending ether to an account from a Smart Contract

texts:
I've just started learning about Smart Contracts and Ethereum, and I've come accross the classical example of FoundRaising.
( e.g. https://developer.ibm.com/clouddataservices/2016/05/19/block-chain-technology-smart-contracts-and-ethereum/)

Since the good practice of a Smart Contract implies that the outcome of the contract needs to be the same accross all the nodes, I have an issue understanding the drawdown() functionality of the smart contract presented at the provided URL.

Concretely, when calling :

benefactor.send(this.balance);

How does the actual sending process occur?
Is the balance of the benefactor changed locally in each node that executes the smart contract? And if so...
How is the consensus achieved?


texts: Access ethereum client from remote machine

texts:
I need to access ethereum client  setup on remote hosted machine (google cloud ). How can I access the client from the web browser of my local machine ?
Current installations on my machine

user@instance-1:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial
user@instance-1:~$
user@instance-1:~$ node -v
v6.12.3
user@instance-1:~$ npm -v
3.10.10
user@instance-1:~$ ganache-cli -version
Ganache CLI v6.0.3 (ganache-core: 2.0.2)


texts: Aren't oracles extremely data consuming?

texts:
I'm a bit concerned that oracles used professionally would need a lot of disk space.

The blockchain is not growing rapidly since if a contract didn't change its state, the next blocks state tree just links to the state of its ancestor.

But using oracles with very frequently changing states (e.g. price tickers, wheather data,...), wouldn't they effectively spam the blockchain?

of course with only very few applications using oracles, this wouldn't be a problem - but if you imagine some financial products running on the blockchain I expect a huge traffic?

Is this something that could be solved with sharding?

I highly appreciate your input!


texts: how to deploy escrow smartcontract and use it with exciting erc20 tokens

texts:
i want to build escrow smart contract with one particular ERC20 standard token. i want to hold token in escrow as a guarantee for transaction. and on some condition those tokens should go back to sellers account.

    so in my app party A is use some services of party B but party B is not trusted so party B will keep some token in escrow and after some condition party B will get those tokens back. its like one way transaction escrow.

    but what conditions we can use like if condition. also Can i send tokens to smartContract and if i can then how to send those tokens back to Party B's wallet or how to send received tokens from escrow smartcontract to any wallet owner person

    and if i am the owner of the tokens and  i am not able to understand who can deploy escrow.cause if i deploy escrow and im the owner of the tokens then i can go to that token function and use transferfrom() function and use escrow address to get back my tokens so how to prevent this question.so how to safely lock those tokens in escrow. because almost 90% tutorials are about ether not about tokens on ethers.


texts: web3js 1.0.0-beta.24 The returned value is not a convertible string:

texts:
I'm trying to read symbol from this contract https://etherscan.io/address/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0#readContract but getting en error The returned value is not a convertible string. Here is my code:

const contractInstance = new Config.web3.eth.Contract(abi, "0x86Fa049857E0209aa7D9e616F7eb3b3B78ECfdb0");

const symbol = contractInstance.methods.symbol().call();

symbol.then((res) => {
  console.log(res)
}).catch((err) => {
  console.log(err)
})

At the same time i'm able to read name, totalSupply, decimals.Is there is any way to read contract symbol ?


texts: How to set time based function in solidity?

texts:
I want to run a function after every 365 days in Solidity. I have tried to use the now keyword, but it is not working (I tried in Remix).
How can I get the time?


texts: Connecting two private nodes on different machines

texts:
My college network is divided into different subnet. In a subnet, I am able to connect two different machines by admin.addPeer("enode Address with ipv6 ip and port"). But when i changes my subnet, Using the same procedure under different subnet, i am not able to connect the two nodes. To start the nodes I have used "geth --ipcdisable --port //port --rpcport //rpcport init //genesisfile". I have used same genesis file and different ports on two machines. Is there any other flag that I need to specify? or there is any problem with the subnet(maybe subnet is blocking something).

I have also add the flag --bootnodes //enode address with ipv4 and port. Same problem i.e. working under a subnetwork and not on other.


texts: Nested structs that are part of a mapping broken in Solidity 0.5.0?

texts:
The following code compiled successfully with Soldity 0.4.21.  With 0.5.0 it triggers a fatal compilation error as follows:

UnimplementedFeatureError: Encoding type "struct TestNestedStructInMapping.structNested memory" not yet implemented.
Compilation failed. See above.
Truffle v5.0.0-beta.2 (core: 5.0.0-beta.2)
Solidity v0.5.0 (solc-js)
Node v8.11.1

Here is the code:

pragma solidity ^0.5.0;

contract TestNestedStructInMapping {

    // The struct that is nested.
    struct structNested {
        uint dummy;
    }

    // The struct that holds the nested struct.
    struct structMain {
        structNested gamePaymentsSummary;
    }

    // The map that maps a game ID to a specific game.
    mapping(uint256 => structMain) public s_mapOfNestedStructs;
}

Here is a link to a Truffle project that you can pull and test with:

https://github.com/roschler/nested-structs-tests.git

Does anyone know how to solve this?


texts: Geth 1.5.9 on Windows Server 2012 r2 stops

texts:
I'm runing Mist 0.8.9 on Windows Server 2012 R2 and I'm having problems with node syncronisation. I run command in powershell:

  .\geth.exe --datadir D:Ethereum

and I got this:

I0419 15:08:37.764496 node/config.go:445] Failed to start Ledger hub, disabling: libusb: not found [code -5]
I0419 15:08:37.765663 ethdb/database.go:83] Allotted 128MB cache and 1024 file handles to D:\Ethereum\geth\chaindata
I0419 15:08:37.805467 ethdb/database.go:176] closed db:D:\Ethereum\geth\chaindata
I0419 15:08:37.806468 node/node.go:176] instance: Geth/v1.5.9-stable/windows/go1.7.4
I0419 15:08:37.806468 ethdb/database.go:83] Allotted 128MB cache and 1024 file handles to D:\Ethereum\geth\chaindata
I0419 15:08:37.863469 eth/backend.go:187] Protocol Versions: [63 62], Network Id: 1
I0419 15:08:37.864469 eth/backend.go:215] Chain config: {ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP
150: 2463000 EIP155: 2675000 EIP158: 2675000}
I0419 15:08:37.865469 core/blockchain.go:219] Last header: #0 [d4e56740] TD=17179869184
I0419 15:08:37.865469 core/blockchain.go:220] Last block: #0 [d4e56740] TD=17179869184
I0419 15:08:37.865469 core/blockchain.go:221] Fast block: #0 [d4e56740] TD=17179869184
I0419 15:08:37.868508 p2p/server.go:340] Starting Server
I0419 15:08:40.002570 p2p/discover/udp.go:227] Listening, enode://9ef9ff367d0d1fc0e4d6718a3712fed9656e8d9b1b3016738a7b48
877620c2655c8a93725ee75aa22097bf4caa55df309b31644906cf2437485faf640fe3a5b8@[::]:30303
I0419 15:08:40.006567 p2p/server.go:608] Listening on [::]:30303
I0419 15:08:40.006567 node/node.go:341] IPC endpoint opened: \\.\pipe\geth.ipc

Here is stucked and it's not starting sync at all. Does anyone know what should I look or do in this situation?

Thank you in advance,
Tomislav


texts: Is ABI necessary for calling ropstend smart contract?

texts:
I only have ropsten's smart contract address, so I'm trying to get it through web3.js with:
window.web3.eth.Contract(abi, address)

but i see in the documentation it receives two parameters, i don't have abi, so is it required? i see in older version we just needed the address.
I'm using "web3": "^1.3.4"

Thank you


texts: How to import the web light-wallet into metamask?

texts: with the same seeds it looks like it will generate different addresses, is that because i am using the testing node or? If I use the same type of node, I can import the light wallet into metamask wallet easily?


texts: Many of the discussions I read about security relate to how miners can manipulate this or that aspect of the way a transaction gets processed, such as whether or not it's included, what it's timestamp will be, etc. But I wonder if there is any solid information on how many miners are out there trying to do these things? Is there a statistic out there (or can there even be one) that says x% of miners are behaving, while y% are trying to cheat? Is it really something that Solidity programmers need to concern themselves with?


texts: In ICOs why initial supply/total supply tokens are transferred to owner address rather than storing it in the contract itself?

texts:
Here I have taken two of the top 20 ERC20 Token/ICO.
1.BNB(https://etherscan.io/address/0xB8c77482e45F1F44dE1745F52C74426C631bDD52#code)
2.BAT(https://etherscan.io/address/0x0d8775f648430679a709e98d2b0cb6250d2887ef#code)
In BNB contract, when deployed it has been coded to set the total supply as the balance of the owner and the tokens are transferred from the owner to whoever buys the token , so the trust part lies in the owner/some particular acccount address,
whereas in case of BATokens the tokens are generated and distributed as and when someone sends the ether to the contract, here the trust lies in the smart contract or it is what called as decentralised trust.
Since BNB is topping in the etherscan, my doubt is why they haven't implemented the token handling in the contract like BATokens? Is there any technical issues like bugs, loop holes? Or is there any bussiness logics behind that?


texts: I find docs of solidity very confusing can anyone suggest me some books or online resources for learning solidity?


texts:
I wonder where strings are stored in Solidity?

Especially, where are string literals, function arguments, and variables stored?

I recall, I've read that strings cannot be saved to memory, but is that right?


texts:
How can I catch exception thrown by method call?

(async () => {
   try {
      const contract = await MyContract.deployed();

      const gasPrice = await web3.eth.getGasPrice();

      contract.methods
        .myMethod()
        .send({ from: account, gasPrice });  // gas: 200000,
   } catch (e) {
      console.log(e);
   }
})()

For some reason I'm not able to cache error thrown by this code. I've tried different ways like using .on('error') and .catch but nothing works.

(node:7042) UnhandledPromiseRejectionWarning: Error: "gas" is missing
at signed (/Users/dimitry/Workspace/contract/node_modules/web3-eth-accounts/src/index.js:165:21)
at /Users/dimitry/Workspace/contract/node_modules/web3-eth-accounts/src/index.js:259:16
at process.internalTickCallback (internal/process/next_tick.js:77:7)

I'm using "web3": "^1.0.0-beta.37"

Thanks.


texts: Geth Setup: enabling JSON RPC endpoint with --http

texts:
I'm a beginner with blockchain and only starting to read programming textbooks. So a newbie to computer science as well.
Right now I'm playing around with my Windows desktop though will be switching to linux soon.
I downloaded geth and started running it. Started reading up on the eth2 node setup.
For eth2 node setup, per Eth2 Launchpad website:
"The JSON RPC endpoint for the eth2 node to connect to must be enabled with --http. This will enable the JSON RPC service on the default port of 8545."
Could you tell me please how the code to enable that would look like?
Also: I already ran geth just with a simple cmd >geth
Turned it off for now because my computer got very slow.
That said, given that I ran it already for the day, did I mess up that initial setup already or does it not matter when you enable the rpc endpoint?
Thank you so much and I'm very sorry for how basic this question is.


texts: Constantly "Waiting to be mined" after certain call in contract

texts:
I have a crowdsale contract, that seems to be working fine.
It receives funds, and returns a token in exchange.

However, once its past the deadline, and I run the checkGoal() function, the contract remains in a "Waiting for transaction to be mined" state indefinitely.

modifier afterDeadline() { if (now >= deadline) _; }
function checkGoalReached() afterDeadline{
    if(msg.sender==admin){
        if (amountRaised >= fundingGoal) {
            fundingGoalReached = true;
        }
        crowdsaleClosed = true;
    }
}

I don't understand what it is about this particular function that seems to lock the contract up.

Any ideas?


texts: What can be done after falling victim to a MyEtherWallet Phishing scam?

texts:
On July 17, I received an alert message (copied below) via Slackbot. It appeared to come from my EtherWallet team, and encouraged a wallet protection increase via 2 factor identification. Inside the message, there was an internet link redirecting to a FAKE internet site.  It sounded great but it was a big phishing scam.

All my coins were taken overnight and my remaining balance = 0.00

Is there anything I can do about that? Can I report that address as a phishing address?  Is there a way to track the thief? Or to mark the account as a PHISHING Account?

I would appreciate some support.

Below is the PHISHING email. [NOTE that the link was reformatted so that it cannot be accidentally clicked on by people reading this SE post here.]

  slackbot View in the archives

  slackbot 12:56 PM, July 17th @tomtom asked me to remind you “---
  NOTICE! To all Ethereum holders ---

  Due to the increasing number of phishing attacks on MyEtherWallet, we
  decided to increase the security by implementing Two-Factor
  Authentication for all Ethereum wallets.

  Visit the link below to activate the Two-Factor Authentication on your
  Ethereum wallet:

  myetherwallet[dot]com#activate-2fa-76638-843N7335-8773636

  Please be aware that you will not be able to access your Ethereum
  wallet anymore on MyEtherWallet without activating the new security
  protocol (Two-Factor Authentication).

  We are taking this measures to protect both you and our network from
  phishing and malicious attacks.

  Thank you for your cooperation and understanding.

  MyEtherWallet Team”.


texts: How to call external ERC20 token transfer function

texts:
I am trying to transfer ERC20 token from another smart contract. For that I am following this article. So I wrote the smart contract as following,
pragma solidity >=0.4.23 <0.6.0;

interface IERC20 {
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}

contract SmartMatrix is IERC20 {
    IERC20 private _token;
    constructor(IERC20 token) public {
        _token = token;
    }
    function sendERC20TokeToDnividends(address sender, address recipient, uint256 amount) public returns (bool) {
        _token.transferFrom(sender, recipient, amount);
        return true;
    }
}

But I am getting the following error while I try to deploy,
This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly.

But I remove interface It deploys successfully.
For example, The following code works,
pragma solidity >=0.4.23 <0.6.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/token/ERC20/IERC20.sol";

contract SmartMatrix is IERC20 {
    IERC20 private _token;
    constructor(IERC20 token) public {
        _token = token;
    }
    function sendERC20TokeToDnividends(address sender, address recipient, uint256 amount) public returns (bool) {
        _token.transferFrom(sender, recipient, amount);
        return true;
    }
}

Please help me to fix this issue.
Edited:
Removed inheritance and tried as the following and getting same error,
pragma solidity >=0.4.23 <0.6.0;

interface IERC20 {
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}

contract SmartMatrix {
    IERC20 private _token;
    constructor(IERC20 token) public {
        _token = token;
    }
    function sendERC20TokeToDnividends(address sender, address recipient, uint256 amount) public returns (bool) {
        _token.transferFrom(sender, recipient, amount);
        return true;
    }
}


texts: How to create a smart contract to send an ETH tx on time?

texts:
For a specific purpose, I would like to create a smart contract in ETH blockchain and its job is to send a specific amount of ETH to a defined address when the time comes (unix time or specific block number).

I'm just get started with Ethereum and blockchain, so forgive me if this question is noob. But someone has a code sample that I can follow and change to fit my purpose?

Here's all I need:

time come (unix time / block number) -> send defined ETH amount to defined ETH address/another smart contract address
with customized gas & gwei


texts: What is the minimum hard drive space needed to develop for Ethereum?

texts: I'm looking into buying a Chromebook and running Crouton or Chrubuntu however the Chromebook I want only has 32GB of hard drive space. Is this sufficient to develop with or will the blockchain take up too much space?


texts: This is going to be short question and may be silly, but I'm literally stuck with a problem, where I need to pass address(0) to function in Truffle Test in JS and don't really know how to do it. In solidity it's simply address(0), but in Truffle JS?


texts: Geth error with HTTP JSON RPC and urllib python3

texts:
I try to run this (geth is started with rpc on http://localhost:8545)

#!/usr/bin/env python3
from urllib.parse import urlencode
from urllib.request import Request, urlopen
rpc = "http://localhost:8545"
print(urlopen(Request(rpc,urlencode({"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":42}).encode(),headers={'Content-Type': 'application/json'}), timeout=60).read().decode())

It print :
{"jsonrpc":"2.0","error":{"code":-32600,"message":"invalid character 'j' looking for beginning of value"}}


texts: Can't send from wallet contract to main account with Ethereum Wallet 0.9.0

texts:
Question from a newbie that is learning it's way around the blockchain world. Hope you can help me out!

My Ethereum Wallet holds the main account and some accounts for testing. I also made one Wallet Contract with the main account as owner. Several months ago I transferred 1 Ether from the main account to the contract without problems.

I have tried several times to transfer the Ether back to the main contract but keep getting an "unknown account" error after providing the password and selecting Send Transaction. There is no entry in the node log so I have no idea what is happening here. Both the contract address and the main account address are filled in by the program. I have tried manual copy-paste, but with the same result.

Does it have anything to do with the status of the blockchain download? I have kept Wallet running for a whole day now, but there are still more then 400k blocks left to download.


texts:
I got an issue when I am trying to run a sample test code via go to access my full node.
Consider the following code snippet:
package main

import (
"context"
"fmt"
"log"

"github.com/ethereum/go-ethereum/ethclient"
)

func main() {

    conn, err := ethclient.Dial("/home/myName/.ethereum/geth.ipc")

    if err != nil {

        log.FatalF("error \n")

    }

}

I get the following message:
../go/src/github.com/ethereum/go-ethereum/rpc/server.go:24:2: cannot find package "github.com/deckarep/golang-set" in any of:
    /usr/local/go/src/github.com/deckarep/golang-set (from $GOROOT)
    /home/myName/go/src/github.com/deckarep/golang-set (from $GOPATH)

and the same for some other dependencies.
Is there a problem with the library on FreeBSD? I am fairly new to Go so there might be a problem with my configurations.
Here is my go env:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myName/.cache/go-build"
GOENV="/home/myName/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/home/myName/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/myName/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0-fdebug-prefix-map=/tmp/go-build459496987=/tmp/go-build -gno-record-gcc-switches"


texts: Interacting with contract in myetherwallet

texts:
I have developed some smart contracts and deployed/interacted with them successfully using truffle framework. However, when copying the main smart contract's address and it's ABI into myetherwallet to interact with its functions, not all functions appear although they seem to be defined correctly in the ABI. I noticed the functions that do not appear in myetherwallet, are those that call other internal functions.

For example assume we have

pragma solidity ^0.6.0;

contract DemoERC20 is X, Y, Z{

...

function balanceOf(address account) public view returns (uint256) {
    return _balances[account];
}

function transfer(address recipient, uint256 amount) public virtual returns (bool) {
    _transfer(_msgSender(), recipient, amount);
    return true;
}

function _transfer(address sender, address recipient, uint256 amount) internal virtual {
    require(sender != address(0), "ERC20: transfer from the zero address");
    require(recipient != address(0), "ERC20: transfer to the zero address");

    _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
    _balances[recipient] = _balances[recipient].add(amount);
    emit Transfer(sender, recipient, amount);
}

}

Both balanceOf and transfer are defined in the ABI, but I can only see balanceOf when trying to interact with the Demo contract over Myetherwallet. This is also the same with any function defined within contracts X, Y, or Z.


texts:
Is it possible to include in a payable function a message such as "Transaction rejected - Company not registered" which is displayed when a transaction is rejected?
My code is as per below:

    pragma solidity ^0.4.24;

contract KYCPurchase {
  uint public price = 2 ether;

  struct Company {
      string registeredNumber;
      string name;
  }
  mapping (address => Company) companies;

  function buy(string registeredNumber, string name) public payable {
    require(msg.value >= price);

    // Keep a list of buyers who have transferred enough ether
    companies[msg.sender] = Company(registeredNumber, name);
  }
}

Thanks