texts: I need to get access to the blocks between 7000 and 8000 and since I plan to query the states I need archieve option. Do I need to run a arhieve node and wait until it downloads everything, or is there any other way to get just that time frame?


texts: Unable to swap ERC20 AMIS token with other tokens missing something need help from experts.

texts:
https://etherscan.io/address/0xa23ca275a19caf9a753ce020a75c264e0b0d1674

As of today the value is in 1000$ per token i have 11 tokens ready to give 1 token amount whoever can solve the fuction issue.

I have tried to swap with other coins on 0xproject the function is not executing. There muat be some issue with function or it may be missing.  Need help in solving the issue.

URGENTLY NEED TO SWAP AND SELL.


texts: Recieve payments in Ethereum ERC-20 tokens in web-services

texts: I want to receive payments in my web-service in ethereum tokens, for example, Eos or Rep. And, of course, I must provide each user with different addresses for payment to determine who is the payer, so I create a new account and give an address to the user. After the payment has been received, I must send received tokens to the main account, but gas is needed for such transfer. What is the best way to receive ethereum erc-20 tokens in web-service?


texts: Is it possible to link contracts to existing libraries from within geth console?

texts:
I've been making and deploying contracts and libraries, deploying libraries first and then using the binary output from e.g.

$ solc --bin-runtime test.sol --libraries TestLib:0xb78f86ea662866b3131f79a886c17884e793f5c4

and copying the contract output and sending in a geth transaction as data.

Is there a way to link contracts to existing/previously deployed libraries and deploy from within the geth console, so that I don't have to independently define the ABI and keep switching between tabs?
If not, why not? And how do I use the ABI in this case?


texts: How to execute a function which requires gas using web3 & React?

texts:
I have the call working for a non-gas execution.

This code below does not seem to run. Should I add account in the call?

let addContract = async (inputValue) => {
    var abi=
  [{"constant":true,"inputs":[],"name":"contractWeight","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"jsonInput","type":"string"},{"name":"hashKey","type":"bytes32"}],"name":"addContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"weight","type":"uint256"}],"name":"addWeight","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"contracts","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]

    var web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/'));
    var contractaddress= "0xb316b4bf742818d3fb97586a2f3aea361b240f30";

    var hashVal = web3.utils.sha3(inputValue);
    console.log(hashVal);

    let commodityContract = new web3.eth.Contract(abi, contractaddress);
  //  let newContract =   commodityContract.at(this.state.contractAddress);
  //  this.setState({commodityContract: commodityContract});
    web3.eth.defaultAccount = web3.eth.coinbase;
  //  var testResult = commodityContract.contracts(test1);
    var result='';
    commodityContract.methods.addContract(inputValue,hashVal).call().then(
       (result) => console.log(result)
     );

    console.log(commodityContract);

}


texts:
Im wrting a dapp which holds / manages sensitive data which might need to be encrypted and decrypted and push again into chain.

I know it is not safe to encrypt data in smart contract,which is why Im thinking of off-chain encryption mechanism . I thought to encrypt data using public key and then decrypt using private key . However I found that popular wallet s/w like metamask doesnt allow this.

1.What are the possible ways to acheive this or any other better ways? (I thought managing users eth keys is not so safe)

2.If using custom keys for encryption, Is it ok using a keymanagement tool like Google KMS or Amazon Kms to manage keys and encrypt data?


texts: How can I mock the time for solidity tests?

texts: My contract has an expiration date that I'd like to unit test but I don't know how to go about doing that. If I could mock the time of the contract that would be dope. Google search provided no information though.


texts: How to add specific transaction in block using geth?

texts: How to include own pending transaction in block will be mined? Some mining pools using this for payouts with low gas price to their miners.


texts: etherscan.io showing wrong balance for my Ethereum wallet

texts:
https://etherscan.io/address/0xdfd43138e27b98a73007618997c66ed6e9adb52f

So I almost have zero balance in this wallet (which is on an exchange if that matters), but it shows the balance as 0.43 ether. Is it a problem with etherscan website or I'm missing something?


texts: Is there any documentation to visualize example of the original DAG graph that Ethereum generates?

texts:
Directed Acyclic Graph (DAG) is well explained here. On Vitalik Buterin's Dagger algorithm's link, the image does not show up. I assume it shows the example of 9 level DAG graph.

  In levels 1 through 8, the value of each node depends on three nodes
  in the level above it, and the number of nodes in each level is eight
  times larger than in the previous. In level 9, the value of each node
  depends on 16 of its parents, and the level is only twice as large as
  the previous;

[Q] Is there any documentation to visualize example of the original DAG graph (showing the 9 level and node's connection between each other) that Ethereum generates?

Thank you for your valuable time and help.


texts: Trying to do interaction between 2 contracts. But compilation failure showing should be declared Abstract

texts:
WinCon.sol

EnemyCon.sol

To create interaction, I am creating interface for EnemyCon in WinCon.sol, but Remix is throwing compilation error stating "EnemyCon should be marked abstract". I tried changing keyword Contract to Interface, but then then further it is not calling the function from other code. Please help, let me know what am I missing ?


texts: Is there a Problem with the "<" operator?

texts:
I actually do not like the concept of splitting the code into lots and lots of contracts.

I basically wrote one crowed sale contract that handles tiers. I do not need time limits.

Everything works fine. But If I send 100000000000000000 WEI (which is the max amount you can send in one transaction) after the second time it jumps into if(weiRaised.add(weiAmount) > cap[currentTier]) which makes no  sense because twice 100000000000000000 WEI is exactly the cap[2]. Thus result in if(100000000000000000 + 100000000000000000 > 200000000000000000) which should be FALSE. I'm little confused.

In the end - it does not really matter because it just produces two 0 value transactions. Because overFunded = 0. But anyway. Seems awkward.

In short it looks like (I know it seems long but it's pretty straight forward and easy. I only put in the relevant function. Working code here:

contract Crowdsale{
using SafeMath for uint256;

// The token being sold
Token public token;

// address where funds are collected
address public wallet;

// how many token units a buyer gets per wei in each tier
mapping (uint256 => uint256) public rate;

// max cap in eacht tier
mapping (uint256 => uint256) public cap;

// the current tier we are in
uint256 public currentTier;

// amount of token raised in "wei"
uint256 public tokenRaised  = 0;

// amount of raised money in wei
uint256 public weiRaised    = 0;

event TokenPurchase(address indexed purchaser, address indexed
beneficiary, uint256 value, uint256 amount);

function Crowdsale(address _wallet, IWToken _token) public {
require(_wallet != address(0));
require(_token  != address(0));

/* HERE THE VARIABLES GET INIT */
// set token address
token = _token;
owner = msg.sender;

// set rates
rate[1] = 23000;
rate[2] = 22000;
rate[3] = 21000;
rate[4] = 20000;

// set caps in Wei
cap[1] = 100000000000000000;
cap[2] = 200000000000000000;
cap[3] = 300000000000000000;
cap[4] = 1000000000000000000;

// the current tier
currentTier = 1;

wallet = _wallet;
/* INIT DONE */

}

// token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(!stopped);
require(msg.value <= 100000000000000000);
require(msg.value > 0);

uint256 weiAmount = msg.value;

uint256 tokens;

// in case that the cap is exceeded
if(weiRaised.add(weiAmount) > cap[currentTier]){

  // split the fund
  uint256 overFunded     = weiRaised.add(weiAmount).sub(cap[currentTier]);
  weiAmount              = msg.value.sub(overFunded);

  // update state
  // calculate token amount to be created
  tokens        = weiAmount.mul(rate[currentTier]);
  weiRaised     = weiRaised.add(weiAmount);
  tokenRaised   = tokenRaised.add(tokens);

  // first fraction of token
  token.ICOmint(beneficiary, tokens);
  TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
  forwardFunds(weiAmount);

  // go into next tier
  currentTier = currentTier+1;

  if(currentTier > 4){
    // Refund overspend wei
    msg.sender.transfer(overFunded);

    // stop token sale
    stopped = true;
    } else {
     // fund the remaining
     tokens        = overFunded.mul(rate[currentTier]);
     weiRaised     = weiRaised.add(overFunded);
     tokenRaised   = tokenRaised.add(tokens);

     // second fraction of token
     token.ICOmint(beneficiary, tokens);
     TokenPurchase(msg.sender, beneficiary, overFunded, tokens);
     forwardFunds(overFunded);
   }

   } else {
    // calculate token amount to be created
    tokens        = weiAmount.mul(rate[currentTier]);
    weiRaised     = weiRaised.add(weiAmount);
    tokenRaised   = tokenRaised.add(tokens);

    token.ICOmint(beneficiary, tokens);
    TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
    forwardFunds(msg.value);
  }
}

function forwardFunds(uint256 _amount) internal {
  wallet.transfer(_amount);
}


texts: How to run smart contract using go-ethereum source code?

texts:
mycontract.sol

  pragma solidity ^0.5.0;

  contract HelloWorld {

  uint256 counter = 100;

  function add() public {
    counter++;
  }

  function subtract() public {
   counter--;
  }
  }

I used solcjs to compile a contract and get the binary of the contract in hex:

  solcjs --bin mycontract.sol

then I put the hex value in the

  /go-ethereum/core/vm/runtime/run_example_test.go/ExampleExecute()

function as the code parameter of runtime.Execute().
Then I run

  run_example_test.go

But it return an array of number:

So I think that's how to run smart contract using geth source code but what if I want to run some specific function of the contract ? And how can I get the state(or the return of contract) of the contract ?


texts: When I add web3.eth.defaultAccount = web3.eth.accounts[0] this code under <script> tag in html. I can't see my entire webpage in Mix IDE. Let me know how to resolve this


texts: Transaction Not Showing up, all others Queued..Please help

texts:
The following transaction is not showing up and when I send a 0eth to myself that gets queued:
https://etherscan.io/tx/0x58dd1572721eee70a796dd021b19cd08dbde7f5e5be90caa9c2ae9fe0151a0d9
Please refer to the screenshot of metamask,as you can see there are total 10 pending in queue.How do I fix this? Please help

Update: I checked the nonce of the new transactions, even though I put 481 in there which is of the original tran. but the new is getting incremented, it was 490. Can someone please help me here?


texts: What happens if internet get disconnected while mining ethereum?

texts: Does the mining process starts all over again and I loose all the work my machine has done or does it start from where it get disconnected and do I get the rewards for that?


texts: Get value from multi mapping in solidity

texts:
I have this code:
struct VotesInfo {
    string name;
    uint256 voteCount;
    bool enabled;
    uint256 check;
}

mapping(address => mapping(uint256 => VotesInfo)) private _votelist;

How can I get the info from the mapping if I know only the second mapping key (uint256) and not the address? As I understood foreach is not an option. Also new to solidity.
Thanks!


texts: Raise & return error with message if no key found in mapping

texts:
I am writing a test that should fail because it looks for a key that doesn't exist on a mapping. How can I raise the error with and error message in solidity? this is the test:
  it('Should NOT update a non-existing user', async() => {
      const magicSmartContract = await MagicSmartContract.deployed();
      try {
         await magicSmartContract.update_card_data('667', '', '', '');
      } catch(e) {
         assert(e.message.includes('This card does not exist'));
         return;  // stop execution
      }
      assert(false); // Should have catched an error
   });

But I am not sure how to catch & raise an error with a message in the smart contract, this is the relevant part:
function update_card_data(string memory _card_id,
                        string memory _new_title,
                        string memory _new_text,
                        string memory _new_img_url) public {
    IdeaCard storage updatedCard = IdCardMap[_card_id];  // Here
    if(bytes(_new_title).length>0){
        updatedCard.title = _new_title;
    }
    if(bytes(_new_text).length>0){
        updatedCard.text = _new_text;
    }
    if(bytes(_new_img_url).length>0){
        updatedCard.img_url = _new_img_url;
    }


texts: Web3JS: Error: Invalid JSON RPC response: "" When creating new contract

texts:
I am simplying trying to create a new contract on the testnet. I am using IFURA as a node and here is my code:

var createInvoice = function(){
    unlockAccountsIfNeeded();
    fs.readFile('./ethereum/contracts/invoice.sol', 'utf8', function(err, contractCode) {
        if(err) console.log("error: " + err);
        var contractCompiled = solc.compile(contractCode, 1); // 1 activates the optimiser
        for (var contractName in contractCompiled.contracts) {
            var greeterContract = web3.eth.contract(JSON.parse(contractCompiled.contracts[contractName].interface));
            greeterContract.new({from:wallet, data: contractCompiled.contracts[contractName].bytecode, gas: 1000000}, function(e, contract){
                if(!e) {
                    if(!contract.address) {
                        console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
                    } else {
                        console.log("Contract mined! Address: " + contract.address);
                        console.log(contract);
                    }
                } else {
                    console.log("web3js error: " + e);
                }
            })
        }
    });
};

I keep getting the same error:

web3js error: Error: Invalid JSON RPC response: ""

I am not sure what could cause the error, it seems like my code works but the parameters that I parse to greeterContract.new are not correct but I am not sure which one.

Thanks for the help.


texts: Do all miners in the network actually run a smart contract or just verify it?

texts:
I have seen a couple articles saying that "all the nodes in the Ethereum network run the code for a smart contract". I was curious about rewards for nodes in the network, specially about the matter of "If all nodes execute a smart contract, why does only one get the gas?" - in which I (partly) found the answer here:

If all nodes execute smart contracts, why do only block creators get the gas fee?

The answers do not talk about nodes running the code, but verifying/validating the block. I can see that verifying a block is computationally much cheaper than actually running code (correct me if I'm wrong, but in my understanding this process would be only peer 2 peer upload/download and verifying the hash), which brings me to the question:

Do all miners actually run a smart contract code or just sync to the new data state without actually running the instructions?


texts: How do I set the address that mining rewards are sent? This means that ethminer will send mining rewards to that a address.


texts: Will The DAO tokens withdraw value be 100Dao for 1.5Eth when The DAO funding will be over?

texts:
As many people I sent ether for The DAO tokens when the exchange rate was 1/100. At the end of the funding, we will be able to withdraw our ether. But the final rate on the last days of the funding will be 1.5/100. So when we will withdraw our ether what will be the rate?

As an example, if I sent 1 ether and received 100 dao on the early days, will I withdraw 1.5 ether ? Or if I sent 1.5 eth for 100 Dao on the latest days will I only receive 1 eth ? What will happen with the 0.5 remaining eth?

Thanks.


texts: How to send struct data as function input on Remix or web3 call?

texts:
I've created a function which gets a struct which contains int+struct.
Now when I want to test it, what data should I send for example on Remix:

here's the code, got from another SO question on - How to send an array of structs as arguments

pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;

contract ExchangeContract {
  enum CurrencyType { USD, TWOKEY, BTC, ETH, DAI, USDT, TUSD, EUR, JPY, GBP}

  mapping(uint256 => CurrencyPrice) public priceByCurrencyType;

  struct Price{
    uint price;
    uint decimals;
  }

  struct CurrencyPrice{
    uint currencyInt;
    Price price;
  }

  function updatePrices(CurrencyPrice[] memory _array) public {
    for(uint i=0; i<_array.length; i++){
      priceByCurrencyType[_array[0].currencyInt].price=_array[i].price;
    }
  }
}

Now, I want to interact with that function from Remix - is it possible?


texts: Who controls the value of Ether or any digital currency defined in Ethereum in private network?

texts: Let's say three banks A,B and C build up a private network using ethereum. They will make transaction among them by defining some currency.How the value of their defined currency will be determined.As it is a currency defined by them only who will decide the exchange rate and all with the real market currency like dollar,pound etc...


texts:
Is there a common way for ranking system (4 different ranks) in a smart contract? The ranking of a player depends on his ETH spent. The more ETH spent, the higher the rank. This means a player can downrank at any time (through a purchase of another player). Recalculating after each purchase is too gas intensive I guess. What else can I do to solve this?

My only solution is just changing the rankings of that players, that downranked and upranked. But how shall the players be stored? As map or list? Linked-list does not seem to be correct in here.

EDIT: I think I have mastered it out. Each rank gets a threshold value. If a player makes a transaction and reaches the threshold, he ranks up. Then he has to figure out if some other players have deranked, by just checking the lowest players in each rank. This presupposes: Players must be stored in one rank. There must be 4 ranks (maps) each being a linked list. Why linked lists? because we cannot order the list physically. Then the player starts to check players balance at the bottom of the rank. If that player is still over the threshold, no player has deranked, including the player we have already checked. Otherwise the player above this player has to be checked and so on... Every player that deranks is being deleted in the current rank and being added in a rank below. Then this steps moves on until the last ranks is reached.


texts: Multiple Inheritance - Inheritance Graph Impossible

texts:
I'm trying to build a contract based on the ERC1404 standard outlined here: https://github.com/simple-restricted-token/simple-restricted-token
The contracts allow you to add restrictions on top of tokens and are composable. The examples cover using a single restriction, however i need to use many restriction in my token. The restrictions I am trying to use are: MaxNumShareholdersToken, IndividualOwnershipStakeToken
I have created the following contract, which inherits from both these files:
pragma solidity ^0.4.24;
import "./../mocks/BasicTokenMock.sol";
import "./restrictions/number-of-accounts/MaxNumShareholdersToken.sol";
import "./restrictions/ownership-percentage/IndividualOwnershipStakeToken.sol";

contract MyToken is BasicTokenMock, MaxNumShareholdersToken, IndividualOwnershipStakeToken {
    constructor (
        address initialAccount,
        uint256 initialBalance,
        uint256 maxNumShareholders,
        uint256 globalMaxPercentOwnershipTimesOneThousand
    )
    BasicTokenMock(initialAccount, initialBalance)
    MaxNumShareholdersToken(maxNumShareholders)
    IndividualOwnershipStakeToken(globalMaxPercentOwnershipTimesOneThousand)
    public {

    }
}

However, when compiling i see the following error message:
TypeError: Linearization of inheritance graph impossible

I have followed the inheritance tree and from my understanding, this should work. Here is the inheritance tree for the files in question.

What am I doing wrong?


texts: June 2017: Most widely used and accepted Ethereum development framework on MacOSx?

texts:
For those getting started with Ethereum development, is there any insight to be offered for which framework to use for mac?

There is also this post: Which one is suitable frameworks for Dapp development(Truffle, Embark, Dapple)? . Though it does not have an accepted answer or offer much insight.

Thanks for helping getting us started!


texts: How to retrieve length of array stored in mapping on frontend?

texts:
I have a contract with the following mapping:

mapping (uint16 => uint256[]) public barLengthToBarIndexForSale;

What's the best way to retrieve the length of an array for a given key on the frontend using truffle?

Something like this...

barERC721Inst.barLengthToBarIndexForSale(5).length;

... seems to not work.

Using an additional function in my contract to retrieve the length...

    function getBarLengthToBarIndexForSaleLength(uint16 _length) external view returns (uint) {
    return barLengthToBarIndexForSale[_length].length;
}

...seems also not to work :(

I tried calling it on the frontend like this:

barERC721Inst.barLengthToBarAmtForSale.call(5)

and

barERC721Inst.barLengthToBarAmtForSale(5)

both throw errors.

Any help is appreciated.


texts: Can you make an Ethereum smart contract token mineable by people who want your token?

texts:
If I make an ethereum smart contract - call it simplecoin, can I set it up such that I can allow users of the coin to mine the transactions? Rather than a generic ethereum miner that would charge gas?

Is this possible?


texts: truffle-contract Contract.new() produce an empty contract(no state)

texts:
I am making a new copy of a already deployed contract.
I am using truffle, truffle-contract to do so.
From JS front end

var conf = contract(MyContract)
    conf.setProvider(this.state.web3.currentProvider)
    conf.new(this.state.party1name, this.state.party1regaddress, this.state.party2address, this.state.effdate,
            {from: web3.eth.accounts[0], gas : 3000000})
    .then((instance) => {conf = instance
        console.log(conf.address)
        console.log(conf.get())
    })

The above code deploys a new contract for me, but it seems like ignoring all the parameters I give and the state of my new contract is empty.

When i do the same thing from truffle console, it works fine

MyContract.new("Manish", "Raffles Place", "0x61b755c693d7cf263f969f336be281a564af915d", {from: web3.eth.accounts[0]})

I checked in console I get below log

So I am getting the new contract address but values passed into my constructor are empty.


texts: " app.candidates is not a function" getting these error while caling the function through truffle console with "app.candidate'

texts:
pragma solidity ^0.5.0;

contract Election {
    //Model a Candidate
    struct Candidate {
        uint id;
        string name;
        uint voteCount;
    }

    //Store Candidate
    //Fetch Candidate
    mapping(uint => Candidate) public candidates;
    // Store Candidates Count
    uint public candidatesCount;

    function Elections () public {
        addCandidate("Candidate 1");
        addCandidate("Candidate 2");
    }

    function addCandidate (string memory _name) private {
        candidatesCount ++;
        candidates[candidatesCount] = Candidate(candidatesCount, _name, 0);
    }

}


texts: where to hide the private wallet key in my dapp?

texts:
Hey I'm making my first dapp and I just want to hide my private wallet key outside of the application itself.I've made other apps before, and I know keys can be hidden off the app with FireBaseConfig, but I'm wondering if there is a suggested way that you guys do it seeing as wallet keys are very different then regular ol' API keys.
App is written in dart (flutter) and everything deploys fine when using ganache and truffle. However I have a sinking feeling I don't want my REAL private key in the app when it's production ready
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';
import 'package:web_socket_channel/io.dart';

class ContractLinking extends ChangeNotifier {
  final String _rpcUrl = "http://10.0.2.2:7545";
  final String _wsUrl = "ws://10.0.2.2:7545/";
  final String _privateKey =
      "MYWALLETKEY";

  Web3Client _client;
  String _abiCode;

//...rest of my code..
}


texts: How should I multiply ether by a decimal?

texts:
I'd like to multiply Ether by a decimal (a proportion, e.g. 0.05). I've got:

ufixed proportion; // What type should proportion be?

function functionName() {
  var Ether = msg.value; // (in units of wei)
  var proportionOfEther = Ether * proportion
  ...

My Solidity linter is saying that * is not compatible with uint256 (the Ether) and ufixed128x128 (the proportion).


texts: mapping Struct to bytes32 can't read from map

texts:
I am saving under byte32 key some struct, it is saved, but I really trust it is saved at all.  When try to read, I get 0x0 in all fields.

mapping (bytes32 => Document) documents;
bytes32[] public documentHashMap;

function setDocument(bytes32  _hash, string memory _documentName, bytes32 _documentHash) public {
     Document memory document = documents[_hash];

     document.id = documentCount++;
     document.documentName = _documentName;
     document.documentHash = _documentHash;
     document.sender = msg.sender;

    documentHashMap.push(_hash) -1;
}

function getDocumentByHash(bytes32 _hash) view public returns(uint, string memory, bytes32, address) {
    return (documents[_hash].id, documents[_hash].documentName, documents[_hash].documentHash, documents[_hash].sender);
}

There is something wrong in in set method?


texts:
how to watch events in web3.js when the event is fired from inside the constructor functionof a contract? Eg:

contract A{
   event Invoked(string);
   function A(){
   Invoked("constructor invoked!");
   }
 }

what to write in web3.js layer to get the output of event in the console.


texts: Access the state/variables of Contract A from Contract B

texts:
I would like to change a variable of type enum of a contract A from another contract B. I am getting an error. Is it not possible to do so? The error is in the second line of the below code...

contract cs{
 ....
........
POD pod = POD(mainContract);
pod.state = st;

}


texts: Solidity filling a struct-array containing itself an array

texts:
So, I want to fill an array of a struct residing in an array of another struct:

...

struct Answer
{
    bytes32 name;   // short name (up to 32 bytes)
    uint voteCount; // number of accumulated votes
}

struct Question
{
    bytes32 name; // short name (up to 32 bytes);
    Answer[] answers;
}

Question[] public questions;
...

i want to add a question with an array of answers the following way

function addQuestion(bytes32 _name, bytes32[] _answers) onlyOwner {
    Answer[] memory answersLocal = new Answer[](_answers.length);

    for (uint i = 0; i < _answers.length; i++) {
        answersLocal[i] = Answer({
            name: _answers[i],
            voteCount: 0
        });
    }

    questions.push(Question({
        name: _name,
        answers: answersLocal
    }));
}

the compiler complains:

Copying of type struct Roadshow.Answer memory[] memory to storage not yet supported.

Does anyone have an idea how can i get this done?


texts: Stop listening to / watching a contract (Web3)

texts:
Here is what I am trying to do (Web3 1.0):

Deploy a contract
Wait until Nth confirmation.
Then stop getting updates from the contract.

My code:

  var myContract = new web3.eth.Contract(_abi, senderAddress, options);

  const toDeploy = myContract.deploy({
    data: _bytecode,
    arguments: [100000, "0xD41396Fa287B20311DD389D563539d8578dad23e"]
  });

  toDeploy
    .send({
      gas: 5000000,
      from: myAddress
    })
    .on("confirmation", (confirmationNumber, receipt) => {
       //After several confirmations, stop getting updates
    });

Is there a way to make web3 stop listening to the contract that was deployed?


texts:
I am new to blockchain and smart contract technology.

I want to understand the overall flow on how decentralized marketplace work. Let's say we have a decentralized marketplace built using smart contracts for listing creation, escrow, etc.
Questions:

I assume all the listings are stored on Ethereum blockchain. If so, does that mean anyone who wants to view the listings (clients) need to have Ethereum client running on the machine? Is there a way to not have Ethereum client running on the machine and be able to browse the listings?
What's the difference between building a decentralized marketplace on blockchain vs. P2P approach?

  One approach is using a blockchain directly. These markets will place product listing information directly into a blockchain, allowing buyers to reference the blockchain and purchase from there. Another method is to create a network of nodes that all talk to each other directly and don’t reference a blockchain, similar to BitTorrent. Original article

Using smart contracts to achieve decentralized marketplace, is it blockchain approach or P2P approach?
With P2P approach, does that mean you rely your network to run the node and keep the system up? Or anyone with Ethereum node running can do the same?
How do you achieve "searching" if the listings' data are decentralized stored on the blockchain? I see Augur and OpenBazzar have searching function. How did they achieve this?
If I build API for interacting with smart contracts, does that mean my API is not decentralized because it'll be hosted on some server such as AWS or Azure? Will this API be talking to one of the node we hosted on our own?
How does a web client interact with the marketplace? Web client makes API requests then API interacts with smart contract on the node hosted by me?

Any help is greatly appreciated!


texts: issue encounter when use swapExactTokensForETH

texts:
I try to "swapExactTokensForETH" I know that for this work you need to "approve to the router" so i when i call  uniswap.approve(to, amountIn) it return Error: cannot estimate gas
if someone can explain me how do you proceed when you swap tokens for eth or help me to fix this issue please


texts:
I have been working with solidity and contracts for a while, but a question came to my mind.

Currently, when you want to interact with a contract using javascript (as example), you need to do the folowing:

var code = fs.readFileSync(solidityFile).toString();
// Compile the contract code
var compiledCode = solc.compile(code);
// Generate the ABI
abi = JSON.parse(compiledCode.contracts[':SupplyChainContract'].interface);
contractInstance = new web3.eth.Contract(abi, contractAddress);

This generates a contract instance and you use this instance to call functions of contract and send transactions.

But, why do we need to do this?

Why cannot we just use the contract address and ask it to execute a function with given parameters?
Is it to prevent spam? To force accountUnlock?

Edit: Is it to save state on the node before the state after transaction if validated (or not)?  Forget that, does not seem to make sense.


texts:
My transaction keeps running out of gas when transferring ETH/ERC20 token from my wallet
Please help me with this, I tried 8 times today and it cost me 0.1 ETH to do it, I raised my gas limit to 60000 but it still failed.
Here is the transaction link:
https://etherscan.io/tx/0x564bd06bb555b62dc2b3851448aa02d58ab99fe20f5d790fdb3d322a0000e4b5
Thank you all!


texts: Where are blockchain environmental globals stored?

texts:
Where are contract globals like msg.sender and block.number stored?

It is in memory or storage?


texts: What token standard to use for general purpose cryptocurrency

texts: I know there are ERC20 and ERC223 token standards. Are there any more token standards? What standart is better to use for general purpose cryptocurrency ?


texts: Can I send Ether with Mist without syncing it to the current best block?

texts: Can I safely send Ether after skipping the peer research in Mist?


texts:
I studied EVM implementations and the bytecode sequences used by them. I wondered that there are three opcodes which are recognized by the EVM but actually are invalid opcodes.

B0 PUSH
B1 DUP
B2 SWAP

If I execute the opcode B0 with Geth-EVM i get the following output:

./geth-evm-1.8.0-stable --json --code b0 run
{"pc":0,"op":176,"gas":"0x2540be400","gasCost":"0x0","memory":"0x","memSize":0,"stack":[],"depth":1,"opName":"PUSH","error":"invalid opcode 0xb0"}
{"output":"","gasUsed":"0x2540be400","time":137988,"error":"invalid opcode 0xb0"}
{"output":"","gasUsed":"0x2540be400","time":210042,"error":"invalid opcode 0xb0"}

As one can see, the opcode B0 is recognized and processed as PUSH opcode. At the same time the error field writes invalid opcode 0xb0. The same holds for the other two opcodes. I tested this also with the Parity-EVM implementation. Parity does not know the opcodes and prints directly an error:

./parity-evm --json --code b0
{"pc":0,"op":176,"opName":"","gas":"0xffffffffffffffff","gasCost":"0x0","memory":"0x","stack":[],"storage":{},"depth":1}
{"error":"EVM: Bad instruction b0","gasUsed":"ffffffffffffffff","time":9881}

Why do these opcodes exist and for what reason? Why does the EVM of go-ethereum know the opcodes but not the implementation of Parity?

EDIT:

I also found this const in the go-ethereum source code:

// unofficial opcodes used for parsing
const (
    PUSH OpCode = 0xb0 + iota
    DUP
    SWAP
)

They mention, that they use it for parsing and they are unofficial.


texts:
When executing an ethereum transaction using web3.js how can I be sure that the transaction has been executed successfully? On Rinkeby testnet sometimes I get an error

  Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!

If my transaction can still be mined how can I make sure if the transaction is mined or not after getting an error in web3?


texts:
I start my geth node with the command:
geth --syncmode="light" --cache=4096 --http --http.port 8545 --http.corsdomain "*" --http.addr "0.0.0.0" --http.api "eth,web3,personal" --ws --ws.port 8546 --ws.origin "*" --ws.addr "0.0.0.0" --nat upnp console

And I get the following command prompt output:

I don't know why I have a maximum of 8 peers at time, with an average of 4/5. I tried disabling the machine's firewall and the peer count won't change, so it has nothing to do with that. I have port forwarded the required ports "30303 and 30301".
How can I increase the peer count? Thanks


texts:
I created an account on etherscan, navigate to the API Keys settings in the user panel, and added a key. I go to the API documentation, take any API call, insert my API key, and I get an invalid API key response. Do I need to link my wallet to etherscan, or go through some other verification process? I have tried creating new keys, several API endpoints on ropsten and mainnet, and they all fail with the same Invalid API key response.
If there is some other information I can provide, I would be happy to. The only information I can think of is my API key. I have tried various endpoints, here are two of them.
https://api.etherscan.io/api?module=transaction&action=getstatus&txhash=0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a&apikey=YourApiKeyToken
https://api.etherscan.io/api?module=stats&action=ethsupply&apikey=YourApiKeyToken
The end goal here is to verify a test contract on ropsten. I started looking at this and thought it was the truffle-verify plugin, and commented at this issue -
https://github.com/rkalis/truffle-plugin-verify/issues/16
but now I'm thinking its the etherscan API, or maybe incorrect configuration of my account prior to generating my API key? Any help would be appreciated. Link to my repository is on the issue comment, but I will put it below as well. Issue is seen on most recent commit on upgradeable-karma branch.
https://gitlab.com/shaunrd0/karma/-/tree/upgradeable-karma


texts:
I have a bunch of contracts which deploy just fine.

Deployment of one of the contracts, XBRNetwork takes exactly 5418911 gas - no problems with that.

However, once I add another trivial (public) function to the contract, deployment during CI run for the PR fails:

   Replacing 'XBRNetwork'
   ----------------------

Error:  *** Deployment Failed ***

"XBRNetwork" ran out of gas (using a value you set in your network config or deployment parameters.)
   * Block limit:  0x989680
   * Gas sent:     10000000

    at /home/oberstet/scm/crossbario/xbr-protocol/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.11 (core: 5.1.11)
Node v10.16.0
Makefile:110: recipe for target 'deploy' failed
make: *** [deploy] Error 1

I have set:

--gasLimit=10000000 in ganache command options
gas=10000000 in migrations

What other option do I need? How would I change the PR to get rid of the "out of gas" issue?

Do test, start ganache:

docker-compose up --force-recreate ganache

and deploy

truffle migrate --reset --network ganache

UPDATE (solution)

The real reason (see the answer) is: apparently, there is a 24kB size restriction on the deployed bytecode (besides the gas limits).

I have added this helper to our CI:

https://github.com/crossbario/xbr-protocol/blob/6f7384c51d52c4d88bfa88314841baf63fc0b7cf/check-abi-files.py

Result:

WORKS:

(cpy381_3) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ python check-abi-files.py
..
ABI file "abi/XBRNetwork.json           " bytecode= 25547  bytes, deployedBytecode= 23998  bytes
..

FAILS:

(cpy381_3) oberstet@intel-nuci7:~/scm/crossbario/xbr-protocol$ python check-abi-files.py
..
ABI file "abi/XBRNetwork.json           " bytecode= 26344  bytes, deployedBytecode= 24795  bytes   WARNING - maximum deployed contract size of 24kB exceeded
..

And the actual solution consequently: refactoring the contract code into a library. Can be done  .. np .. now that I know this hidden limit;)


texts: Web3js events "fromBlock: 0" doesnt work

texts:
I want to get events from block X.
I have:

quorum-v2.4.0
web3js 1.2.6

And I have my own smart contracts I want to listen for. So I have created listener for allEvents like this:

  const event = contract.events.allEvents({
    fromBlock: 0,
  });

And I also have following snippet of code where I am listening for the new events and also for the previous events. So I am specifying  fromBlock as described in web3js documentation:

  fromBlock - Number|String|BN|BigNumber (optional): The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as "latest",

  event
    .on('data', console.log)
    .on('error', eventError);

When I dont specify fromBlock: 0, it doesnt return anything which is OK. When I set fromBlock to 0 it always return the last block (e.g block 6 - see below) even though  there are more blocks before the block number 6:

Object {address: "0x9d13C6D3aFE1721BEef56B55D303B09E021E27ab", blockNumber: 6, transactionHash: "0x51f254852cc897d6d3e40041b3a3e5dd7ec9a5ebddd771d9…", transactionIndex: 0, blockHash: "0x0eaec149917f0517aa99042875313882aa57831b3d02aaf5…", …}

Based on the documentation I assume it should return all events from block number 0. So I should get events in block 0,1,2,3,4...latest.

Do I understand it correctly?
Do I need to set some configuration? I want to workaround contract.getPastEvents and I want to set fromBlock within the subscription in listener.


texts:
The idea is to have a user call send() with some eth. The contract decides if user won/lost. Winner gets a prize msg.sender.transfer(msg.value + winnings); loser gets nothing.

Unfortunately the contract got hacked:

https://etherscan.io/address/0x419a058dca91d152d36c4c6888aafd3890ce7429

pragma solidity 0.5.11;

contract EtherDie {
    address payable owner;
    uint256 public maxSendPercentage = 5;
    uint256 public prizePercentage = 10;
    uint256 public winPercentage = 60;
    event Winnings(uint256);
    bool locked;

    modifier noReentrancy() {
        require(!locked,"Reentrant call");
        locked = true;
        _;
        locked = false;
    }

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

     function () external payable {
        // donate here
    }

    function send() public payable noReentrancy {
        require(msg.value <= 5 ether && msg.value < address(this).balance * maxSendPercentage / 100, "sending too much");
        if (random() < winPercentage) {
            uint winnings = msg.value * prizePercentage / 100;
            emit Winnings(winnings);
            msg.sender.transfer(msg.value + winnings);
        }
    }

    function withdraw(uint256 _wei) public payable {
        require(owner == msg.sender,  "cannot withdraw");
        owner.transfer(_wei);
    }

    function setPrizePercentage(uint256 _prizePercentage) public {
        require(owner == msg.sender,  "cannot set price percentage");
        prizePercentage = _prizePercentage;
    }

    function setMaxSendPercentage(uint256 _maxSendPercentage) public {
        require(owner == msg.sender,  "cannot set max send percentage");
        maxSendPercentage = _maxSendPercentage;
    }

    function setWinPercentage(uint256 _winPercentage) public {
        require(owner == msg.sender,  "cannot set win percentage");
        winPercentage = _winPercentage;
    }

    function random() private view returns(uint){
        uint source = block.difficulty + now;
        bytes memory source_b = toBytes(source);
        return uint(keccak256(source_b)) % 100;
    }

    function toBytes(uint256 x) private pure returns (bytes memory b) {
        b = new bytes(32);
        assembly { mstore(add(b, 32), x) }
    }
}

If you look at the internal transactions, you can see how the funds got drained. There was a mutex but it didn't seem to work.

Any ideas?


texts: Difference between G_create and G_txcreate

texts:
I am reading the yellow paper https://ethereum.github.io/yellowpaper/paper.pdf

There is a gas cost for account creation: G_create.

And there is a gas cost for account creation after Homestead fork: G_txcreate.

They are both 32000 gas.

The text appears to refer to them interchangeably. In the main text it refers to G_txcreate. But in the gas usage table it refers to G_create.

Did I miss something? And what is the actual amount of gas?


texts: How to sign transaction for calling sendRawTransaction JSON RPC method?

texts:
I have a private ethereum network and a java process with communicates with a ethereum node with JSON RPC.

I need to add a transaction from java process by calling the sendRawTransaction RPC method.

How can I sign the transaction to be passed to a sendRawTransaction call?


texts: go-ethereum POA with clique - issue with add new signers when all old signers are removed

texts:
I have setup a POA network with Clique consensus on azure. Due to some issue all the signer vms got deleted and we have no more signers and only normal geth nodes.

So i tried updating the geth nodes to signers. clique propose doesnt seem to work anyway i try.

Is there any procedure I have to follow in this kind of situation ?

I have 3 nodes which are all geth nodes. And connected. I want to make all 3 of them signers.

Thank you.


texts: ETH smart contract deposit and withdrawal functionality - multiple addresses?

texts:
I have an ERC721 smart contract with basic functionality.
When the user deposits this ERC721 token, I generate for him a new eth address. For example using
account_pass = random_text()
Account.enable_unaudited_hdwallet_features()
account, mnemonic_phrase = Account.create_with_mnemonic(account_pass)
So, for example, I have 10 of my ERC721 tokens on my 10 different addresses.
Now, some user wants to withdraw 25 tokens.

Will this result in 3 transactions meaning I will have to pay transaction fees 3 times by 3 different accounts each?

The second possibility is running the setApprovalForAll function when creating a new deposit address, thus allowing to control ERC721 tokens of deposit account from some my main address. This function, however, requires having some ETHs on my new deposit address.

Or is it possible to send ERC721 tokens from multiple accounts to one account with 1 transaction where the transaction fee payer will be also 1 account?

Or can I configure my Ethereum node (dedicated) to pay the transaction fees for transactions made via my node?

Or should I allow the smart contract owner (me) to send ERC721 tokens from any account to any destination?

How can I implement not so costly deposit and withdrawal functionality?
I would like to pay the transaction fees just from my 1 account.
P.S. I use Python Web3 + eth_account
Smart Contract:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC721, ERC721URIStorage, ERC721Burnable, Ownable {
    constructor() ERC721("MyToken", "MTK") {}

    function safeMint(address to, uint256 tokenId) public onlyOwner {
        _safeMint(to, tokenId);
    }

    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
        super._burn(tokenId);
    }

    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }
}


texts: Is there a way to detect when my contract receive tokens? I don’t own the token contract, I only want to know the address and amount of token sent to my contract.


texts: eth.syncing is false while eth.blockNumber is 0


texts: Connecting to remote Geth client from AWS hosted server via web3 needs fix

texts:
There is a general problem that is affecting most everyone who tries to initialize AWS hosted servers with a remote Geth instance. It would be great to have documentation to address a fix or at least a workaround.

As demonstration, I have a problem connecting to my ec2 hosted Geth node from my AWS Express server with web3. I think a critical breaking point is security groups setup. I've given lax permissions to geth options on startup geth --rpc --rpcapi eth,web3,personal --fast  --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --testnet. This should be ok, assuming only my server IP is whitelisted in the Geth assigned security group. I have no issues testing contract deployment from my Geth client using web3 requests from an Express server on my local machine (my local IP is also whitelisted).

Now, given the assumption that problems connecting to Geth are coming either from the AWS Express server on startup or from Geth instance security rules, here are a list of potential security questions I have that will hopefully lead to a fix.

Specifically regarding ingress rules for the Geth client:

Is TCP with the Express server's public IP and port 8545 sufficient to connect?
Are UDP and TCP on port 30303 from all IPs a necessary requirement? (Other ports like 30304/30301? Some confusion in forums about legacy ports.)
Is ICMP required to be open? (I doubt pinging is necessary to establish an initial connection but I don't know.)
Are NAT options required on Geth startup?
Also, egress rules are completely open.

Regarding an AWS hosted Node/Express server:

Does the instance (or load balancer) have to allow messages from the Geth client? (I've included them in my rules just in case.)
An error that many users see on server spinup begins with these lines of code:

Error log-

{Error: EROFS: read-only file system, open '.node-xmlhttprequest-sync-1'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.writeFileSync (fs.js:1347:33)
at send (/var/task/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:477:10)
at HttpProvider.send (/var/task/node_modules/web3/lib/web3/httpprovider.js:91:13)
...
...}

Perhaps some permissions require modification in the OS.

Here is my standard web3 config:

var Web3 = require('web3');
var web3 = undefined;
var fs = require('fs');

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  // set the provider you want from Web3.providers
  web3 = new Web3(new Web3.providers.HttpProvider("http://xx.xxx.xx.xxx:8545")); //Geth node
}

exports.accounts = web3.eth.accounts;

exports.myContract = web3.eth.contract(JSON.parse(fs.readFileSync('./compiled_contracts/myContract.abi', 'utf8')));
exports.myContractCompiled = "0x" + fs.readFileSync('./compiled_contracts/myContract.bin');

exports.web3 = web3;

I'm hoping someone has some clear insight to share here.


texts: "null" function name decoded from ethereum transaction, which function I executed on earth

texts:
question
hi, I got a ethereum tx decode like this

I don't know why there's a function named "null", I look at smart contract, no function name is "null".
so I am confused, which function I have executed?
tx & contract detail
transaction : https://etherscan.io/tx/0x13389268ed1cae395a94cc111528ef8e5b929221af4ecc2a0c7e977dd7dbc38d
smart contract: https://etherscan.io/address/0x3e66b66fd1d0b02fda6c811da9e0547970db2f21#code


texts:
So I want to test this Solidity code using Typescript but faced with a type conversion issue.

uint16 base;

function addNumberToBase(uint16 number_) {
    // This number must be between 1 ~ 5
    require(number_ < 1 && number_ >= 5, "This number must be between 1 ~ 5");
    base += number_;
}

And here is the TS testing code, I tried here many types but didn't work.
it("Should add a number between 1 ~ 5 to base", async () => {
     const number_ : Number = 4;
     await contract.addNumberToBase(number_);

     // But here getting this error:
     // Error: VM Exception while processing transaction: revert This number must be between 1~5
});

The same with using types Uint16Array and BigNumberish.
My suggestion is that's because of an issue in converting between types in both languages. So, please are there any useful libraries for converting uint16?
Thanks.


texts: How to pop from (decrease the length of) a memory array in Solidity

texts:
I have a function that gets an address array from another contract, conditionally deletes the msg.sender from the array, then saves the new array back to that contract.

Because the array backerList is in memory, i can't do backerList.length--;

But I cannot declare backerList as a storage array because memory array can't be converted to a storage one.

I am stuck here, what should I do?

 address[] memory backerList = syndicate.getBackerList();

 if(syndicate.individualTotalBacking(msg.sender) == 0){

        uint index;

        for(uint i=0; i<backerList.length; i++){
            if (backerList[i] == msg.sender){
                index = i;
            }

        //shifting array

            for(uint k=index; k<backerList.length-1; k++){
                backerList[k]=backerList[k+1];
            }

        }

        backerList.length--;
        syndicate.setBackerList(backerList);
    } else {}


texts: How is minimum required account balance calculated?

texts:
Here's a transaction:

0xf8900b8504a817c800830f424094394b88b676f289224bdc332f361be399ea064bd587060a24181e4000a4a358c2fa841a3c2efd182abc0a149b32a493044d84aa6c0d4ebe34e0f1b9e96403db65da2aa0a2b453bcade87566a292462a6e4de82615508de982936799642dba9e959b1ac3a0364eee7341bf901182e59c1b7492b03e55163703435fc8a1f199fcf30d50abca

Here's the result of parsing it with helpeth library using parseTx method:

Signed by: 0x4f33d4895b0584f31024132468bd85beb4249ac5
Nonce: 0x0b
To: 0x394b88b676f289224bdc332f361be399ea064bd5
Value: 1700000000000000 (0.0017 ETH)
Data: 0xa358c2fa841a3c2efd182abc0a149b32a493044d84aa6c0d4ebe34e0f1b9e96403db65da
Gas limit: 1000000
Gas price: 20000000000 (20 Gwei)
Potential total transaction cost: 0.02 ETH
Minimum required account balance: 0.0217 ETH

When I send this transaction to the network I pay 0.0027 ETH (almost ten times smaller than Minimum required account balance).

The transaction cost is calculated with this formula:

value + gasPrice * gas = txCost

In my case its: 0.0017 + 0,00000002 * 50 000 = 0.0027

How does Minimum required account balance calculated?

And why there's need for it at all? It's very confusing when want to send a tx and have enough balance, but get an error unsufficient funds when balance is lower than the Minimum required account balance


texts: Do ERC20-type tokens make a 51% attack more profitable?

texts:
A successful 51% attack (PoW or PoS) would allow the attacker to double spend any token, not just ether, so the greatest possible payoff is equal to the value of all ERC20-type tokens plus all ether. But since the only token used for mining/staking is ether, the value of the reward for doing so isn't affected by the value of the ERC20-type tokens. So if the price of ether goes up, the value of mining/staking rewards will too, but the same isn't true for ERC20-type tokens. It seems like the more valuable ERC20-type tokens are relative to ether, the more profitable an attack is and the less stable ethereum is.

Am I right about this? And if so, is this is a known issue?


texts: Setting up a private network with one node per VM with TestRPC?

texts:
I wonder if I can set up a private test network with 4 nodes (4 Linux VMs) on the same network with testRPC.

TestRPC is really easy to use (create a blockchain, no need of mining etc etc) when developping smart contracts.

I know that geth is capable of creating a private test network with multiple nodes, but wonder if testRPC is also capable of achieving this task.

Thanks in advance,


texts: Problem migrating contract using truffle. Unknow account message

texts:
I am trying to migrate a contract using truffle but I get a "Unknown account" message eventhough I tried various ways to unlock the account beforehand. Am I missing something? Any help really appreciated.

Here is the error log :

truffle migrate —network rinkeby
Compiling ./contracts/first.sol...
Writing artifacts to ./build/contracts

Using network 'rinkeby'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: unknown account
    at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/cli.bundled.js:37312:16)
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:220420:36
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:72910:11
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:204149:9
    at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/cli.bundled.js:205574:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/cli.bundled.js:73069:18)
    at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/cli.bundled.js:73359:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/cli.bundled.js:73514:12)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/build/cli.bundled.js:73474:24)
    at emitNone (events.js:91:20)


texts: What is the non-transactional behavior of the EVM?

texts:
This question is about Solidity code that reads the state of a deployed contract on a Geth node using web3.js. When I call claimsProcessed() with a different account than admin, I expected it to throw my "Security Violation".

Instead it returns a fancy value ...

3963877391197344453575983046348115674221700746820753546331534351508065746944

I have ...

uint256 private claimCount; // == 1
address admin = 0x123..ce;

and ...

function claimsProcessed() public adminOnly view returns (uint256)
{
    return claimCount;
}

modifier adminOnly() {
    require (
        msg.sender == admin, "Security Violation - You are not an admin"
    );
    _;
}

What can I do to get a "Security Violation" when the read operation is performed by another account than the admins.


texts: Why the same contract has more bytecode size in solidity 0.5 in compare to 0.4.24?

texts: My earlier contract was compatible with solc@0.4.24. Now I am upgrading my contract to make it compatible with solidity 0.5 but it leads to an increase in bytecode size. AFAICT There is no change in the EVM. solidity 0.5 is the only high-level change. It shouldn't affect the EVM but increase in the bytecode size is questionable.


texts: Uint256 division in vyper (and solidity)

texts:
Floating point division is not supported in solidity as mentioned here: How can I perform float type division in solidity?

I want to divide two uint256 numbers and save them as a decimal, retaining 10 decimal places of accuracy. Would I need to multiply these numbers by 10000000000 first and then divide them by each other, then save the decimal and then divide the decimal by 10000000000?


texts:
We are developing a decentralized application on Ethereum that manages surveys.

We have a main smart-contract that contains survey information (i.e. hashes) as well as 2 main functions: one to create a new survey and one to participate to the survey.

This contract is becoming too large (+- 250 lines) so we would like to split it into several smaller contracts.

The challenge is that our functions all need to access the data that is stored in the main contract so we can't move functions to another contract (it would no longer have access to the data).

So we thought using a proxy mechanism. A proxy contract would store data and transfer calls to functions by delegate calls to different contracts.

Before we start implementing this architecture, we would like to know if:

1- Is this architecture/design correct?

2- What other options are available to us?

Thank you for your help


texts: What rights/value do ICO tokens give their holders?

texts:
I've done a bit of research on ICOs, but it seems the most important information is always missing: what do ICO token holders get for their tokens? How can those tokens be used to derive value from investing in them?

I understand every ICO is different, and I'm not looking for any kind of exhaustive list. But a few examples would be nice.

If holding an ICO token only gives you the right to sell it later to a willing buyer, then the fundamentals of the token are all that matters - not the health of the company doing the ICO. In this case, I would hardly even call it an ICO. It would just be another alt coin.

If holding an ICO token is to have any value related to the issuing company, it needs to have some kind of value that grows if the health of the company improves. An obvious example would be if an ICO token were equal to X% of the company's equity, or if it were equal to X shares in a situation with VERY well defined share inflation parameters (ie policy around issuing new equity). But my understanding is that tying an ICO token to a company's equity isn't legal in most cases (unless you're doing a plain old IPO).

So do ICO tokens usually give the holder a right to demand something of value (and importantly, something who's value grows as the issuing company grows in value or some related success metric)?


texts: Is it possible to have a signature as the mapping key type?

texts:
If I have someone's signature and I want to use it in a mapping, is there a way to have it serve as the key in that mapping?

Would I need to use mapping (string => uint), or mapping (bytes32 => uint), or would I first need to hash the signature?


texts:
If I want to change the discovery port from 30303 to XXXX I do "parity -port XXXX".  But what if I want to change 30304/udp?

For example, maybe I have many computers NAT behind a firewall.  I can do port forwarding for the discovery port 30303, XXXX, etc. and invoke those individually on the command line.  But how do I do this with 30304/udp?


texts:
web3.eth.estimateGas is always calculating low gas for the transaction. Here is a reference to a trasaction in ropsten.
https://ropsten.etherscan.io/tx/0xd5bead5b576b2f4e4cbe83e4acf20d701740b05fdaf3f2749e0c1973ea4c7d6c

I used the data feild and contract address to calculate the gas. I got => 21464. But it actaully required 47032.
This is one example but I have the same problem for other transactions as well.

web3.eth.estimateGas({
    to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe",
    data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"
})
.then(console.log);


texts: GoEthereum getting public key from private key hex formatting


texts: Returning ERC20 tokens accidentally sent to the DAI contract

texts:
I don’t know if it’s the right place for it, but I’m taking a chance. Despite several years of daily use of ERC20 tokens, I unfortunately managed to make a mistake and send some ERC20 tokens to the DAI contract instead on another wallet. Here is the DAI contract address : 0x6B175474E89094C44Da98b954EedeAC495271d0F
Could you please tell me if there is a way to get those ERC20 tokens back? Maybe using the read & write features of Etherscan?
I am very sorry for the inconvenience and appreciate any help.
Best,


texts: Getting a contract by address only (without ABI definition)

texts:
Is it possible to get a contract only by its address without the ABI definition?

I'm experimenting with ethereum in a private network through the web3.js client console.

The problem is that any error in node will cause the client to crash. I was careful enough to store the contract address, but not the ABI definition.

Is there a good approach for solving this problem?


texts: In Browser-Solidity, I want to see the messages sent by a contract

texts:
There is good information on this site about writing and ad-hoc testing a contract in Browser-Solidity. When I use the transaction tab to create my contract and invoke its public functions, I want to see what messages were sent by the contract and to which addresses. Where can these messages be inspected?

I have seen

How to quickly test a Solidity function?
Browser Solidity: What does the "Transaction" tab do?


texts: How do I use delegatecall assembly with a storage pointer to a struct

texts:
I am trying to call a library function using assembly and the delegatecall opcode.  The library function accepts two parameters, the state object storage pointer and an address, it returns a single uint.

I can tell if the op fails because the data at in_pos is untouched, however when it does work it always returns zero even if the function being called simply returns a 0x01 value.

state is a struct that is shared by the calling contract and the library, its position is 0

address t = 0xTargetLibraryAddress;
address a = 0xAccount;
bytes32 result;
assembly {
   let in_pos := mload(0x40)
   mstore(in_pos, 0x12345678) //a valid func sig within the library
   mstore(add(in_pos, 0x04), state)
   mstore(add(in_pos, 0x24), a)
   let success := delegatecall(sub(gas, 10000), t, in_pos, 0x44, in_pos, 0x20)
   result := mload(in_pos)
   mstore(0x40, add(in_pos, 0x44))
}

Any suggestions?


texts: ecrecover not giving back the adress of the sender

texts:
I am trying to understand how eliptic curve work and when i try to get the sender of this transaction: https://etherscan.io/tx/0x14a298c1eea89f42285948b7d51eeac2876ca7406c9784b9b90dd3591d156d64 ( spoiler the sender address is: 0x8d900bfa2353548a4631be870f99939575551b60). I follow the answer from this old question: Hash of the transaction VS Transaction Hash or Transaction ID. And the ecrecover function i use is pyethereum.utils.ecrecover_to_pub.

But when i try to recover back the address, i can't get the sender address.

The function i used is:

hash = HexBytes('0xa4060d01d4add248db470b4121616cbe5b2015daf328809000ec9a1d0954d649')
ecrecover_to_pub(hash, 27, 0x067940651530790861714b2e8fd8b080361d1ada048189000c07a66848afde46, 0x69b041db7c29dbcc6becf42017ca7ac086b12bd53ec8ee494596f790fb6a0a69).hex()[-40:]

which the result address is 0xd124db72eff486dad933df8cc5ec97acb26144ae

i think i have set the v, r, s right because i got the v, r, s using web3.eth.getTransaction('0x14a298c1eea89f42285948b7d51eeac2876ca7406c9784b9b90dd3591d156d64').

The v, r, s from the result function are: 37, 0x067940651530790861714b2e8fd8b080361d1ada048189000c07a66848afde46, 0x69b041db7c29dbcc6becf42017ca7ac086b12bd53ec8ee494596f790fb6a0a69


texts: Does Parity db reset delete blocks or fork chain?

texts: Does CLI command db reset delete all blocks after the chosen block to reset to?  If not is there a way to re-establish those blocks?


texts: A promise was created in a handler but was not returned from it

texts: Hey I'm new to javascript promises. I am getting several errors stating a promise is created but not returned. How do you return from a promise?


texts: The same node quickly submitted 2 times the same transaction, will be wrong, why？

texts:
the error is:
java.lang.RuntimeException: Error processing transaction request: known transaction: b323b93e8b3417aef2f1217c8da281ef5d937f9e1e88245207e44a15fed27b54

I fast twice performed the following methods：
demoContract.pledge(message, weiValue).send();


texts: Can I deploy a contract without being fully synced to the Ethereum network?

texts:
So I've had huge problem to get the Ethereum network to sync.
I've tried several times, even on different computers.
Trying to remove the old DB and run "geth --fast cache=1024".
Anyhow, my current sync has stopped a few hundred blocks from the finish line and it just keeps downloading chain structure.

I'd like to deploy a contract and I don't think I can use https://remix.ethereum.org/ since I need to use the Open Zeppelin Framework.
Is it possible to deploy contracts without the network being synced?


texts: Storage Patterns: Transforming multiple mappings -> structs with mapping

texts:
Currently I have quiet a few mappings which I believe overall could be reduced to a struct with internal mappings and one overall mapping, however, I'm not sure how to do this myself and are therefore looking for guidance.

mapping(address => uint256)    public proposedOfferings;
mapping(address => uint256)    public receivedOfferings;
mapping(address => uint256)    public acceptedOfferings;
mapping(address => uint256)    public rejectedOfferings;

How can I re-structure above to below, keeping in mind each mapping consist of two separate uint256 variables (e.g. uint256 amount and uint256 percentageBonus).

struct offerings {
mapping(address=> uint256) proposed;
mapping(address=> uint256) received;
mapping(address=> uint256) accepted;
mapping(address=> uint256) rejected;
}

mapping(address => offerings) offeringData;

also, some information on the related design paradigm would be highly appreciated. thanks!


texts: Why is the ERC721 metadata limited to images?

texts:
Why is the ERC721 metadata JSON Schema limited to images?
If I specify a file other than the image, does it cause an error when issuing the token?
If it can be issued, what will be sacrificed? (e.g., tokens lose their ability to protect files, tokens are less likely to be linked to files, etc.)


texts: How to specify which wallet address to deploy contract with

texts: When deploying with Truffle how do you specify which wallet address to deploy with? I know if you're using web3 you can specify web3.eth.defaultAccount but how would I do this Truffle? I read somewhere to adjust your truffle.js file and add a from but it spits an error for me. How would truffle know which address I'm using to interact with it, e.g. me using MetaMask.


texts: I want to backup my accounts onto a USB or other external device for safe-keeping.  How can I do that?


texts:
I am using the zeppelin-solidity. Where is the setting how many tokens you receive for 1 Ether?

And where can I set my Ether account as the receiver account?

Thanks


texts: how to call web3.isAddress() via JSON-RPC?

texts:
web3.isAddress (and other web3 methods such as toWei) works fine in the geth console, but when called from RPC (or IPC), it always returns

{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"The method is_address does not exist/is not available"}}

web3 is enabled by default, but still i explicitly used --rpcapi web3. This is confirmed by socat

{"jsonrpc":"2.0","id":1,"result":{"admin":"1.0","debug":"1.0","eth":"1.0","miner":"1.0","net":"1.0","personal":"1.0","rpc":"1.0","txpool":"1.0","web3":"1.0"}}

i tried all possible combinations i can think of, such as web3_is_address. still no luck. any one can shed some light on this? Thanks.


texts: Sent ether to Etc instead of Eth on Nano s

texts: Hi I sent Ether to Etc instead of Eth on ledger Nano s, and its not showed up, I've confirmed  it was sent(Ehterscan) i went to Myetherwallet, connected my Nano to search for it, using more address, still no sign of transfer or address used, please help


texts: What’s the point of setting To when use using the create() opcode?

texts:
The to header is normally optional when creating a smart contract… But though reading JSON-RPC documentation, I saw it was possible to set the To field of a transaction creating a smart contract ?

Does the field is ignored in the case of contract creation ? If yes, please quote the source code lines where the recipient is ignored (as an example in a widely used implementation) ? If not what it does since it doesn’t sets contract address ?


texts: How to generate multiple eth-addresses from one private key?

texts:
Is it possible to generate different multiple eth-addresses from one private key?

The goal is to implement a JavaScript service that will allow a user to buy a subscription using cryptocurrency.

From the user perspective, it should appear that:

by pressing a button he will get an eth-deposit address;
by pressing one more time a new eth-address should be displayed to the user.

As an option, I am considering the generation of a new account with public/private key pair for each time a user presses the button and saving the hashed private key into the database. Also, I would need a worker, that will be listening to the network and checking blocks for the transaction to the generated account. But I don't really like saving the private key as well as generating a new key pair...

So I wonder if there is any other way to implement this feature without saving private key into the database and without using third party services?


texts:
Trying to follow the tutorial on Medium, I would like to open the truffle console (Ubuntu 16.04).

I get the following output:

mzh@021-voting $ truffle console
Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/usr/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:116:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpRequestError (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:544:12)
    at ClientRequest.<anonymous> (/usr/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:414:24)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1281:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)
mzh@021-voting $
mzh@021-voting $ npm -version
3.10.10

mzh@021-voting $ truffle -version
Truffle v3.1.1 - a development framework for Ethereum

Usage: truffle <command> [options]

Commands:
  init      Initialize new Ethereum project with example contracts and tests
  compile   Compile contract source files

Can't find any information about problems with the truffle console on the web. Anyone had the same problem?


texts:
I've seen a lot of articles saying that Casper/PoS will be substantially better in terms of energy efficiency but haven't seen any concrete numbers. How much better will it be? 50x (still really bad), 500x (still pretty bad), 5000x (pretty good).

The reason I ask is I'm playing with a new concept I'm calling EfficientChain: Blockchain For Energy Efficiency. Instead of doing useless proof of work calculations, I'm wondering if it's possible to prove consensus through useful energy usage prediction algorithms.

The company I work for has got a relatively rudimentary algo that can predict energy consumption for a given time period based on historical consumption data + meteorology data. I was thinking we could prove consensus based on multiple nodes getting a similar result for the energy usage prediction. (Transaction being a reduction in energy usage).

If proof of stake really will involve negligible energy use (e.g. 10 watt hours per transaction), then maybe we'll scrap that idea and still use Ethereum (plus maybe Golem for doing the calculations). But if PoS is still pretty bad, we'll have to look at alternatives.


texts: architecture to automate sending erc20 tokens from contract to EOA

texts:
Let's say I bought a millions worth of USDC and sent it to a multi-sig wallet.
I'm trying to reward users in my site with USDC right away whenever they accomplished some tasks.
Is it possible to automate this process from the backend using web3.js?
I just want to know if it's a safe thing to do and possible to avoid sending tokens to each user manually whenever they completed tasks.


texts:
My compile.js code:

var wrapper = require('solc/wrapper')
var solc = wrapper(window.Module)
const Compile = (code,name) => {
    return solc.compile(code, 1).contracts[':'+name];
};
export default Compile ;

I am getting below error:

./node_modules/solc/node_modules/require-from-string/index.js
Module not found: Can't resolve 'module' in '/Users/amitchambial/work/contractdeployer/node_modules/solc/node_modules/require-from-string'

How to solve this error?


texts: Verify transfered amount of two transactions from same ERC20 to same Contract

texts:
I making a contract to sell stuff in a decentralized way and want to use following method to transfer founds.

function transferToken(address token, address from, uint256 amount) internal {
    IERC20 token_ = IERC20(token);

    uint256 pBalance = token_.balanceOf(address(this));

    bool transferResult = token_.transferFrom(from, address(this), amount);
    require(transferResult == true, "Unable to transfer");

    uint256 nBalance = token_.balanceOf(address(this));
    require(pBalance.add(amount) == nBalance, "Invalid transfered amount");
}

The thing is that the contract verify if new balance is the previous one plus the last transfer. This works fine, but I have a doubt.

What happen when two calls to this method usign same token are made in the same block?
Each transaction is executed following transaction index?
At time that second one is executed pBalance will be updated with first one?

I hope I was clear

Thanks!


texts: Would someone be able to interact with a contract without the a JSON interface?

texts:
Someone has obtained a contract address and roughly knows what the contract does, but doesn't have the exact JSON interface. Would he in that case be able to interact with the contract (for instance by decompiling the contract opcode)?

Note that this is a hypothetical question.


texts: Is it possible to create a non transferrable ERC721 token? For whatever reason that some tokens I intend not to be transferrable, could I perhaps implement transfer in such a way that it could read a variable, e.g: require that bool transferable = true when attempting to call transfer?


texts: receive ether from address only after another address has sent ether

texts:
I have a two smart contracts. One receives ether(ReceiveEther) and the other sends ether(SendEther).
I have it set so whoever made SendEther can only send to  ReceiveEther if both contract creators are the same.
However, the ReceiveEther contract can receive from anyone.
How do I make it so ReceiveEther can receive from anyone only after SendEther has successfully executed once?

pragma solidity ^0.5.11;

contract ReceiveEther {
    uint256 public count;
    address public creator= msg.sender;
        function () external payable {
            require(count < 2);
                count++;
                   }
        function getBalance() public view returns (uint) {
            return address(this).balance;
    }

}

contract SendEther {
    address public creator= msg.sender;
    uint256 public sendcount;
        function sendViaCall (address payable _to) public payable {
            require(msg.sender == creator);
            (bool sent, bytes memory data) = _to.call.value(msg.value)("");
            require (sent, "failed to send ether");
            require(sendcount < 1);
                 sendcount++;
    }
}

I'm sure i could create another Sending contract that looks at the counter of ReceiveEther and works only if it is >1, but I don't want to deploy an extra contract.
Thank you for any help.

EDIT
My most recent attempt is where i added another counter and a while loop.
The idea is that now there is a button the contract creator must press. While it is pressed once, only he can send to the contract. If he presses it twice, he no longer is the only one who can send to it.
It compiles without error, but I cannot send ether at any point.

pragma solidity ^0.5.11;

contract ReceiveEther {
    uint256 public clicksfromcreatorcount;
    address public creator= msg.sender;
        function increaseifcreatorclicks() external {
            require(msg.sender == creator);
                clicksfromcreatorcount++;
        }
        function () external payable {
            require (clicksfromcreatorcount >=1);
                while (clicksfromcreatorcount==1 ) {
                    require(msg.sender == creator);
                }

        }
        function getBalance() public view returns (uint) {
            return address(this).balance;
        }
}

contract SendEtherFirst {
    address public creator= msg.sender;
        function sendViaCall (address payable _to) public payable {
            require(msg.sender == creator);
            (bool sent, bytes memory data) = _to.call.value(msg.value)("");
            require (sent, "failed to send ether");
        }
}

i get this message from the compiler

transact to SendEtherFirst.sendViaCall errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Reason provided by the contract: "failed to send ether".

Maybe the issue is with the while loop or the extra "require". I'll keep looking into it. I'm using solidity.readthedocs to understand how i should be doing things.


texts: Storing structured data in private blockchain

texts:
The task.

Develop distributed registry on blockchain network that can store public data of the certain objects.

For example:

{
  "id": 123456789012345,
  "title": "Big black box (not more than 100 characters)",
  "description": "not more than 255 characters",
  "serial_number": "SN4567RT12",
  "type": 4,
  "size": 50,
  "date_of_manufacture": 1531230018,
  "owner_local_id": 99856
}

Information could be supplemented in future by data like this:

{
  "id": 123456789012345,
  "arrived_to": "not more than 255 characters",
  "date": 1531230018
}

Initial data and next additionals should formulate common object profile with history of all actions.

Adding new object or supplementing existed object must cost some fee.

I have private network with Clique PoA on few VPS.
I write data into inputData transaction field in JSON. For searching i wrote indexer that collect data from transaction to local mysql db.

Is this normal or there are better ways storing data and manipulate it?

How i can set fee for adding new object, by smart-contract or integrate into transaction algorithm?

Estimation of quantity of objects in production is about 10-50M per year


texts: Doesn't have enough funds to send Tx - TestRPC and Metamask

texts:
I'm testing and creating a smart contract to send some ether to one account using TestRPC, Truffle and Metamask.

I have a page with a button, when i click on the button it fires the event submitEtherWallet

submitEtherToWallet: function() {
    MyWallet.deployed().then(function(instance){

      return instance.sendTransaction({from: account, to: instance.address, value: web3.toWei(5, 'ether')});

    }).then(function(result) {
      App.basicInfoUpdate();
    });
  },

The method aparently is working well, because metamask open a popup to confirm the transacation.

After click to submit the transaction:


texts: general mathematical description of Pow algorithms

texts:
Is it possible to consider a chain of blocks as an acyclic graph,
where to add the next block (or node, if we are thinking about the blockchain as a graph), it is necessary to solve a computationally difficult problem, such as:

Find x, such that:

H(x) ≤ y, where y is a dynamically calculated target.

For Bitcoin, there seems to be such a formula that is suitable:

SHA256(SHA256(Н(block contents || nonce)) < targethash,

with various values of nonce chosen until one is found that satisfies the above condition.

For Ethereum, from the yellow paper, we have:

and what about other algorithms of PoW? Can they also be classified under such a description?

Sorry for my English. I hope my question will be clear. It will be great if you correct my mistakes


texts: How do you hard-fork a Clique PoA chain to use new validators?

texts:
Imagine you've got a running PoA chain using Clique PoA with Geth. If everything is running normally, you can propose additions and removals of validators and the existing validators will vote on the changes. However, let's suppose the majority of the existing validators is misbehaving and will not cooperate with the validator change you want, but people using the chain are agreed on a last good block and prepared to carry on with the existing state, but using new validators.
It appears that if you were running Aura with Parity, you could change your genesis.json to add the new validators from a particular block:
https://openethereum.github.io/Validator-Set.html#multi-set
This will obviously appear invalid to anyone who hasn't upgraded their genesis.json as of that block, but let's assume that's OK.
Can you do something similar with Geth and Clique? Alternatively, is there a way to bootstrap a new chain with a fresh genesis.json, but import the state from the previous chain as the initial state for the new chain?


texts: Transferring tokens to contract B based on contract A's balances mapping

texts: Is it possible to snapshot the 'balances' mapping from an old contract ? and give them free new tokens based on the amount in the mapping


texts: Cannot send funds to a smart contract using web3j

texts:
I'm trying to send funds to a smart contract using the following code, however, the balance is always 0.

TransactionReceipt transactionReceipt = Transfer.sendFunds(
            web3j, credentials, recipient,
            amount, Convert.Unit.WEI)
            .sendAsync().get();
EthGetBalance contractGetBalance = web3j.ethGetBalance(recipient, DefaultBlockParameterName.LATEST)
              .sendAsync().get();
    BigInteger contractBalance = contractGetBalance.getBalance();

Why doesn't it go through? The smart contract code is:

pragma solidity ^0.4.7;

contract ReceiveContract {
  address public owner;

  function ReceiveContract() public {
    owner = msg.sender;
  }

  function () payable public {
    owner.transfer(msg.value);
  }

}


texts:
I'm building an analytics app that tracks transactions on Ethereum and wondering how to get the most accurate timestamp for each transaction. Using the web3.js library I'm able to see the following metadata, but no actual timestamp related to the transactions.
{
  blockHash: '0xab8f0061300d73524ccdccc3107765e5d8d43c842d55a5ca5ffcfe0105e5f8df',
  blockNumber: 10953453,
  from: '0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE',
  gas: 21000,
  gasPrice: '101000000000',
  hash: '0xf54f84224c76caa5fc34c54ba311469ae0449795933cd3ae2de422a87b0c2707',
  input: '0x',
  nonce: 5327011,
  r: '0xaaadd560f9e747e97cd0362a218ecebf15503371672db9ee0f7364bceb4db67b',
  s: '0x5ac12941aa048b7bf3ff3b4addaf205d23b5a721abd034fc9cd92f57b314a08d',
  to: '0x9B7C174e8970BAb168EbeBde1cf89Edf7066745C',
  transactionIndex: 121,
  v: '0x26',
  value: '735810720000000000'
}

What is the best way to get accurate timestamps for each transaction?


texts: When did the Ethereum "free memory pointer" change? (6060... -> 6080...)

texts:
I have been digging a bit deeper into the Ethereum bytecode with the specific goal to do contract verification from the source code.

I noticed, while doing some tests, that the initial bytes of the Ethereum contract has changed somewhere between 0.4.21 and 0.4.22.

Normally, a contract would always start with:

6060604052

  PUSH1 0x60 PUSH1 0x40 MSTORE

But starting at 0.4.22 and onward, they seem to start with:

6080604052

  PUSH1 0x80 PUSH1 0x40 MSTORE

What is the significance of this change, and where can I find documentation about this change?


texts: Deleting vs. Assigning to Default Values

texts:
If I have a struct with many customer accounts:

bytes32[] public customerID;
mapping(bytes32 => CustomerAccounts) public customerAccounts;

struct CustomerAccounts{
   address customer;
   uint balance;
}

To delete a customer account in the struct, is it better to assign to a set of default values, like this:

CustomerAccounts memory blank;
customerAccounts[customerID] = blank;

or to use delete, as in this:

delete customerAccounts[customerID];

Or does not not really matter?

While the difference in gas is small, < 1000, I suspect in the former case, it may be still there in some ghostly form that could cause problems.


texts: Problem with deploying a collectible with brownie

texts:
I tried to deploy a collectible with brownie.
When I typed "brownie run scripts/simple_collectible/deploy_simple.py" the terminal simply told me, that there was a file missing.
Here is a pastebin to my errorcode: https://pastebin.com/KLMcX3GW
Can somebody help me with that problem?


texts: Unable to deploy smart contract on private blockchain

texts:
I'm trying to setup a private blockchain and deploy some contracts to it. I have the blockchain running but I am running into issues when I'm trying to deploy a contract to it.
This is my genesis block:
{
   "config": {
      "chainId": 1994,
      "homesteadBlock": 0,
      "eip150Block": 0,
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0
   },
   "difficulty": "1",
   "gasLimit": "900000000",
   "alloc": {
      "0xE9cA452f53C9541eDf0461A4160D348d6953C230": {
          "balance": "9999999999999999"
      }
   }
}

And I'm running it with this:
./geth/build/bin/geth --datadir ./geth/data --networkid 1994 --rpc --rpcport 8543 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" --allow-insecure-unlock --unlock "0xe9ca452f53c9541edf0461a4160d348d6953c230" console 2>>eth_log.log

I am trying to deploy the following smart contract:
pragma solidity >=0.5.16;
contract helloWorld {
    function render() public pure returns (string memory) {
        return 'Hello World!';
    }
}

However truffle is giving me the following error when I do:
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0xbd2e3abaf89fe79f3942270847bb981c0f3bb3c0113a758a41baf42d9dfa855f
   > Blocks: 0            Seconds: 0
   > contract address:    0x63BaB74Bf18c73c3E38D85fc3c04CCd53d2C5AE0
   > block number:        489
   > block timestamp:     1615140207
   > account:             0xE9cA452f53C9541eDf0461A4160D348d6953C230
   > balance:             1467.009999999999999999
   > gas used:            221555 (0x36173)
   > gas price:           0.000000001 gwei
   > value sent:          0 ETH
   > total cost:          0.000000000000221555 ETH

   ⠴ Saving migration to chain.
Transaction: 0x530d80bd2fff3265cdbc94d5bf6cf41d5c937e4be4b84789a4110224cf8babf2 exited with an error (status 0) after consuming all gas.
     Please check that the transaction:
     - satisfies all conditions set by Solidity `assert` statements.
     - has enough gas to execute the full transaction.
     - does not trigger an invalid opcode by other means (ex: accessing an array out of bounds).
Truffle v5.2.3 (core: 5.2.3)
Node v10.19.0

I'm obviously missing something but I can't spot it. Can someone let me know how to get this contract deployed? Thanks
EDIT: It seems to be happening during the "Saving migration to chain" of the 1_initial_migration.js file. These are my settings of my truffle config file:
development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
      from: "0x....",
    },


texts: Single gpu mining on ethpool.org: payback questions

texts:
It has been some 8 hours since I started mining with an RX480. Nothing fancy, just a rig used by me and not used the entire time. Its hashing power is around 24-25 Mh/s.

Partially confused with the "next block estimate" of around 7 years (as provided in http://ethpool.org/miners/myaddress) I am wondering if (please, don't laugh) that is how much it will take for me to mine my first reward. I understand that ethpool uses a special solo mining. I do not mind waiting for some time, but would you perhaps:

a) have an estimate of what is there to expect with this time of processing speed working. That is how much and how often can I expect a payout, especially my first?

b) Would you recommend switching to another mining pool due to my low hashing speed?

Thanks in advance for any info provided.


texts: What happens to miners when proof of stake is rolled out fully phasing proof of work out completely?

texts: What happens to miners when proof of stake is rolled out phasing proof of work out completely?


texts:
I am following the 7nodes example on truffle's website to setup and connect to a quorum network

http://truffleframework.com/tutorials/building-dapps-for-quorum-private-enterprise-blockchains

I was able to get the network running on a virtualbox intance and the network is running. But when I try to truffle migrate and connect to the nodes it says.

Error: No network specified. Cannot determine current network.ild

This is my truffle config file, same as in the tutorial

module.exports = {
networks: {
development: {
   host: "127.0.0.1",
   port: 22000, // was 8545
   network_id: "*", // Match any network id
   gasPrice: 0,
   gas: 4500000
  }
 }
};

Also I am currently running a windows 10 setup. So how do i solve this?


texts: BlockNumber stuck on 0 while a private network node is looking for peers

texts:
I'm extremely new to Blockchain and mining, and I've followed this tutorial to create my first private blockchain. I am stuck when it comes to mining and I'm afraid I'm quite lost.
Afte I've started the miner with miner.start(), the geth console keeps generating the DAG in a loop-but eventually geneates it , and keeps looking for a peer, like this:

I've googled a bit and figured the values of Blocknumber and hashrate are key to knowing what's happening , my blockNumber has been stuck on 0 while hashrate changed after 2 minutes of mining:

Can anyone please help me understand what's going on and how can I fix this?


texts:
Do you guys know an easy Discovery Protocol implementation that is not deprecated and is powerful enough. I've checked some, but all of them are not suitable for my task (reasons below).

Checked implementations:

ethereumjs-devp2p - Awesome nodeJS implementation of devp2p, but unfortunately - no API for Discovery Protocol
pydevp2p - Python module. Deprecated (At least hasn't updated for a long time). Does not have documentation.


texts: missing ether after uninstalling metamask

texts: Lost my ether from Metamask when I uninstalled it and it did not show up when reinstalled...but it is showing on Etherdelta with the no private key error in red. How do I recover it please? I'm leery of fooling around with private keys. Many thanks.


texts:
I have a JSON string, a part of which looks like this:

\"min\":1,\"max\":4,\

I want to make the values 1 and 4 dynamic, by adding the variables min and max, but I'm struggling with the syntax of how to do that. What would be the best way of doing that in Solidity?


texts:
Currently I try to understand signing and validating in Ethereum and Solidity. For this I have found the following tutorial: https://medium.com/@angellopozo/ethereum-signing-and-validating-13a2d7cb0ee3.
What I don't understand is who can call eth_sign via JSON RPC? In my application the geth node will provide the JSON RPC but then everyone, also people who are not the owner of of the account, can sign their messages and afterwards verify this message as far as I understand.
The problem I need so solve is that in my application I want to sign data with a private key and in my Smart Contract I need to verify this data with a public key. How can I solve this issue when everyone can call eth_sign?


texts: How do I get the decimals of an erc20 contract when the decimals variable is not there?

texts:
What is the best practice for doing this?
In the ERC20 standard having a public decimals: uint256 is marked as optional.
But obviously you cannot display a token balance in the UI without having the decimals.
So how should I handle the case where the decimals field is not there? Should I just assume the contract implements 18 decimals?
What is the standard here? Is it safe to say that 95% of contracts implement the decimals variable?


texts: Mist crashing on startup UNCAUGHT EXCEPTION TypeError

texts:
I'm running the Ethereum wallet Mist in Ubuntu but it crashes on start up with this message

[2017-10-01 13:45:59.552] [INFO] EthereumNode - Start node using /home/oscar/.config/Mist/binaries/Geth/unpacked/geth

[2017-10-01 13:45:59.649] [ERROR] main - UNCAUGHT EXCEPTION TypeError: Cannot read property 'message' of null
    at Socket.proc.stdout.on.data (/opt/Mist/resources/app.asar/modules/ethereumNode.js:428:46)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

It was working fine yesterday but now I can't open it at all.


texts:
I have a small private dev network.

There are three (Parity) nodes.  One of them shows two peers.  The other two each show one peer.  One of the nodes showing only one peer is listed in the genesis file.

What could be preventing the two nodes from discovering each other, especially since they each discover the third node?

More specifically: what can I start debugging/reading to find the failure point?

All three nodes have the following ports open:

30303 on tcp and udp
30304 on udp


texts:
I am new at Ethereum and intended to connect to a test chain by c#. my code runs greatly on my old laptop win7, but on newer one Win10 it just waits forever. this is my code. has anyone any idea?

   var web3test = new Web3();
   var isMining = await web3test.Eth.Mining.IsMining.SendRequestAsync();


texts: Why are token purchases on Rinkeby test net showing up on etherscan but the tokens not showing up in Ethereum Wallet?

texts:
The Ethereum Wallet is synced to the network, and it is the most up to date version. But the address that was the beneficiary of the tokens when purchased does not have any tokens in the account on Ethereum Wallet.

The tokens are transferred according to etherscan though and the funds are forwarded to the correct address receiving the funds in the ethereum wallet.

I really have no idea why this is, and can't find any explanation on Github. I appreciate any help on fixing this problem.

Thank you.


texts: How a smart contract works and when is activated?

texts:
I am trying to understand how a smart contracts works and what are the steps from requesting to receiving some amount of coin (let's say ethereum). I have some questions..

When a smart contract is created this is added in a block and send in the network to be checked (what should users check here, because smart contract is not a transaction?)
When a user makes a request to a method exported by the smart contract it creates a transaction and it will be sent to the network for validation, right (so what is the smart contract job if the transaction will be validated in network?).
Smart contract beeing in the blockchain this means every user from network has it. Smart contract is run by every user when a request to a method is done?
We can think of a smart contract like a normal user which has a balance?
A user can access every contract from blockchain?

I am referring to ethereum. Thanks.


texts:
I am having trouble verifying the checksum of the newest Etherum wallet download. On the download site it is not specified which hash algorithm was used to generate the checksum so on my Mac I tried.

openssl sha Ethereum-Wallet-macosx-0-8-3.dmg
openssl sha1 Ethereum-Wallet-macosx-0-8-3.dmg

even

openssl md5 Ethereum-Wallet-macosx-0-8-3.dmg

but none of them generated the checksum of

e915e66a774cd9af320b746bfd907cc9f678d0d39e75643f35488925e177fefa

what am I doing wrong?