texts:
I need to sign an offline transaction in golang. I have the following, which is a slight modification of this answer to a similar question:

import "github.com/ethereum/go-ethereum/core/types"
import "github.com/ethereum/go-ethereum/common"
import "github.com/ethereum/go-ethereum/crypto"

type GethTxn struct {
  To   string     `json:"to"`
  From string     `json:"from"`
  Gas string      `json:"gas"`
  GasPrice string `json:"gasPrice"`
  Value string    `json:"value"`
  Data string     `json:"input"`
}

func SignTxn(from string, _to string, data []byte, nonce uint64, value int64, gas *big.Int, gasPrice *big.Int, privkey *ecdsa.PrivateKey) (*GethTxn, error) {

  var parsed_tx = new(GethTxn)
  var amount = big.NewInt(value)
  var bytesto [20]byte
  _bytesto, _ := hex.DecodeString(_to[2:])
  copy(bytesto[:], _bytesto)
  to := common.Address([20]byte(bytesto))

  signer := types.NewEIP155Signer(nil)
  tx := types.NewTransaction(nonce, to, amount, gas, gasPrice, data)
  signature, _ := crypto.Sign(tx.SigHash(signer).Bytes(), privkey)
  signed_tx, _ := tx.WithSignature(signer, signature)

  json_tx, _ := signed_tx.MarshalJSON()
  _ = json.Unmarshal(json_tx, parsed_tx)
  parsed_tx.From = from
  fmt.Println("data", parsed_tx.Data)
  return parsed_tx, nil
}

What I want is the raw transaction payload, but what I get is incorrect. I believe I want parsed_data.Data, but I'm not sure. What I'm looking for is a Go analog to the following JS function:

var Tx = require('ethereumjs-tx');

var privateKey = new Buffer(pkey, 'hex')
var tx = new Tx(txn);
tx.sign(privateKey);
var serializedTx = tx.serialize().toString('hex')

Where serializedTx is a string (the payload I want).

I'm a Golang noob so I suspect I'm just misusing geth, but any help would be very much appreciated. I have spent quite a long time on this problem.


texts: I'm getting a Parser Error: Expected token Comma got 'Return' return contributions.length - 1; ^

texts:
function contribute()
    public
    inState(State.Fundraising)
    isMinimum()
    iinMultipleOfPrice() payable returns (uint256){

        uint256 amountInWei = msg.value;

        contributions.push(
            Contribution({amount: msg.value, contributor: msg.sender})
            );
        totalRaised += msg.value;
        currentBalance = totalRaised;
        if(fundingMaximumTargetInwei !=0){
            tokenReward.transfer(msg.sender, amountInWei/priceInWei);

        } else {
            tokenReward.mintToken(msg.sender, amountInWei/priceInWei);

        }

        (LogFundingSuccessful(msg.sender, msg.value, totalRaised)

        //Check if funding is completed & pay the beneficiary accordingly

        return contributions.length - 1;
    }


texts: I am wondering what does "Maximum peer count ETH=25 LES=0 total=25" What is this eth=25 ? Les = 0 ?"mean and why shoud we have maximum peer count. When we say peer count does it mean people who are involved in the chain sharing with my pc?


texts: Does CGMiner officially support FPGA Mining?

texts:
I've been toying around with the idea of diving into the world of FPGA mining in the realm of Ethereum Mining. According to this link I found during my research online, CGMiner supports FPGA Mining for Ethereum, but I cannot find any other evidence to say that FPGA mining is supported/possible for mining Ethereum.
My question is simple, does CGMiner officially support FPGA mining for Ethereum? If so, what cards are compatible?
Thanks for viewing!


texts: in which currency does state trie's balance is stored?

texts:
My question is very simple and I couldn't find the answer for it.
There's a state trie in ethereum. Each state trie has address as key and value as an object which has balance as one of the keys.
I am curious what currency does ethereum store in balance ? is it wei, gwei, eth or even gas ?


texts: Is it possible to transfer Ether without a contract, like with Bitcoin?

texts:
I realised I don't know if Ethereum is exactly like bitcoin with an added dimension (smart contracts), or if there are things that Bitcoin can do "natively" that Ethereum can't.

Is it possible to transfer Ether without a contract? And more generally, is everything possible with Bitcoin possible with Ethereum (without using something Bitcoin doesn't have (smart contracts))?


texts: TX doesn't have the correct nonce - Metamask

texts:
I'm trying to call the leafPicked() function in my contract from web3 which launches Metamask as intended. After pressing accept the transaction shows as failed along with the error message pictured below.

What am I doing wrong?

Contract Function:

function leafPicked(uint numPicked) public returns (uint, uint){
    require(numPicked < remaining_leaves);
    uint number_before_picking = remaining_leaves;
    remaining_leaves -= numPicked;
    leafWasPicked(remaining_leaves, numPicked);
    return (remaining_leaves, number_before_picking);
}

Web3 function:

  web3.eth.getAccounts(function(error, accounts) {
    if (error) {
    console.log(error);
    }

    var account = accounts[0];
    console.log(account);

    App.contracts.Plant.deployed().then(function(instance) {
      plantInstance = instance;

      // This function is not executing as intended
      return plantInstance.leafPicked(parseInt(leafNum), {from: account});

    }).then(function(result) {
      console("Result from leaf picking: ", result);
      return App.SetContractValues();
    }).catch(function(err) {
      console.log(err.message);
    });
  });


texts: Is there a euro-ether data-feed to use in smart contracts

texts: I'd like to implement a reliable data feed in a solidity based crowdfunding contract. the goal is to collect a certain amount of ether that equals an euro amount at the end of the funding. Is there a gateway or feed system for ethereum yet?


texts:
If a contract for a erc20 token can not accept eth? Can the tokens blockchain "Value per Token" ever become greater than 0?

Suppose the contract to create the ecr20 token has nothing in place to sell tokens and does not have the ability to accept eth from anyone.

Can the Value per Token that shows up on etherscan.io ever become greater than 0?

If so what would cause the Value per Token (in eth) to change?

Edit: For clarification, also suppose that the tokens have some arbitrary purposefull use like paying for access to a server and they are sold individually for usd via paypal.


texts: Geth export-preimages /import-preimages does what?

texts: What does Geth export-preimages /import-preimages do?


texts: truffle-hdWallet-provider not return correact address when using private key

texts:
I want to access MyEtherWallet account address from truffle-hdwallet-provider.

This is the code.

```

var HDWalletProvider = require("truffle-hdwallet-provider");
var privateKey = process.env.KEY;
var infuraApiKey = process.env.INFURA;

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*"
    },
    mainnet: {
      provider: function () {
        return new HDWalletProvider(
          privateKey,
          "https://mainnet.infura.io/" + infuraApiKey
        );
      },
      network_id: 1,
      gas: 2000000,
      gasPrice: 3000000000 // 3 Gwei
    }
  }
};

```

In process.env.KEY, there are correct private key.
It is correct because I can access my account using this private key.

However, I run truffle console --network mainnet and chek my address web3.eth.getAccounts(function(err, res){console.log(res)}), it returns wrong address.

Why??

The private key is correct, but I can't access another address I don't know.
Why??

Thanks in advance.


texts: How to swap old tokens with new ones on a new Solidity contract and restrict a particular wallet?

texts:
hope you can assist me on this scenario

few months ago a token has been created and dispatched to several wallet. Right now, the developer wants to add some better features for the users.

The users need to send same amount (let's call it 100) tokens to a new contract, where those 100 tokens are swapped for 100 new tokens.

The caveat is that the developer has lost a wallet holding some amount (about 30,000 tokens) of tokens which he would want to exclude from getting the new tokensin case if is found by someone.

Now the question is;

How can a new contract receives X amount of old tokens.
How can the amount sent be checked and send back new tokens of same value?.
How restrict a particular wallet from getting the new tokens

So basically, i'm looking for a way to swap new coins from the old contract and exclude a particular wallet address..

(if you can also add a standard code too)

Thank you for helping me out :-)


texts:
Vitalik explains "Weak Subjectivity" in this blog
here, but it's too difficult to beginners. Can anybody please explain this a bit more easily?


texts: can I monitor contract events in python?

texts:
If I understand correctly, in web3.js the allevents method enables a contract event to be monitored.

is there an equivalent in python ?


texts: Risk assessment - account confidentiality when signing transactions

texts:
When creating cold storage setups, I've seen various users describe running a private Ethereum chain for the purpose of confirming access to their generated accounts.

I'd like to verify access to cold storage accounts I create by signing an offline transaction and pushing it through on a live machine.

What risk am I exposing my offline accounts to, if any, by not testing on a private chain? Does publishing signed transactions degrade the security of my accounts even slightly?


texts:
I am getting this error message while synching my geth node: eth/downloader/downloader.go:278] Synchronisation failed: peer is unknown or unhealthy

Why would a peer be considered 'unhealthy'?
Is there a log file I can check for more information about this error?


texts: Is there a way to approve all future erc20 tokens for a contract?

texts:
I wanted to write a Smart Will contract that basically sends everything in my address to a beneficiary's address if I die.
However I don't want to send everything to the smart contract in advance because I am still alive and want to buy / sell erc20 tokens I find interesting.
The problem is, I can certainly approve all tokens I hold today. However if I buy a new erc20 token tomorrow, this smart contract won't have the approval to send that new token.
So how would I approve all future erc20 tokens? I'm thinking this isn't possible, so I'm wondering what are my alternatives? Is there a way for this to happen?


texts: How to test your smart contract against currently existing ones on mainnet locally using Truffle?

texts:
Background
I am fairly new to smart contracts and am currently experimenting using Ganache and Truffle to test on my local machine.
My goal would be to have the smart contract interacting with other existing smart contracts on the Ethereum Mainnet, for example the UniswapV2Factory.sol, WETH9.sol and others. To test if my methods are working correctly, I also need to deploy those contracts to my local blockchain. This is where I am having trouble.
Problem
I have tried different things:

Create one truffle project and put every contract, library and interface i need in the contracts directory. This gives me trouble compiling the contracts, since some need solidity version 4.xx, 5.xx and 6.xx.

Create a seperate truffle project for each contract 'group' and set the solidity compiler version accordingly. This compiles and migrates fine and I can see all contracts appearing in the Ganache GUI. But when using the Truffle console I can only interact with the contracts from one project at a time.

Question
What is the best approach when trying to test your smart contract against currently existing ones on mainnet locally?


texts: Is it possible to define a default index for directories hosted by swarm?

texts:
I've uploaded my homepage to swarm, using the --recursive flag, i.e.:

0 ✓ user@ursae ~/.src/github.com/5chdn $ swarm --recursive up co/
I0115 11:32:09.046878 upload.go:195] uploading file co/0x61f42a05.asc (3112 bytes) and adding path 0x61f42a05.asc
I0115 11:32:09.050241 upload.go:195] uploading file co/favicon.png (330 bytes) and adding path favicon.png
I0115 11:32:09.050961 upload.go:195] uploading file co/index.htm (3805 bytes) and adding path index.htm
f1a669a425b378bd8034fe0df7fea098c8b932a6037b688764afda1e92a8db1e

Now, going to bzz:/f1a669a425b378bd8034fe0df7fea098c8b932a6037b688764afda1e92a8db1e/ gives me the message:

manifest entry for '' not found

But navigating to ./index.htm works as desired and shows my web site. Even the favicon works.

Is it possible to create that manifest entry somehow to tell swarm to show the index.htm by default?


texts:
I'm trying to do something simple like Hello World that shows on a webpage. I've written a smart contract like this:

pragma solidity ^0.4.18;

contract HelloContract {
    string word = "Hello World!";

    function getWord() constant returns (string) {
        return word;
    }

    function setWord(string newWord) returns (string) {
        word = newWord;
        return word;
    }
}

and this the html:

        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>

        <link rel="stylesheet" type="text/css" href="main.css">

                Name:
                <input id="name" type="text">

                <button id="button">Click!</button>

what I'm trying to do is, users insert their name (setWord) and it'll display "Hello (username)" (getWord) and all of this running on blockchain means there is a txhash and when I click it'll display "Hello (user)" at the data on etherscan.


texts: MyEtherWallet 3.3.7 Withdraw ETH from DAO for ETH function not working

texts:
so I am trying to recover my ETH from DAO using MyEtherWallet 3.3.7, as described in the Ethereum Wiki: https://theethereum.wiki/w/index.php/The_DAO_Refunds#How_Do_I_Withdraw_The_DAO_Refunds_Using_MyEtherWallet.3F.

I downloaded version 3.3.7 of MyEtherWallet, and unlocked my account successfully. However, although it calculates the correct amount of ETC I should receive, it does not calculate the right amount of ETH in the Withdrawal contract and the ExtraBalance contract, as you can see on the screenshot:

It never loads the ExtraBalance tokens and the ETH on the right, and when I try to withdraw my ETH, it says "do you want to trade your XXX DAO for 0 ETH", instead of the correct amount of ETH.

Can someone help me with this problem? I am having a lot of difficulty in withdrawing my ETH from the DAO contract, and any help will be greatly appreciated :)


texts:
i try to deploy a contact using Eris Platform, i followed the tutorial in the documentation  of Eris ( https://monax.io/docs/tutorials/getting-started/index.html?redirect_from_eris=true#fnref:1 )
but when i get to the step of deploying a contract i got this Error:

root@abday-Lenovo-IdeaPad-Z510:~/.eris/apps/library# eris pkgs do --chain library_chain --address $addr --compiler 192.168.99.100:2376
Performing action. This can sometimes take a wee while
Executing Job                                 defaultAddr
Executing Job                                 setStorageBase
Executing Job                                 deployStorageK
failed to send HTTP request Post http://192.168.99.100:2376/compile: malformed HTTP response "\x15\x03\x01\x00\x02\x02\x16"
Error compiling contracts
Post http://192.168.99.100:2376/compile: malformed HTTP response "\x15\x03\x01\x00\x02\x02\x16"

Container interactive-58a4f2a7-fe59-40b3-bc2c-90c1c544364a exited with status 1

192.168.99.100:2376 : this is my docker-machine ip address

this is my contract :

contract Library {
  string storedData;

  function set(string x) {
    storedData = x;
  }

  function get() constant returns (string retVal) {
    return storedData;
  }
}

and this is my epm.yaml file :

jobs:

- name: setStorageBase
  job:
    set:
      val: "Book Title"

- name: deployStorageK
  job:
    deploy:
      contract: library.sol
      wait: true

- name: setStorage
  job:
    call:
      destination: $deployStorageK
      data: set $setStorageBase
      wait: true

- name: queryStorage
  job:
    query-contract:
      destination: $deployStorageK
      data: get

- name: assertStorage
  job:
    assert:
      key: $queryStorage
      relation: eq
      val: $setStorageBase

any idea about this ?
thank you

this is what's i got @Zach , a different error :

root@abday-Lenovo-IdeaPad-Z510:~/.eris/apps/idi# eris pkgs do --chain testchain --address 92B92269AC1E8081B9FD4A4F1F35884B97D8E348 --compiler http://172.17.0.4:9099
Performing action. This can sometimes take a wee while
Executing Job                                 defaultAddr
Executing Job                                 setStorageBase
Executing Job                                 deployStorageK
Executing Job                                 setStorage
ABI Error                                 abi=
                                         data=
                                         dest=
                                       rawErr=Abi doesn't exist for =>  abi

There has been an error in finding or in using your ABI. ABI's are "Application Binary
Interface" and they are what let us know how to talk to smart contracts.

These little json files can be read by a variety of things which need to talk to smart
contracts so they are quite necessary to be able to find and use properly.

The ABIs are saved after the deploy events. So if there was a glitch in the matrix,
we apologize in advance.

The marmot recovery checklist is...
  * ensure your chain is running and you have enough validators online
  * ensure that your contracts successfully deployed
  * if you used imports or have multiple contracts in one file check the instance
    variable in the deploy and the abi variable in the call/query-contract
  * make sure you're calling or querying the right function
  * make sure you're using the correct variables for job results

Container interactive-f048917d-8248-429f-8728-2c393b9425f5 exited with status 1


texts: Where Can Find the Ethereum source code on Proof Of Stake

texts: Looking to find the implementation of Ethereum Proof of Stake Source Code on GitHub.


texts:
I'm trying to test one of my functions in a contract which returns a bool value, and in the process of debugging I tried to retrieve the output using console log and I get the following hash:

{ tx: '0x2e5bf10660a50c89eed50cdcf97c23a51845337858223f4d3d1af2495507f661',
  receipt:
   { transactionHash: '0x2e5bf10660a50c89eed50cdcf97c23a51845337858223f4d3d1af2495507f661',
     transactionIndex: 0,
     blockHash: '0xace406a9b73620b4bf88bf19ba9773dc70f9b32b7e7f9cea4aa4aa9d2018d987',
     blockNumber: 356,
     gasUsed: 21958,
     cumulativeGasUsed: 21958,
     contractAddress: null,
     logs: [] },
  logs: [] }

Please can somebody help me in understanding what does this mean and a probable fix for this?

Thanks


texts: how can i get this metamask thingy when user is logged in?

texts:
Im talking about how i can implement this metamask navbar icon?

I would like to make it look like this when people are logged in with metamask


texts: Transactions from multiple addresses to a single address in Ethereum

texts:
We are currently in the process of developing a payment plugin for merchants to accept crypto payments. We are currently generating a unique order for every order which is placed in the merchant store. We easily implemented BTC, BCH and LTC since they support multiple UTXO transactions.

I went through most of the posts in the forum and noticed that this is not possible in ethereum using JSON RPCs just outside the box. Can someone please guide me if there is an alternate way to implement transactions from multiple addresses to a single address using Ethereum or if there is a better way to deal with merchant based transactions?

Thanks!


texts: Is it worth to use the default value of a member in a struct to save gas?

texts:
Consider the following:

struct Activity {
    string name;
    uint8 durationInDays;
}

Most of my activities have a duration of 1 day. Is it worth to decrement one unit to save gas?

For example:

struct Activity {
    string name;
    uint8 durationInDaysMinusOne;
}
mapping ( uint => Activity) activities;

function storeActivity(uint uid, string name, uint8 durationInDays) {
   Activity storage activity = activities[uid];
   activity.name = name;

   require(durationInDays > 0);

   if(durationInDays > 1) {
      activity.durationInDaysMinusOne = durationInDays - 1;
   }
}

Does that if make sense to save gas?


texts:
I have a smart contract with some members which should get modified on certain events. For simplicity, let's imagine we have a greeter contract.

If I call greeter.greet() in the JavaScript console, it responds with something like Hello World. But what if I want to count the number of greetings and store them inside the contract?

My first try was the following:

contract greeter
{
  string greeting;
  uint calls;

  function greeter ( string _greeting ) public
  {
    greeting = _greeting;
    calls = 0;
  }

  function greet ( ) constant returns ( string )
  {
    calls = calls + 1; // does not work
    return greeting;
  }
}

The calls variable was not updated. My first guess is that I need to somehow create a transaction to pay for the gas. I used web3.js to deploy the contract. Should I use web3 also for calling greet() with a transaction?

Or could I fund the contract account with some Ether to enable the contract to pay its own gas? How to manipulate data in a Solidity smart contract?


texts:
So, I participated in an ICO a while back, and to send the ETH over to the ICO Contract address, I used Jaxx (stupid me).

When I told Jaxx to send the funds over, Jaxx actually and inexplicably created a secondary address in the wallet, and then promptly deleted the private key. I've never seen this behavior from a wallet before, and it's stumped the idiots over at the Jaxx support team, because all I did was hit "send."

So, my ICO Tokens are now stuck in a secondary address that I don't have the private key for, but I'm wondering if there's any way I can unlock it using the mnemonic Jaxx used in the first place, for the original wallet. I have to assume they were derived from the same mnemonic, after all.

Before it's suggested, I've tried importing the mnemonic into MEW, but it doesn't have any way for me to sort through the millions of addresses the mnemonic creates. The address is not in the first hundred-odd pages, and the website crashes after a while, if you keep digging down through the addresses. I really need a way to sort to a specific address.

So really, my question is, is there a way I can open a specific address with a Jaxx mnemonic?

Thanks for any and all suggestions in advance.


texts: Locally submitted transactions to the light node gets lost if the node is restarted

texts:
What happens to the transactions submitted to light node in the following scenarios?
1) Light node does not have a network connection with its peers.I could find that the transactions are submitted successfully to light node but not broadcasted to its peers.
2) Light node is stopped before it can broadcast the transaction submitted.

I could find transactions.rlp file in geth folder for "FULL" nodes. Is this file related to pending transactions somehow? If so, why there is no such file for light client geth and how the transaction queue works for light client? Is it stored internally which is reset on every restarts for a light client?


texts: I read about zkSnarks and it says that it will increase the stability by 30x by conducting the verification off-chain. What does off-chain mean here? Nodes will still have to use their computation power to conduct the verification, right? Does it mean that it will save space by not considering each and every verification step as a transaction to save space? When learning about lightning network it was pretty clear that there is going to be a fixed size pool and users will be able to change their share and finally publish it to the chain when both parties agree. What happens in this case? am confused.


texts: Unable to migrate contracts to Kovan using truffle.js (testrpc and dev chain works though)

texts:
I'm having problems deploying contracts to kovan.  I'm able to deploy to testrpc, as well as the parity dev chain, but the exact same process fails on kovan. The contract hangs at:

Running migration: 1_initial_migration.js
Deploying Migrations...

Then fails with:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
    Error: Contract transaction couldn't be found after 50 blocks

my truffle.js:

// Allows us to use ES6 in our migrations and tests.
require('babel-register')
module.exports = {
    networks: {
        kovan:{
            network_id: '*',
            host:'localhost',
            port:8545,
            from:'MY_KOVAN_CHAIN_ADDRESS'
        },
        development: {
            host: 'localhost',
            port: 8545,
            network_id: '*', // Match any network id
            from:'MY_DEV_CHAIN_ADDRESS'
        }
   }
}

and I'm running:

truffle migrate --network kovan

after connecting parity to the kovan chain with:

parity --geth --chain kovan --force-ui --reseal-min-period 0 --jsonrpc-cors http://localhost

The same commands work with the dev chain (replace kovan with development in the truffle command, and kovan with dev in the parity command)

For reference:

parity --version
Parity
  version Parity/v1.6.8-beta-c396229-20170608/x86_64-linux-gnu/rustc1.17.0
Copyright 2015, 2016, 2017 Parity Technologies (UK) Ltd

truffle --v
Truffle v3.2.5 - a development framework for Ethereum

I've also unlocked the account on the kovan network using truffle console --network kovan (similarly on the development chain), so that isn't the problem.

I can see the transaction needing signed in the parity web UI, and I can sign it, but nothing happens.

Any help appreciated!

Thanks!


texts: No syntax highlight on Windows VisualStudio 2015 with Solidity extension

texts:
I'm trying to set up my smart contract environment with:
* VS Enterprise 2015
* Solidity extension

Everything installs fine but I don't get syntax highlight and I can't deploy contracts (Deployment to http://localhost:8000/ started! User used for deployment: testuser User check failed!)

I've also installed bloc

Any ideas?


texts: How does a real estate property contract work under smart contracts?

texts:
I am relatively new to concept of smart contracts. I am reading Nick Zabo's Smart Contracts: Building Blocks for Digital Markets, under the Smart Property section it is mentioned:

  Smart property might be created by embedding smart contracts in
  physical objects. These embedded protocols would automatically give
  control of the keys for operating the property to the party who
  rightfully owns that property, based on the terms of the contract.

Then  it mentions an example of a car under smart contract. I would like to know - how would it be possible to have a real estate contract implemented with smart contracts?

Suppose we want to release a certain property only if certain conditions are met. Consider the condition as simple as if the money is paid according to the required sum. Does that mean the payment should be made via ETH? And the ownership transfer will be generating a keypair for the new owner and destroying the old one? How does the enforceability of the contract work here?


texts: Is it bad idea to store my passwords on blockchain with a smart contract?

texts:
I want to save my passwords and some other personal data on a ethereum like blockchain. it seems more persistant to me. I may lose my e-mail , my pc may crush and I may lose my usb stick. But nothing will happen to a blockchain.
I will encryp it and put require(msg.sender,myaddress); to even read functions. But still is there a way someone else can retrieve these information as it would be very bad because they could just easily login to my wallets with that info and steal funds.


texts: How does Solidity/the EVM store a uint vs. an int?

texts:
What's the difference, in terms of bit structure, between an int and a uint under the EVM?

For an example, if an int8's value, expressed in binary, was 00010011, what would the uint8 of that be? What would negative 00010011 look like?


texts: Ads Cash coin is really based on Ethereum?

texts:
There is a new crypto currency started last month known as Ads.Cash (https://ads.cash/) with following "About" Section.

"AdsCash is the multifunctional next generation crypto currency for the Adworld based on Ethereum blockchain using cutting edge smart contract feature."

Many people are treating this as another BitCoin and can change their lives, at the same time many are treating it as a scam.

I would like to know whether the Ads.Cash really uses Ethereum contract/blockchain or do Ethereum really know about Ads.Cash (which is using Ethereum name)? Is there any alliance between Ethereum and Ads Cash?

Thanks,
Ram


texts: Error: "Security/No-assign-param": Avoid assigning to function parameters

texts:
I use this function to convert type uint256 to string.But i get error message about "Security/No-assign-param"

function converIntToString(uint number) internal view returns(string){

    if (number == 0)
        return "0";
    uint j = number;
    uint length;
    while (j != 0){
        length++;
        j /= 10;
    }

    bytes memory bstr = new bytes(length);
    uint k = length - 1;
    while (number != 0){
        bstr[k--] = byte(48 + number % 10);
        number /= 10;
    }

    return string(bstr);

}

I am using VSCode and I did not encounter the same problem on Remix IDE

Is there anyone who can help me solve this problem?


texts: Function that adds struct to an array in the blockchain does not execute when called by another function

texts:
I have a problem that's probably very basic, but I cannot seem to figure the issue out

function _CreateBike(uint id, uint generation, string model, string ability, uint8 tier) internal returns(Bike){
    Bike memory bike = Bike(id, generation, 1, tier, model, ability, msg.sender);
    garage.push(bike);
    return bike;
}

I have this function above that creates a struct and pushes it to an array, and it works as intended

function BuyBike(string model, string ability, uint8 tier) public payable costs(basePrice*tier) {
    Bike memory bike = _CreateBike(garage.length, current_generation, model, ability, tier);
    ownedBikes[msg.sender] = [bike.id];
}

however when I run this function which calls on the earlier function, the struct doesn't get added to the array. I assume this has something to do with reference variables and storage in the blockchain vs local memory, but I still cannot figure out how to fix the problem after checking stackoverflow and the solidity docs. Can someone please tell me what's going on?


texts:
I moved on from PoW (which takes an eternity, I don't know why) to a PoA consensus (which is quasi instantaneous since I set the block mining to 1 second). Now everything works really quickly on my private blockchain.

Issue: I get stuck after sending one transaction. In the flow of my prototype I have to wait for the transaction to be mined to move on to doing other stuff (notably, sending other transactions). The issue here is that I get "Signed recently, must wait for others" after sending one transaction...

As I understand, this is a security feature of the consensus algorithm. I'd just like to know if it's possible to have only one signer (at a time) and still get my blocks mined. (I don't really want to take the whole geth source code to edit that paragraph than recompile etc. It seems like overkill. Is there a quick way to hack around this?)

Many thanks :)


texts: How could I get more data about pending transaction?

texts:
How would I be able to get more data about a pending transaction in the mempool? I am interested in getting data about,

Value of transaction
Gas used
Who the transaction is from and where it is going

I have a nodejs server which I have used to subscribe to the mempool, but this alone only returns the transaction hash. I have tried the web3.eth.getTransactionReceipt(txHash) and web3.eth.getTransaction(txHash).
 var subscription = web3.eth
 .subscribe("pendingTransactions", function (error, result) {
 if (!error) console.log(result);
 })
 .on("data", function (transaction) {
 console.log(transaction);
 });

Is it even possible to get more details of a pending transaction? I would like to scan for incoming transactions for my arb bot.


texts: In eth2 validators will be randomly selected. What is the formula for how this random selection works?


texts: Why is my for loop not fetching multiple token data?

texts:
I'm a little bit noob, so bear with me, but I love the blockchain very much and that's why I'm here, so please hear/help me out. I am building a price scanner for Uniswap, so I have this program to check the price of DAI/WETH on Uniswap that runs just fine:
const { ChainId, Fetcher, WETH, Route, Trade, TokenAmount, TradeType, Percent } = require('@uniswap/sdk');
const ethers=require('ethers');
const chainId = ChainId.MAINNET;
const daiAddress = '0x6b175474e89094c44da98b954eedeac495271d0f';

const init = async () => {
    const dai = await Fetcher.fetchTokenData(chainId, daiAddress);
    const weth = WETH[chainId];
    const pair = await Fetcher.fetchPairData(dai, weth);
    const route = new Route([pair], weth);
    const trade = new Trade(route, new TokenAmount(weth, '100000000000000000'), TradeType.EXACT_INPUT);

    console.log(route.midPrice.toSignificant(6));

However, if I want to create a for loop on checking the price of more than one token, I add another token in a for loop, but node.js throws me an error: (node:8368) UnhandledPromiseRejectionWarning: Error: Invariant failed: CHAIN_ID
Here is the code:
const { ChainId, Fetcher, WETH, Route, Trade, TokenAmount, TradeType, Percent } = require('@uniswap/sdk');
 const ethers=require('ethers');
 const chainId = ChainId.MAINNET;
 const daiAddress = '0x6b175474e89094c44da98b954eedeac495271d0f';
 const sushiAddress = '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2';

const init = async () => {
    const dai = await Fetcher.fetchTokenData(chainId, daiAddress);
    const sushi = await Fetcher.fetchTokenData(chainId, sushiAddress)
    tokens = [dai, sushi];
    const weth = WETH[chainId];
    for (token in tokens) {
    const pair = await Fetcher.fetchPairData(token, weth);
    }
    const route = new Route([pair], weth);
    const trade = new Trade(route, new TokenAmount(weth, '100000000000000000'), TradeType.EXACT_INPUT);
    console.log(route.midPrice.toSignificant(6));

How do I create a correct for loop that would check the tokens I type in?
Much love if you can help a n00b out on his path to the glorious web3 matrix <3


texts:
I want to run truffle compile on my AWS Ubuntu 18.4 server. I'm able to compile the same contracts on my local with no compilation errors but when I tried to run truffle compile on AWS ubuntu server it throws Syntax Errors.

Can someone please explain what's happening here? Do you think truffle version can be an issue here?

Local System: Truffle v4.1.14 (core: 4.1.14)

AWS Ubuntu Server: Truffle v5.0.1 (core: 5.0.1)


texts: Can I delete "address" field from the ethereum key file?

texts: I don't like that anyone who reads my encrypted ethereum JSON key file knows my address and balance. Can I delete the "address" field and still be able to import that file into geth and MyEtherWallet?


texts: How to send Ethereum transaction with json RPC

texts:
I want to send transaction to account this is the command to use :

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{parms}],"id":1}'

and this is the params to use :

params: [{
  "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
  "gas": "0x76c0", // 30400,
  "gasPrice": "0x9184e72a000", // 10000000000000
  "value": "0x9184e72a", // 2441406250
  "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]

But I don't understand in which unity are "gas", "gasPrice", and "value"

Before I can send transaction with this command :

eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:web3.toWei(100,'ether'),data:web3.toHex('message')})

How can I do to do the same thing with Ethereum json rpc?


texts: How use payable function with browser solidity?

texts:
How use payable function using interface of browser solidity IDE Remix ?
http://ethereum.github.io/browser-solidity/#version=soljson-v0.4.11+commit.68ef5810.js


texts: How to get smart contract run time bytecode from network without compiling anything?

texts:
Simple question, but I couldn’t find the answer anywhere. How to get the exact bytecode of a smart contract (not creation bytecode) when the source code of contract is available on https://etherscan.io ?

This is for already deployed contracts.


texts: Once I have created my new Crypto Currency, how may miners mine for my currency?

texts:
Will the miners mine my new currency by using the same miner as Ethereum?
And will they need to configure their miner to specially mine my currency? I would be grateful if someone can explain me how this works for me, now I have created my new currency under the Ethereum technology.


texts: Do mining pool or miners decide on which transaction to be included in the next block?

texts:
This question is about mining pools specifically, which is why I don't think it's a duplicate of this question.

I understand that with most Bitcoin mining pools, the mining pool computes the header that miners then add a random nonce to. That header is shared across all miners in a mining pool, as a way to minimize the amount of computation that individual miners have to do.

Is it the same for Ethereum mining pools? Do we even know what strategy each mining pool uses to pick which transactions to include? I assume it considers gas price of transactions, but surely there's got to be more. For instance, it appears that f2pool includes significantly fewer transactions than etermine in their blocks. So surely they don't use the same strategy to include transactions.

Related: is most mining pool software open-source? The best I could find is etherchain's ethpool-core, but that's not the full source code. Or is that mostly proprietary code?


texts: Execute a smart contract with the agreement of both parties

texts:
I am writing a Solidity contract which publishes documents (or, more precisely, stores the documents' hashes) on the Ethereum blockchain. Currently, I have no idea how to write the code so that the contract only executes after both the 2 involved parties have agreed on the document's content.

Digital signature is one solution I have thought of. However, my intent is to not let any single party to publish the document after they have modified its content as they want.

UPDATE / EDIT

Maybe I was complicating the problem. Just store a list of documents (actually their hashes) agreed by one party and another list of documents agreed by both. Each party runs the contract from their address. It only executes if the calling address is of an involved party which has not agreed.

The verification process only needs to deal with the second list.

What is the possible solution to this?


texts: Passing one contract instance as an argument to the constructor of another contract

texts:
I need to use the functions of the ERC20 contract in another contract.

The ERC20 contract is from the openZeppelin contract library. I found the following code on a website:

import "../../node_modules/zeppelin-solidity/contracts/token/ERC20/ERC20.sol";

contract Escrow is Ownable {
    ERC20 public currency;
    address public collectionAddress;

    function Escrow(ERC20 _currency, address _collectionAddress) public {
        currency = _currency;
        collectionAddress = _collectionAddress;
    }
}

In this code, ERC20 instance is passed as an argument to the constructor of Escrow. That means that the ERC20 instance is stored in the Escrow contract's state variable at the time of the deployment of the Escrow contract.

I want to know how to write the deployment code for passing one contract instance as an argument to the constructor of another contract in truffle.

Also, should the ERC20 contract be deployed before the Escrow contract in Truffle or can both the contracts be deployed together?

If so, then what would the deployment script in truffle look like ?


texts:
What should we do if s in the ecdsa signature is greater than n/2? As we all know, in the ECDSA signature of Ethernum, the output s must be smaller than n/2, where s is the signature output and n is the ECC group order. If s>n/2, we have two choices:

Should we just re-choose a k, then re-sign the message to make s
Or just make $v\oplus 1$ in the signature to make r -> (x,-y)?

What Ethernum ECDSA really do?


texts: solc@0.5.15 and web3@1.2.6 Error "Returned values aren't valid, did it run Out of Gas"

texts:
I created a simple contract and try to run it on Remix. It worked fine. However, when I deployed and excuted in a private ethereum, I got the error "Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from"

I tried to update the web3 and solc, but it still got the error.

Contract code

pragma solidity ^0.5.15;
    contract ExternalData {
    string public ETHUSD='7';

    constructor () payable public {
      ETHUSD = '1';
    }
       function getETHUSD () public pure returns (string memory usd) {
            return '7';
       }
}

Compile Code

const solc = require('solc');
const path = require('path');
const fs = require('fs');

const externalData = path.resolve(__dirname, 'contracts', 'ExternalData.sol');
const source = fs.readFileSync(externalData, 'utf8');

const provableAPI = path.resolve(__dirname, 'contracts', 'provableAPI_0.5.sol');
const src_provableAPI = fs.readFileSync(provableAPI, 'utf8');

var input = {
  language: 'Solidity',
  sources: {
    'ExternalData.sol': {
      content: source
    }
  },
  settings: {
    outputSelection: {
      '*': {
        '*': ['*']
      }
    }
  }
};

function findImports(path) {
  if (path === 'provableAPI_0.5.sol')
    return {
      contents:
        src_provableAPI
    };
  else return { error: 'File not found' };
}
var output = JSON.parse(
  solc.compile(JSON.stringify(input), { import: findImports })
);

var output_compiled = {
  interface : output.contracts['ExternalData.sol']['ExternalData'].abi
  , bytecode : output.contracts['ExternalData.sol']['ExternalData'].evm.bytecode.object
};

module.exports = (output_compiled);

Deploy Code

const Web3 = require('web3');
const { interface, bytecode } = require('./compile1');

const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8541"));

const deploy = async () => {
    const accounts = await web3.eth.getAccounts();
    console.log('Attempting to deploy from account', accounts[0]);

    await web3.eth.personal.unlockAccount(accounts[0], '123456');

    let _txHash;
    let _err;

    const result = await new web3.eth.Contract(interface)
    .deploy({ data: '0x' + bytecode})
    .send({ gas: '2000000', from: accounts[0] },  (err, txHash) => {_txHash = txHash; _err = err;});

    var externalData = new web3.eth.Contract(interface, result.options.address);
    var ethusd = await externalData.methods.getETHUSD().call();

    console.log(JSON.stringify(interface));

    console.log('Transaction hashId is ', _txHash);

    console.log('Contract deploy to', result.options.address);
};

deploy();


texts: Web3.js is not installing correctly with commands "npm install web3", npm install web3 -latest" and npm install ethereal/web3.js -save"

texts:
192-168-1-109:~ connor$ npm install web3@^1.0.0
npm ERR! code ETARGET
npm ERR! notarget No matching version found for web3@^1.0.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/connor/.npm/_logs/2018-03-09T07_22_40_901Z-debug.log
192-168-1-109:~ connor$ npm install web3
npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated tar.gz@1.0.7: ⚠  WARNING ⚠ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar

> websocket@1.0.24 install /Users/connor/node_modules/web3-providers-ws/node_modules/websocket
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
  SOLINK_MODULE(target) Release/bufferutil.node
  CXX(target) Release/obj.target/validation/src/validation.o
  SOLINK_MODULE(target) Release/validation.node
npm WARN connor No description
npm WARN connor No repository field.
npm WARN connor No license field.

+ web3@1.0.0-beta.30
updated 1 package and moved 1 package in 28.16s

192-168-1-109:~ connor$ npm update web3
npm WARN connor No description
npm WARN connor No repository field.
npm WARN connor No license field.

+ web3@1.0.0-beta2
removed 282 packages and updated 1 package in 13.048s

192-168-1-109:~ connor$ npm install ethereum/web3.js -save
npm WARN connor No description
npm WARN connor No repository field.
npm WARN connor No license field.

+ web3@0.20.5
added 5 packages from 7 contributors and updated 1 package in 223.995s

I have tried interacting with web3 after every install swell ??


texts: The contract code couldn't be stored, please check your gas amount while deploying contract

texts: I'm trying to deploy 3 contract in 2_deploy_contract (I deploy all 3) but after the first is deployed I get the following error : The contract code couldn't be stored, please check your gas amount.


texts: Who pay gas for multi-sig tx? Is this customizable?

texts:
This is clear that msg.sender is gas payer for general transactions.
But, in case of transaction having multi signatures, who is the actual gas payer?
Please let me know if the following options are available or not.

Every signed EOAs pay gas equally
Only specific EOA signed at last pays gas
Only specific EOA signed at first pays gas

It would be appreciated if you additionally let me know guides or references for available options.


texts: why aave total supply not equal to circulation supply?

texts:
I'm new to the blockchain world. I'm trying hard to understand how tokens are generated and I learned that the tokens are not minable, unlike bitcoin or eth coins. also learned that these tokens only exist inside a contract.

who decides the supply of tokens and when these tokens are generated?

for example, why  aave total supply(16M) not matching the circulating supply (12.6 M). where are the other tokens and how they will be generated https://www.gemini.com/prices/aave

please provide me some knowldge.


texts: Why does my average hashrate dip after 2-3 days?

texts:
I’ve just started to build a rig and using 3070s and 3060s with Windows and Phoenix miner mining at Nanopool.
The first 12 hours has consistent average hasrate that’s in the ballpark of what the cards should be capable of. But after around 2-3 days the average dips by about 15 MH/s per card, anyone know why this is happening? The issue goes away when restarting the miner. Also noticed the cpu workload and temp increases as time passes.


texts: How do merkle and patricia trees co-exist

texts:
I understand how those tree's work separately, but i can't imagine how to put it in one structure.

From ethereum's wiki:

  All substantial quantities of data in Ethereum are stored in a data structure known as the Patricia Merkle tree, a tree structure where each node in the tree is the hash of its children. Each set of key/value pairs maps to a unique root hash, and only a small subset of nodes is needed to prove that a particular key/value combination is in the tree corresponding to a particular root hash.

Also, inspecting this diagram, can't see where each node is a hash of it's childs.

From official specification, can't understand below part. What means <> in current example?

<64 6f> : 'verb'
<64 6f 67> : 'puppy'
<64 6f 67 65> : 'coin'
<68 6f 72 73 65> : 'stallion'
Now, we build such a trie with the following key/value pairs in the
underlying DB:

rootHash: [ <16>, hashA ]
hashA:    [ <>, <>, <>, <>, hashB, <>, <>, <>, hashC, <>, <>, <>, <>, <>, <>, <>, <> ]
hashC:    [ <20 6f 72 73 65>, 'stallion' ]
hashB:    [ <00 6f>, hashD ]
hashD:    [ <>, <>, <>, <>, <>, <>, hashE, <>, <>, <>, <>, <>, <>, <>, <>, <>, 'verb' ]
hashE:    [ <17>, hashF ]
hashF:    [ <>, <>, <>, <>, <>, <>, hashG, <>, <>, <>, <>, <>, <>, <>, <>, <>, 'puppy' ]
hashG:    [ <35>, 'coin' ]

EDIT:
Ok so i understood that hashA empty brackets '<>' is empty slots in branch node.


texts: "No such file or directory" when Executing Test RPC

texts:
I installed testrpc using the following:

npm install -g ethereumjs-testrpc

NPM -v: 5.3.0

NodeJS -v: v8.5.0

Now, whenever I try to initialize a random testnet by running the command:

$ testrpc

I get an error saying:

/usr/bin/env: ‘node\r’: No such file or directory

I'm really not sure what to do and could not find any other examples of this question on the web. If it matters, I'm running Ubuntu 16.04.


texts:
I am writing the contract below to store json in a nested struct in remix:

pragma solidity ^0.5.11;
contract Analytics {
  address lastAddress;
  uint timeStamp;
  string label;
  uint count;
  string id;
  string typeofEntry; // lack of better terminology
  string channel;
  string createdAt;
//   uint totalAmount;
  struct Field {
    string typeOfFunding; // type is a reserved word in solidity https://solidity.readthedocs.io/en/v0.4.21/miscellaneous.html#reserved-keywords
    uint amount;
    string cohort;
    string promotion;
  }
  struct Entry {
    string id;
    string typeofEntry; // lack of better terminology
    string channel;
    Field funding;
    string createdAt;
    uint totalAmount;
  }
  mapping(uint => Entry) public entries;
function updateEntry (string memory _id,
                      string memory _typeOfEntry,
                      string memory _channel,
                      string memory _typeofFunding,
                      uint  _amount,
                      string memory _cohort,
                      string memory _promotion,
                      string memory _createdAt,
                      uint  _totalAmount) public returns
                      (bool sucess)
    {
      entries[id] = id;
      entries[typeofEntry]= _typeOfEntry;
      entries[channel]= _channel;
      entries[funding].typeOfFunding = _typeofFunding;
      entries[funding].amount = _amount;
      entries[funding].cohort = _cohort;
      entries[funding].promotion = _promotion;
      entries[createdAt] = _createdAt;
      entries[totalAmount]= _totalAmount;
      return true;
    }
}

I am however getting a

  Declaration Error: Undeclared Identifier

In the lines below:

  entries[funding].typeOfFunding = _typeofFunding;
      entries[funding].amount = _amount;
      entries[funding].cohort = _cohort;
      entries[funding].promotion = _promotion;

Not sure what the issue is and will appreciate pointers


texts: How were the "dynamically adjusted target" in mining expressed in the Yellow Paper?

texts:
The one validity condition present in the above list that is not found in other systems is the requirement for "proof-of-work". The precise condition is that the double-SHA-256 hash of every block, treated as a 256-bit number, must be less than a dynamically adjusted target, which as of the time of this writing is approximately 2187.

  Ethereum White Paper - §Introduction to Bitcoin and Existing Concepts -
   Mining

How is the dynamically adjusted target expressed in the Yellow Paper?
I mean, what is the mathematical term for it in the Yellow Paper?
Is it related to Hd, the difficulty?


texts: Web3 - how to add WEI and ETH values correctly

texts:
I'm working on an auction feature in my DApp and having problems correctly adding together two WEI values.

The contract stores two important values:
1. A minBidIncrement variable - which I've set to 0.1 ETH, and
2. A highestBidAmount variable - which stores the highest bid anyone has made to date.

Thus, if the last highest bid was say 2.5 ETH, I want to make sure the next allowable bid would be at least that plus the minBidIncrement, meaning it should be:

2.5 ETH + 0.1 ETH which equals 2.6 ETH.

Its pretty straight forward stuff.

So I'm doing this:

    let minNextBid = highestBidAmount + minBidIncrement;

but what I get from that is some crazy huge value which causes my Dapp to freak out and Metamask to give me errors.

Here's what's happening underneath the hood:
-highestBidAmount comes back as 100000000000000000
-minBidIncrement also comes back as 100000000000000000

(both of those are fine cause they're 18 decimal places, which means they're really 0.1 ETH)

So next when I set my minNextBid, I'm basically doing 100000000000000000 + 100000000000000000, but that yields: 100000000000000000100000000000000000

And when I then convert that to ETH, I get this value: 100000000000000000.1

which isn't at all what I was expecting to get. What I was expecting to get was 0.2 ETH, but I get that astronomical value instead.

So what's happening here? What am I doing wrong?
What's the right way to do this?


texts: can a smart contract autonomously hold erc20 tokens or ETH?

texts:
I want to make a simple smart contract, but I don't know if smart contracts are capable of what I desire. Please tell me if they are:

a user can send ETH (or any ERC20 token) to the smart contract address and it will mint some of it's own token and send it back in exchange.
a user can then send in the minted token at any time in the future and the smart contract will return the original assets that were sent in, to the sender.

I was told this couldn't be done because the smart contract would need to sign the transaction, and it can't sign it or else the private key would be viewable. Is this true? this behavior seems like such a simple thing, I'd be surprised if it's impossible for it to do this autonomously. But if so, I just don't understand what a smart contract really is.

Thank you for helping!


texts: Adding a payee to a donation contract. Error: Transaction reverted

texts:
Disclaimer: I'm a noob when it comes to programming altogether let alone smart contracts.

I refactored this code that was written like three years ago so it could work with solidity 0.5.0. I deployed it on Remix's Javascript VM but the addPayee function is not working: transact to Donation.addPayee errored: VM error: revert. Please help thanks :(

Also, I'm not sure that the contract is assigning me (the deployer) as the owner.

contract Donation {

  address public owner;

  struct Payee {
    bool status;
    uint weight;
    uint balance;
  }

  e.
  mapping(address => Payee) public payees;
  mapping (int8 => address) public payeesIndex;

  int8 public payeesIndexSize;

  function Donations() private {
    // Set the address of the contract deployer to be owner.
    owner = msg.sender;
    payees[owner].status = true;
    payees[owner].weight = 10;
    payeesIndex[0] = owner;
    payeesIndexSize = 1;
  }

  // Check if current account calling methods is the owner.
  modifier isOwner() {

      require (msg.sender == owner);
    _;
  }

  // Aggregate all payee weights.
  function getTotalWeight() public view returns (uint) {

    int8 i;
    uint totalWeight = 0;

    for (i=0;i<payeesIndexSize;i++) {
       if (payees[payeesIndex[i]].status == true) {
         totalWeight += payees[payeesIndex[i]].weight;
       }
    }

    return totalWeight;
  }

  // Add a new payee to the contract.
  function addPayee(address _payee, uint _weight) isOwner public returns (bool) {

    payees[_payee].weight = _weight;
    payees[_payee].status = true;
    payeesIndex[payeesIndexSize] = _payee;
    payeesIndexSize++;

}

function getStatus(address _address) public view returns(bool)  {
    return payees[_address].status;
  }


texts: Cryptocurrency payments in Centralized Architecture

texts:
I'm new to cryptocurrency, so not sure if I'm asking the right question on this...

I want to develop a game with traditional centralized client/server architecture, probably java application server, SQL database, and clients could be whatever kind of phone apps.  I know well how to do this.  But then in the game I want to let users make payments to me (the server) in cryptocurrency (ETH), and also me (the server) make payments to users.

Researching this online is confusing as there's so many aspects to the technology, and so many people explaining different things.  I'm not sure what I need to do.  Do I need to run an Ethereum node on my server?  If so, how to do this?  I would have to keep my ETH account or wallet or something on the server to make and receive payments.  What about the client?  Does the client have to be a node, or can it just ask the user to input some key to their cryptocurrency?

I didn't think I needed to make this project distributed like a DAPP, because I "simply" want to make and receive payments, but maybe I'm naive?  Is my architectural vision legitimate?  If so, how best to implement?  And if not, what is a better solution?


texts: How to find bootnode IP Addresses for Ethereum testnet (Ropsten and Rinkeby)?

texts:
I am trying to develop a simple Voting app by following a tutorial on the net. I want to deploy my dapp to the testnet. To do this I am using the bootnodes as mentioned in the tutorial (below), but are there other bootnodes which can be used?

  mahesh@projectblockchain:~$ geth --testnet --syncmode "fast" --rpc --rpcapi db,eth,net,web3,personal --cache=1024  --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303"


texts:
How an EOA, contract address can be achieved?

What is an mechanism for generating these?


texts: How to determine a contract address with a predefined transaction?

texts:
In ERC-820 (https://github.com/ethereum/EIPs/issues/820) a transaction is given which on raw send deploys a contract at a predefined address fro all chains. This deployment contract then deploys the Registry contract at a predefined address.

Now for the questions:

How is this possible? I assume it's because it's a signed transaction and so the address of the deployer is always the same?
If I try to web3.eth.sendRawTransaction('0x...') this, it doesn't work for a private testrpc chain, why?
In general, shouldn't this be best practice for all projects to give the raw transaction to have the same contract address in every chain?


texts: Why does Truffle create contract when tests contains no transactions?

texts:
I tried running tests that were not sending any transactions and ran into two errors that to me make no sens : an authentification error and, when the account has been unlocked, a block gas limit error (Error: Exceeds block gas limit).

This prompted me to look at the transaction that Truffle sends when running tests. The code of the test is the following :

contract('Testing truffle', function(){
    it('does nothing', function(){
        assert(true);
    });
});

Using a local geth node connected to Ethereum testnet, I can see six transactions being sent :

Three of them seems to be contract creation and the others are transactions to the first created contract (0x288fb9423026fa441b85d02028838e7756497c61).

Can someone tell me what that is about ?


texts: Do all transactions show in metamask wallet?

texts: Bare with me I'm new here :) I've been selling art on Rarible but I can't tell if the Eth is going into my account. Because I'm minting nft's I can't keep track of my Eth total. My wallet activity doesn't say received when I sell something so that's where I'm getting confused. My Metamask extension always has errors on the manage extensions page and if I hover the cursor over the eth total on my wallet it always says "Balance may be outdated". Should incoming and outgoing activity show up on my wallet? Is Etherscan the log for Metamask or can a transaction show successful on Etherscan and get blocked because of a Metamask error?


texts: Why does using {value: 1} in a test results in an exception with no text?

texts:
I'm completely new to smart contracts in Etherum. Using Remix I created a small contract that does nothing except require msg.value == 1:

pragma solidity >=0.4.22 <0.7.0;

contract Danny {
    function foo() external payable {
        require(msg.value == 1, "Must send exactly 1");
    }
}

Then I created a test that just calls it and asserts a nicer message if it fails (I'm not sure why, but by default the error shown by the test framework doesn't include the string from the error):

pragma solidity >=0.4.22 <0.7.0;
import "remix_tests.sol";
import "./danny.sol";

contract DannyTest {
    Danny danny;

    function beforeEach() public {
        danny = new Danny();
    }

    function test1() public {
        try danny.foo() {
        } catch Error(string memory reason) {
            Assert.ok(false, string(reason));
        } catch (bytes memory data) {
            Assert.ok(false, string(data));
        }
    }
}

As expected, this test fails with "Must send exactly 1". So, I then tried to send a value of 1 with the test, using the details from "Testing a method involving msg.value":

try danny.foo{value: 1}()

However this fails with an empty error:

I've tried all sorts of combinations all evening, but haven't been able to make this work. The version of the compiler shown in Remix is 0.6.8 (though I'm not sure if the unit testing plugin uses the one selected here of its own).


texts: How to decode an Ethereum transaction input of an 0x transaction

texts:
The input data is very large. I believe there are multiple functions called.

Can I just hash each of the functions in the ABI, get the 6 characters and compare them to the first six characters of the data. Then get the inputs and match them to the next characters in the data. Then just remove the matched characters and start the process all over again to find the next function and parameters?

Do I need to transform the input data at all? I haven't had much success with the mentioned process yet, so I assumed maybe I am missing something there.

Another issue is that the 0x contract has multiple different ABIs. Can I just combine them into one array if there are no conflicting functions names? Or even if I know the functions needed just keep those in a created ABI?

Also I want to do this in PHP, I have found other libraries in JS and python that I can't use for this project but can use for reference. I need some help with these questions to help move me forward.


texts: GAS FEES DIVISION WITH swapAndLiquify Function [Solidity]

texts:
I community, i'm trying to set the gas fees optimization for the delfationnary token im about to launch asap but quick question to be sure. I set the fees at 10% like so
5% for the pool
5% for rewards [3% for the holders / 2% for devexpenses]
I wrote something but im not sure its the right configuration so I need your help all to hell me fix this please. The line of code is this one:
" function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
    // split the contract balance into halves
    uint256 forLiquidity = contractTokenBalance.div(2);
    uint256 devExp = contractTokenBalance.div(4);
    uint256 forRewards = contractTokenBalance.div(4);

    // split the liquidity
    uint256 half = forLiquidity.div(2);
    uint256 otherHalf = forLiquidity.sub(half);

    // capture the contract's current ETH balance.
    // this is so that we can capture exactly the amount of ETH that the
    // swap creates, and not make the liquidity event include any ETH that
    // has been manually sent to the contract
    uint256 initialBalance = address(this).balance;

    // swap tokens for ETH

    swapTokensForEth(half.add(devExp).add(forRewards)); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered

    // how much ETH did we just swap into?
    uint256 Balance = address(this).balance.sub(initialBalance);
    uint256 oneThird = Balance.div(3);
    wallet.transfer(oneThird);

    addLiquidity(otherHalf, oneThird);

    emit SwapAndLiquify(half, oneThird, otherHalf); "

to be sure im right what im trying to do here is to split the 10% taxes into halves, i want one half 5% goes to the pool and I want the other 5% goes to rewards but I want to do a subdivision but here is where I stuck can I do 3% for holders and 2% goes to the dev) I add the function locktheswap, is that function will prevent the holders to have those 3% if the trigger the swapandliquify function by sell the tokens for example?
If you see something I maybe dont see or want to add any additional information or review, comments feel free. Im a newbie in coding and it's hard to find good information.
Thank's a lot y'all


texts: Does Web3.js have the functionality to create new accounts and unlock an account for a period of time for a series of transactions?

texts: I want to create new accounts through my Dapp web interface and unlock a specific account so that transactions can be processed. I didn't see it in the web3.js documentation so wonder if that's on the web3.js roadmap?


texts: calculate the nth root of an arbitrary uint using solidity

texts:
10^(1/8) is 1.33352143. I'm looking for a solidity function that would return 133352143 here given inputs 10 and 8.

I've looked around for something that can do this with no luck.


texts: I develop a dapp with truffle.js and wish to deploy to the live network. I have the Ethereum Wallet already installed (mac osx), and I'm pretty sure it runs on top of geth - am I correct? Anyway, does it act as an RPC server as well? I don't want to install a standalone geth and start moving ether around if I already have a geth running the Ethereum-Wallet. I couldnt find any where in the GUI to config the RPC, nor is it enabled by default (tried to truffle migrate to 127.0.0.1:8545, it says it can't find an RPC server)


texts: Transferring ether balance from contract balance to winner,not working


texts: I want to use crypto-js module in truffle / app.js

texts:
I want to use npm module "crypto-js" in app.js of truffle_project.
But I can't use it.

app.js:

var CryptoJS = require("crypto-js");
// ...

I build app, then I open build/index.html by browser, I get the error on Javascript console of google chrome:

Uncaught Error: Cannot find module 'crypto-js'

I changed to:

var CryptoJS = require("./node_modules/crypto-js");

or:

var CryptoJS = require("../../node_modules/crypto-js");

but I get the same error. I tried absolute path and relative path, I get the error.

How do I do to use crypto-js module in app.js?

P.S.
install command:

# pwd
~/truffle_project
# npm install crypto-js

and the directory structure is default of truffle.


texts: Design of contract that mediates a transaction between a seller and a buyer

texts:
I'm working on designing an application that requires a contract to mediate a transaction between a seller and a buyer.

The buyer will initiate the game by paying the contract, the contract will then take the "goods" from the seller and send them to the buyer, and finally send the money to the seller.

The "goods" in this case are just some data (that is NOT stored on the chain, and is generated off-chain by the seller.)

My question then is, how do I go from this to a working solidity contract?

My current design (my knowledge of solidity is very limited):

There could be a contract function say i_need_to_buy() that the user will call thereby paying some gas etc.
The contract will emit an event seller_send_goods_now() sending the buyer's public key.
The seller will be waiting for this event (via web3.watch perhaps?) It'll do some off-chain computation (say encrypting the data with the buyer's public key - so only she can open it.)
The seller will then call another contract function send_goods_back() sending the encrypted data to the contract.
The contract will emit a new event goods_received() forwarding the data (essentially to everyone.)
The buyer will be waiting for this event and has now received the goods. She decrypts the data and thanks Vitalik Buterin.

If seller doesn't send the "goods" the contract could just refund the money, right?

Is the design good enough? What would you change?


texts: Not referring to the definition in the dictionary. In the context of blockchains and Ethereum in particular, the term "grief" has been used repeatedly in a host of scenarios: ethresear.ch, Plasma calls, Twitter conversations etc.


texts: Easier Installation of privatenode for non-technical users

texts: I have seen documentation of creating privatenet using geth. But it holds few commands which will not be a better option for users/clients who doesn't have technical knowledge to use the application in privatenet. It is not expected that each user will run geth commands on terminal. Creating docker is the efficient solution for such situations?


texts:
I have a pretty standard OpenZeppelin crowdsale.  Now the issue is that I want to be able to use one crowdsale contract with multiple (~100) different ERC20 tokens.

Ideally I want to put the crowdsale contract on the chain and then add ERC20 tokens to it over the next few months.  I don't want to release a new crowdsale contract for each token because it'll be expensive.

Is there a way to convert the Crowdsale contract into one that can handle multiple tokens?  Does one exist already?


texts: What would be good result measures in Ethereum

texts:
I'm thinking of a way to present relevant results measures for my blockchain.
I can see how for hyperledger is interesting to present (transactions per second x block size) or (latency x block size). However, Ethereum has different bottlenecks... block size still makes sense but I'm just not sure about transactions per second or even latency...
Does anyone have an idea of which measures would be interesting to analyze?
(using remix and ganache, open to use others that offer more ways of analysis)
Thanks.


texts: How to use Mocha reporter in Truffle console?

texts:
I work with Truffle and Windows Powershell. I set Mocha in truffle-config.js like:
module.exports = {
                    .
                    .
                    .
     mocha: {
        reporter: 'eth-gas-reporter',
        reporterOptions : {
        currency: 'USD',
    }
      }
}

to see some information about gas consumption in USD. I deployed my contract with Truffle in its development environment. So, i need a command used in Windows Powershell to present the desired information. Are my configuration and my need correct? if yes, please provide the appropriate command.


texts: How to send ethers from multiple accounts to a single recipient?

texts: I want to transfer 1 ETH distributed to three addresses to a single recipient address. How can I achieve this in ethers.js


texts: Type uint256 is not implicitly convertible to expected type int256

texts:
I'm trying to compile the following keep getting an error, even though used this before in second code and its working fine.
Simply trying to change the temp to the new temperature set by the user, so that I could call/get it from Solidity.
Any help on how to fix the error or achieve what I want?

Code:

uint256 public temp;
constructor() public payable {
.
.
.
.
  temp = 15;
    }
event DataCommited( int256 T, string _L);

function commitTask(int256 _temp, string memory _location) public inState(State.Created) payable{
require (keccak256(abi.encodePacked(location)) == keccak256(abi.encodePacked(_location)));
require(_temp < 35 && _temp > -5, "Temperature out of range");
dataCount += 1;

if(dataCount == rewardNum)
        {
            msg.sender.transfer(reward);
            emit TaskDone();
        }

        emit DataCommited( _temp, _location);
        _temp = temp;

    }

Working code without an error:

uint256 age;
function setInstructor(string memory _fName, uint256 _age) onlyOwner public  {
   fName = _fName;
   age = _age;
   emit Instructor (_fName, _age);
}


texts: Could not deploy contract with valid data

texts:
I have downloaded contracts with their abi and json. I have to deploy them. when i extract bytecode from downloaded files and then assign it to my data variable to deploy contract whic gives following error; Same error related question asked earlier here, but no answer is given.

UnhandledPromiseRejectionWarning: Error: The data field must be HEX encoded data.

here is my code;

async function deployCon(key) {

  var v = constructorParameters[key].input.length;
// console.log("deploy for contract : ", v)

const contract = new web3.eth.Contract(abi[key]);
if(v == 0) {
  params = {
    data: "0x" + bytecode[key],
};
}
else {
  params = {
    data: "0x" + bytecode[key],
    arguments: constructorParameters[key].input
};
}

const transaction = contract.deploy(params);
const options = {
    data: transaction.encodeABI(),
    gas: await transaction.estimateGas({from: account1})
};

const signed = await web3.eth.accounts.signTransaction(options, privateKey1);
receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);
console.log(`Contract deployed at address: ${receipt.contractAddress}`);
return receipt;

}

and here is my bytecode[key] value

606060405260018054600160a060020a031916........

NOTE: I have just tried above code for the contract see here


texts:
I tried to send some Ether for an ICO (my first ever) but the transaction failed with error revert opcode. Please see below.

https://etherscan.io/tx/0x17844dca601f11995b88411e768a363260e4a11d1ead9aeeb0b02acd61a44c5d

I tired a couple of times but it did not work and also increased the gwei to 99. I dont understand how this will work as the ICO has receommended that we use 200000 gas limit max and 60 gwei (max 99) when sending ether otherwise the transaction would fail. And now the sale has ended so missed out.

Can you please explain how can I avoid this issue next time?

Many thanks


texts: Difference in "delegate call via assembly"

texts:
I came across a different version of delegate call via assembly and also tried all of them - no different result so far. How does it differ and which is the best version to use?

OpenZepplin version:

assembly {
  let ptr := mload(0x40)
  calldatacopy(ptr, 0, calldatasize)
  let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)
  let size := returndatasize
  returndatacopy(ptr, 0, size)

  switch result
    case 0 { revert(ptr, size) }
    default { re  turn(ptr, size) }
}

MakerDAO version:

assembly {
  let succeeded := delegatecall(sub(gas, 5000), _target, add(_calldata, 0x20), mload(_calldata), 0, 0)
  let size := returndatasize

  response := mload(0x40)
  mstore(0x40, add(response, and(add(add(size, 0x20), 0x1f), not(0x1f))))
  mstore(response, size)
  returndatacopy(add(response, 0x20), 0, size)

  switch iszero(succeeded)
    case 1 {
        revert(add(response, 0x20), size)
    }
}

Simple version:

assembly {
  let succeeded := delegatecall(sub(gas, 5000), _target, add(_calldata, 0x20), mload(_calldata), 0, 32)
  response := mload(0)
  switch iszero(succeeded)
  case 1 {
    revert(0, 0)
  }
}


texts: Triggering actions on smart contract when a token transfer happens

texts:
Differently from receiving ethers which goes through a payable code block, receiving tokens is not managed by the recipient but by the token contract code. Hence, in case you want your contract to perform some action when he receives tokens, which practice is best to use?

EDIT: I'm aware of EIPs to enhance token interface to manage this, however my question is how to work this around for ERC20 tokens.


texts: Deploy to mainnet with Truffle + Infura: nonce too low

texts:
I'm trying to deploy a very simply ERC20 token contract using Truffle and Infura and getting this:

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x701cc16d9719131ba94533bde8b88eae6b80a090193e6cfcc08c4f1c29e65aa1
  Migrations: 0x3c0cc05bdb1f1e82db23cb0d0bf0f5e3666ff410
Saving successful migration to network...
  ... 0x07d4c68bf6e3453d9daa5f61757d14d9d24d79a8565671adc625fc742bf9d7ba
Saving artifacts...
Running migration: 2_deploy_contracts.js
Saving successful migration to network...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
nonce too low

After reading some other posts, I tried to "postpone" the 2nd migration so to let all infura nodes sync and be aware they need to promote my nonce by 1, this is how the main part of 2_deploy_contracts.js looks:

setTimeout(function(){
    deployer.deploy(MyToken, 'MyTokenName', 'MyTokenSymbol', initialSupply)
  },1000 * 60 * 15)

As you can see, I'm trying to give it 15 minutes to sync.

However, I still get the nonce too low, and I get it quite immediately. I suspect the 2nd transaction that get's a lower nonce isn't the deployment of my Token, rather something to do with Truffle's Migration contract, related to Saving successful migration to network...

Anyway, wether it is my bad, or Truffle's bad, how do I deploy to mainnet using truffle + infura without the nonce too low issue?


texts: Web3.js unable to unlock account to call smart contract

texts:
I am using web3.js 0.20.6 and I want to unlock an account to execute a smart contract method on a private blockchain. The account is used to pay for the gas. I have used the following code to unlock the account:

web3_1.personal.unlockAccount(web3.eth.accounts[0],password,time, function(error,result){
    if (result){
        // account unlocked so call smart contract function
        contract_instance.publishNode(param1, param2,{from:web3.eth.accounts[0],gas:300000});
    }
});

and I get the following error:

/home/davide/WebApp/node_modules/web3/lib/web3/requestmanager.js:61
    throw errors.InvalidResponse(result);
    ^

Error: account is locked
at Object.InvalidResponse (/home/davide/WebApp/node_modules/web3/lib/web3/errors.js:38:16)
at RequestManager.send (/home/davide/WebApp/node_modules/web3/lib/web3/requestmanager.js:61:22)
at Eth.send [as sendTransaction] (/home/davide/WebApp/node_modules/web3/lib/web3/method.js:145:58)
at SolidityFunction.sendTransaction (/home/davide/WebApp/node_modules/web3/lib/web3/function.js:167:26)
at SolidityFunction.execute (/home/davide/WebApp/node_modules/web3/lib/web3/function.js:253:37)
at Object.exports.publish_node (/home/davide/WebApp/red5Network.js:117:16)
at Object.callback (/home/davide/WebApp/app.js:61:16)
at /home/davide/WebApp/node_modules/web3/lib/web3/method.js:142:25
at /home/davide/WebApp/node_modules/web3/lib/web3/requestmanager.js:89:9
at XMLHttpRequest.request.onreadystatechange (/home/davide/WebApp/node_modules/web3/lib/web3/httpprovider.js:118:13)

On the other end if instead of calling a smart contract function I send ether from an account to another everything works. What is the issue?


texts:
I don't get why when trying to deploy my contract it says that gas estimation errored.
Forked Mainnet with ganache-cli -f <INFURA_ID>
Trying to deploy and execute following code:
pragma solidity ^0.7.0;

import 'IERC20.sol';
import 'IUniswap.sol';

contract Uniswap_Swap {
  address internal constant UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
  address daiAddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
  IUniswap public uniswapRouter;

  constructor() {
    uniswapRouter = IUniswap(UNISWAP_ROUTER_ADDRESS);
  }
  function convertEthToDai(uint daiAmount) public payable {
    uint deadline = block.timestamp + 15;
    uniswapRouter.swapExactETHForTokens{ value: msg.value }(daiAmount, getPathForETHtoDAI(), address(this), deadline);
    (bool success,) = msg.sender.call{ value: address(this).balance }("");
    require(success, "refund failed");
  }
  function getPathForETHtoDAI() private view returns (address[] memory) {
    address[] memory path = new address[](2);
    path[0] = uniswapRouter.WETH();
    path[1] = daiAddress;

    return path;
  }
  receive() payable external {}
}

Any help is much appreciated
EDIT: migration file
const UniswapExample = artifacts.require("UniswapExample");

module.exports = function (deployer) {
  deployer.deploy(UniswapExample);
};

tried it with remix and directly through terminal. Even wrote a python code to call. Closest I got was with python and Excessive_Input_Error. Though I thought no liquidity needed to add due to mainnet fork.


texts: Could a contract, or parts of a contract, be reverse engineered from bytecode if the ABI was available?

texts:
Compilation back to the original source code from just the bytecode is impossible because all variable names, type names and even function names are removed. (source)

It's possible to call functions on a contract by using a bytes4 hash of that functions name, so that means that the contract stores that hash of the name.

If a de-compiler had access to the ABI, could it reverse a contract, or parts of a contract, to Solidity?


texts: How Can I Convert Between A Solidity Timestamp And Year/Month/Day Hour:Minute:Second?

texts:
Solidity provides the uint256 now or block.timestamp Special Variable.

How can I convert between this Solidity timestamp and year/month/day hour:minute:second?


texts: Why is geth account list and eth.accounts different?

texts:
I am trying to sync Metamask accounts with a private geth installation.

I imported the account from MM and that shows on geth list but on eth.accounts nothing for that account. Any reason for this and how to correct?

Three accounts -

root@dockertest:/home/trevor/devnet# geth --datadir node1/ account list
INFO [11-27|22:26:31.833] Maximum peer count                       ETH=25 LES=0 total=25
Account #0: {2a7f4fa8000e6fc777e665bf83a866fb51508f95} keystore:///home/trevor/devnet/node1/keystore/UTC--2018-11-27T07-30-25.745358795Z--2a7f4fa8000e6fc777e665bf83a866fb51508f95
Account #1: {b04f9d894ac45b3ebc499fce1aaf8d7578a73e4d} keystore:///home/trevor/devnet/node1/keystore/UTC--2018-11-27T17-25-37.723858602Z--b04f9d894ac45b3ebc499fce1aaf8d7578a73e4d
Account #2: {3b79ccfce4e6fdeefd2f9dbc744b0dc10f632d6a} keystore:///home/trevor/devnet/node1/keystore/UTC--2018-11-27T22-02-27.478135343Z--3b79ccfce4e6fdeefd2f9dbc744b0dc10f632d6a

After starting node1 using geth --datadir node1/ ...

Two accounts -

root@dockertest:/home/trevor/devnet# geth  attach node1/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.18-stable-58632d44/linux-amd64/go1.10.4
coinbase: 0x2a7f4fa8000e6fc777e665bf83a866fb51508f95
at block: 4838 (Tue, 27 Nov 2018 22:19:40 UTC)
 datadir: /home/trevor/devnet/node1
 modules: admin:1.0 clique: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

> eth.accounts
["0x2a7f4fa8000e6fc777e665bf83a866fb51508f95", "0xb04f9d894ac45b3ebc499fce1aaf8d7578a73e4d"]


texts: Getting this error: "error "oversized data"

texts:
When I am trying to deploy my smart contract(It is a 600+ lines smart contract)through truffle framework (version 4.1.14)  on Rinkeby testnet it is showing the above error.But when I am deploying the same contract with remix ide and using metal mask then it is deployed successfully. I know that the code size limit of 32KB is in ethereum-go implementation to avoid DOS attack.So if anyone can answer why the contract is getting deployed with remix but not with truffle.
Here is the link on rinkbey testnet
https://rinkeby.etherscan.io/tx/0xe42b8fa9a7aab732a633465a84e8a56433eb482e0cb5aa49ed38f5428dfc82a4


texts:
I know that this has been covered in other questions here but I'm not sure what's happening in my case. My code is returning a compiler error "Stack too deep, try removing local variables." But I only have around five function arguments and a few more local variables. The function in question is given below:

function sell(bool limit, uint256 whichquery, uint8 whichoutcome, uint256 amount, uint16 price) {
        uint cumulativeamountgained;
        uint numorderstobedeleted;
        uint amountnotfilled = amount;
        if(tokenHoldings[msg.sender][whichquery][whichoutcome] < amount) throw;
        if(limit){
            for (uint i=orderbook[whichquery][whichoutcome][0].length-1;i>=0;i--){
                if(orderbook[whichquery][whichoutcome][0][i][0] >= price) {
                    if(orderbook[whichquery][whichoutcome][0][i][1] > amountnotfilled){
                        orderbook[whichquery][whichoutcome][0][i][1] -= amountnotfilled;
                        tokenHoldings[address(orderbook[whichquery][whichoutcome][0][i][2])][whichquery][whichoutcome] += amountnotfilled;

The error is triggered on the last line of this code snippet under the first "whichquery".


texts: Messaging platform with public-private key pairs as identifier

texts: Is there any platform available for Ethereum address 0x1d53.. to message 0xcc23..., and so on? It seems like there would be a lot of demand for something like that, which suggests it exists. Off-chain, I guess. I need it for the pairs in Pseudonym Pairs (source code) to agree on a random video channel over something like https://gotalk.to or https://meet.jit.si.


texts: How the consensus informations are transported across the network?

texts: Lets consider the scenario, if one node in India, finds the nonce (in pow) and it will generate the block and propagate to the network. How the block will move across the each and every node of the network?. is it by gossip or ghost protocol?. If that is the case, in 10s - 12s whether it will reach to the entire node in the world and they will work for next block?. What about the poor internet connectivity countries like Africa?.


texts:
This is a contract im trying to deploy and i think its an abstract contract as most of the functions dont seem to be implemented... anyway the issue im facing is that truffle is telling me i cant deploy an abstract contract so can someone tell me what to do in this case?
Do i need to deploy all the contracts which implements this contract functions first before i can deploy this as well?
Im not sure how the system works.

contract ERC20 {
  function totalSupply() public view returns (uint256);

  function balanceOf(address _who) public view returns (uint256);

  function allowance(address _owner, address _spender)
    public view returns (uint256);

  function transfer(address _to, uint256 _value) public returns (bool);

  function approve(address _spender, uint256 _value)
    public returns (bool);

  function transferFrom(address _from, address _to, uint256 _value)
    public returns (bool);

  function decimals() public view returns (uint256);

  event Transfer(
    address indexed from,
    address indexed to,
    uint256 value
  );

  event Approval(
    address indexed owner,
    address indexed spender,
    uint256 value
  );
}


texts: How to create Interface to read Struct in mapping?

texts:
There are 2 contracts A and B.

A has a mapping which returns Struct:

mapping (bytes32 => Cup)  public  cups;

How can we read the cups mapping in contract B?

Following code doesn't work for sure:

interface CupsInteraface {
    function cups(bytes32 cup) external returns (Struct);
}


texts: Struggling with using Event logs via Web3js to update my React app

texts:
I'm building a DApp in React and really struggling to handle events well. My understanding is that listening for Events is the best way to update my react UI. I'm looking for links, tutorials, example projects, or best practices on how to handle events effectively.

My main problem is that MetaMask seems to keep duplicating logs that are emitted by particular Events. This makes it difficult to determine when to have my UI respond. Right now I'm tracking transaction hashes of each log and only responding to non-duplicates. Is this normal?

  componentDidMount() {
    getWeb3
    .then(results => {
      this.setState({
        web3: results.web3
      })

      //Set up event event logging
      const contract = require('truffle-contract');
      const attendanceRewarder = contract(AttendanceData);
      attendanceRewarder.setProvider(this.state.web3.currentProvider);
      attendanceRewarder.deployed().then((instance) => {
        let contributedEvent = instance.Contributed();
        let winnerEvent = instance.Winner();
        let validatedEvent = instance.Validated();
        let nameUpdatedEvent = instance.NameUpdated();
        let winningsCollected = instance.WinningsCollected();
        contributedEvent.watch( (err, response) => {
          console.log(response,err);
        });
        winnerEvent.watch( (err, response) => {
          console.log(response,err);
        });
        validatedEvent.watch( (err, response) => {
          console.log(response,err);
        });
        nameUpdatedEvent.watch( (err, response) => {
          console.log(response,err);
        });
        winningsCollected.watch( (err, response) => {
          console.log(response,err);
        });
      })
      return this.instantiateContract();
    })
    .catch(() => {
      console.log('Error finding web3.');
    })

    //Poll for any metamask account switches
    setInterval(() => {
      let account = this.state.loggedInAddress;
      if (this.state.web3.eth.accounts[0] !== account) {
        this.setState({loggedInAddress: this.state.web3.eth.accounts[0]});
        let hasContributed = this.state.attendeeList.includes(this.state.loggedInAddress);
        this.setState({hasContributed: hasContributed});
      }
    }, 500);
  }


texts: Getting Pending Eth Transactions related to a contract

texts:
I noticed you can call: "web3.eth.subscribe('pendingTransactions') and then call web3http.eth.getTransaction(txHash); to get the full details of the transaction (which then you can filter depending on the contract you're looking for)
However, this results in a huge amount of calls, 10k requests in just 5 minutes, since there's so many eth requests going through right now.
Is there a better way to do this? To filter on pending transactions, for a specific address? It doesnt seem like this is possible without rolling out your own Eth Node, since services like Alchemy or Quicknode all fall below this amount of requests, even for the highest paid tier.


texts: Mining Address get changes very frequently

texts:
I have a private ethereum node running on aws instance, the time when started the node i set the etherbase/coinbase address to the first account of the node. As i started the node i find that first account is getting the rewards of mining and everything was as expected, but after few hours the miner/etherbase address automatically get changed, as a result of which funds from first account get transferred to miner address as a mining reward. And i unlocked the first account to send the transaction over the node and as all the funds get transferred to newly assigned miner address, all my transactions become pending due to insufficient funds in sender account. Any help will be appreciated.
Thanks in advance.
Here are the few details of geth client and command i used :
GO ETHEREUM CLIENT DETAILS :
Geth
Version: 1.9.12-stable
Git Commit: b6f1c8dcc058a936955eb8e5766e2962218924bc
Architecture: amd64
Protocol Versions: [65 64 63]
Go Version: go1.13.8
Operating System: linux
GOPATH=
GOROOT=/build/ethereum-YoJS3q/.go
GETH COMMAND :
/usr/bin/geth --datadir node01 --networkid 10 --allow-insecure-unlock --targetgaslimit 9000000000000 --nousb --etherbase '0x669980d2EF6b14e15e4e1D32E70F2ccC83EC98c9' --rpc --rpcaddr "0.0.0.0" --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3 --rpccorsdomain '*'
GENESIS.JSON :
{
"alloc": {
"0x669980d2EF6b14e15e4e1D32E70F2ccC83EC98c9": {
"balance": "10000000000000000000000000000000000000"
},
"0x61722d9D8F75E97A2F8B4C63Be1C8820D944C940":{
"balance": "1000000000000000000000000000000000000"
}
},
"coinbase": "0x669980d2EF6b14e15e4e1D32E70F2ccC83EC98c9",
"config": {
"homesteadBlock": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"chainId": 10,
"eip150Block": 0,
"eip155Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip158Block": 0,
"maxCodeSize": 35,
"maxCodeSizeChangeBlock" : 0,
"isQuorum": true
},
"difficulty": "0x0",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xE0000000",
"mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
"nonce": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}


texts: Can a smart contract owner choose to reject or accept a transaction?

texts:
This might be a stupid question, but I am a noob to this.
I am wondering if the creator/owner of a smart contract can choose to reject a payment they receive.
If so - how does the owner of the contract interact identify themselves to the contract. I mean how do they securely interact with the contract in a way that no-one else can? Is that possible?

Or can a smart contract be made that, for example, auto refunds any payments sent to it after x days - unless the owner of the contract accepts them somehow?


texts:
I try to construct a transaction with Node (11.4.0), ethereumjs-tx (1.3.7)  and web3 (1.0.0-beta.55) and Infura.
Infura gives me '0x35b' for the nonce,
then I create the tx:

amount = 0.001;
nonce = '0x35b';
txParams = {
    to: "0x130f6562d441D25A812865527761EE7246AF0297", //receiver,
    value: web3.utils.toHex( web3.utils.toWei(amount, 'ether') ),
    gas: 21000,
    gasPrice: 20 * 1000000000, // converts the gwei price to wei
    nonce: nonce,
    chainId: 3  // Ropsten
}

Then I create the tx:

const EthereumTx = require('ethereumjs-tx');
let tx = new EthereumTx(txParams);

The tx seems to be invalid:

console.log(tx.validate())

prints 'false', and if I try to send the tx to Infura (method: eth_sendRawTransaction) I get:

(intermediate value) is not iterable

Any idea what my problem is ?


texts: How do I call Approve() function from the contract creator's address? ERC20 token escrow

texts:
I am trying to send ERC20 token into an escrow contract so that it could transfer them to relevant stake holders. The part that I am stuck in is properly using the approve function.

From my escrow contract I created the following approve function:

function approveDeposit(uint amount) public returns(uint) {
  return _tokenAddress.approve(address(this), amount);
}

For example when submitting approveDeposit(100), I was expecting that the it would first call the tokenContract and then approve the contract to transferFrom the owner 100 tokens in the form:

_allowed[owner][contract] = 100;

But when I debug in remix, it seems like _allowed[contract][contract] is executed.

How exactly can I execute _allowed[owner][contract] = amount
instead of _allowed[contract][contract] = amount?


texts: Ethereum cost - how does it work in memory

texts:
This is really bugging me and doesn't seem any article that can help at all.
wiki says further the gas costs for using memory:

The fee for expanding memory is determined via a
subtract-the-integrals method. Specifically, TOTALFEE(SZ) = SZ * 3 +
floor(SZ**2 / 512) is the total fee for expanding the memory to SZ
32-byte chunks (note: partially filled chunks are counted, so 33 bytes
= 2 chunks), and if a particular operation expands memory from size x to y, the additional gas cost is TOTALFEE(y) - TOTALFEE(x)

Now, I want to understand the formula idea.
So, I have:
//calling this costs 21394 Gas
function nice() external {

}

// calling this costs 21507 gas
function nice() external {
    uint128[1] memory t;
}

// THE DIFFERENCE HERE IS 113

Now, as I can see, we used maximum 2 chunks of 32 bytes. So putting in the formula will give us 6. How can it become 113 ? maybe I don't understand the additional cost - TOTALFEE(y) - TOTALFEE(x) ?  Can someone elaborate on this ?
UPDATE 1
I decided to compare two closer versions so that I could better understand it. So, We have 2 versions:
This gives us 21634
function test2() external  {
   uint128[22] memory t;
}

This gives us 21640
function test2() external  {
   uint128[23] memory t;
}

So, there are 6 gas difference. Let's figure out how we can get the 6 by ourselves.

https://www.diffchecker.com/igIeqefv
In terms of opcodes, there's no actual difference, other than codecopy. If we look at codecopy, it says: 2 + 3 * (number of words copied, rounded up). So, let's calculate this for both versions. For version 1, it will be 2+3*22 = 68. For the second version, it will be 2+3*23=71.
Now, we also have to count memory cost. The above seems like to be opcode costs. For the first version from the memory cost formula, we have - 22*3 +0 = 66 . For the second version, we have - 23*3 + 1 = 70.
Now, let's sum those u. for the first version, we have 68 + 66 = 134. For the second version, we have 70+71 = 141. So, the real difference is 7 gas, when we saw that compiler difference was 21640-21634 = 6.
What about the 1 gas ? This is very interesting.
UPDATE 2
There's another interesting scenario.
// This costs 21394 in remix
function test2() external  {
}

// Then I change it to . Now this costs 21409
function test2() external  {
        assembly {
            mstore(0x80, 10)
        }
}
So there is 21409 - 21394 = 15 gas difference

I decided to compare their opcodes. and in the second version, this is what gets added.
PUSH A          10
PUSH 80         0x80
MSTORE          mstore(0x80, 10)

Push is 3 gas, so we have 6 gas for 2 PUSH. and MSTORE is 3 . so we got 9.
Now, there has to be expansion cost, which seems to be 3. so we are left with 9+3 = 12.
How did we end up with the 15 gas difference instead of 12 ?


texts: Transaction done, but nonce does not update and call to a function returns zero

texts:
I've used web3py to deploy a contract and send some transactions to it.

I calculate the nonce this way: nonce = web3.eth.getTransactionCount(account, "pending")

When I deploy the contract, everything goes right.
Then I make a simple transaction (using the method buildTransaction), such as updating the value of a contract, and then I wait for the tx receipt. When I see it on etherscan, the transaction has been a success.
But if I try to call the constant function that returns that value, I get 0, even if I had updated it with other value.

In addition, if I later try again doing that transaction, the nonce does not update, and I get the message of "nonce too low".

Can you help me with this issue? Idk what happens.