texts:
I am making a to do list application using metamask,following this tutorial
and my truffle-contract.js keeps giving this error
"Uncaught TypeError: Web3 is not a constructor" and references the code
  var BigNumber = (new Web3()).toBigNumber(0).constructor;

but in the start of this code
var Web3 = require("web3");

Web 3 has already been loaded using require.
I had installed web3 using npm install, the package.json, a small part of the package.json I'm pasting below
    "nodemon": "^1.17.3",
    "truffle": "5.0.2",
    "truffle-contract": "3.0.6"
  },
  "dependencies": {
    "web3": "^0.20.6"
  }
}

after this my app.js give the error "Uncaught (in promise) ReferenceError: Web3 is not defined"
in this part
 if (typeof web3 !== 'undefined') {
      App.web3Provider = web3.currentProvider
//Error in this line below
      web3 = new Web3(web3.currentProvider)
    } else {
      window.alert("Please connect to Metamask.")
    }```


texts: Transferring parity blockchain data to another machine does not work

texts:
For the past several days I have been trying to transfer the blockchain data from an x86_64 machine to an armv7l machine, hoping that I could avoid having to sync from scratch on the latter.

However, my pretty straightforward attempt to rsync the data has failed not only transferring from x86_64 to armv7l, but also from armv7l to x86_64. The issue is the fact that neither parity will continue syncing with the transplanted data.

My first attempt was to simply rsync the ~/.local/share/io.parity.ethereum/chains directory. Upon transferring the data, parity on the other machine was not able to continue syncing newly mined blocks and simply stalled. After some time, parity would display the following error: Stage 5 block verification failed

Being quite ignorant of parity's internals, my thought was that the blockchain data was dependant on some other file as a verification measure? To try and solve that, I simply transferred over the entire io.parity.ethereum directory. That would also fail with the same error.

After that, I thought that the issue was some kind of unique verification hash generated from device's architectural differences, which made me try and find a way to export the blockchain. This is possible via the parity export blocks command, but unfortunately it will not export everything until the device has completed syncing "ancient blocks" with the following message: Error exporting incomplete chain as per https://github.com/paritytech/parity/issues/6933

My question is whether this is an intentional security measure, or some kind of transfer issue?

There isn't any transfer error during the procedure, and I have used an USB flash drive formatted with btrfs to transfer the data. Both devices are able to sync from scratch on their own.

rsync flags: -a --info=progress2 --update --recursive --delete
parity flags: --ipc-path=/run/ethereum/parity.ipc --scale-verifiers
parity version: v1.9.0.10818 built from git master on both machines

Any kind of insight into this issue is greatly appreciated!


texts:
what does "Replacing" mean in migration?

a simple test contract C.sol:

pragma solidity ^0.4.17;

contract C{
    uint public ConstructorUint;

    function C(uint SetConstructorUint)public{
        ConstructorUint = SetConstructorUint;
    }
}

the Migration file 99_migration.js:

var Cnumber0 = artifacts.require("C");
var Cnumber1 = artifacts.require("C");
var Cnumber2 = artifacts.require("C");
var Cnumber3 = artifacts.require("C");
var Cnumber4 = artifacts.require("C");
var Cnumber5 = artifacts.require("C");

module.exports = function(deployer) {
    deployer.deploy(Cnumber0, 0);
    deployer.deploy(Cnumber1, 1);
    deployer.deploy(Cnumber2, 2);
    deployer.deploy(Cnumber3, 3);
    deployer.deploy(Cnumber4, 4);
    deployer.deploy(Cnumber5, 5);
}

the truffle.js:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    }
  }
};

upon starting up Ganache and running in the terminal.

$ truffle migrate --network development

I find that create contracts happened, as expected.

in the terminal running.

$ truffle networks

I find only One C contract with the last at address of the C contracts.
starting over by closing Ganache and running

$ truffle networks --clean

this time I try

$ truffle develop

this opens the truffle console where
from the truffle console

truffle(develop)> migrate

I see this:

  Saving artifacts... Running migration: 99_migration.js   Deploying
  C...   ...
  0xf56571c947f71fa8d3220ce2707accdf97a00a3ac2042d18dcff0410e26bf476
  C: 0x345ca3e014aaf5dca488057592ee47305d9b3e10   Replacing C...   ...
  0x17acd2015ea93445bca90c4f207073a7f86eb3556de00936e78f6fd4fe67c7a3
  C: 0xf25186b5081ff5ce73482ad761db0eb0d25abfbf   Replacing C...   ...
  0xcc2a645db6d4c32405ab3c771069262370512689de895a6374b78b72d73b12c8
  C: 0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f   Replacing C...   ...
  0xac0d4f51c458e28fc3ecc871994e03e3aed86032dd881cf7dd57f2dffb58d378
  C: 0x9fbda871d559710256a2502a2517b794b482db40   Replacing C...   ...
  0xf6cded7c4228a00cc2f12287417b0c697dec09635c013e28440d10dea7fc0565
  C: 0x2c2b9c9a4a25e24b174f26114e8926a9f2128fe4   Replacing C...   ...
  0x539e27630c8881957a07ded94f9f2fb60963e505991eec1a588893e96d80b654
  C: 0x30753e4a8aad7f8597332e813735def5dd395028 Saving successful
  migration to network...   ...
  0x68e7f2440f71ec0386d4214eb0c3e2346112dd1073495fc2ef1c8244691e5684
  Saving artifacts...

again that Replacing word
so I use the functions of the contracts by "ContractName.at("ContractAddress").FunctionName(FunctionArguments)

truffle(develop)> C.at("0x30753e4a8aad7f8597332e813735def5dd395028").ConstructorUint()

  { [String: '5'] s: 1, e: 0, c: [ 5 ] }

truffle(develop)> C.at("0xf25186b5081ff5ce73482ad761db0eb0d25abfbf").ConstructorUint()

  { [String: '1'] s: 1, e: 0, c: [ 1 ] }

truffle(develop)> C.at("0x2c2b9c9a4a25e24b174f26114e8926a9f2128fe4").ConstructorUint()

  { [String: '4'] s: 1, e: 0, c: [ 4 ] }

as you can see the numbers 5, 1, and 4 do exist. so the contracts do too?
however from a separate terminal I again check the network by

$ truffle networks

and I get this:

  Network: UNKNOWN (id: 4447)   C:
  0x30753e4a8aad7f8597332e813735def5dd395028   Migrations:
  0x8cdaf0cd259887258bc13a92c0a6da92698644c0

only one contract at the last address? so what happens in a non test net does the contract deploy with migrations many times with different constructor values as expected or does it do something else unexpected.
if it does the unexpected what is a work around to accomplish multi deployment of the same contract, such as this.


texts:
What are the main functionalities that blockchain/DLTs have to support Know Your Customers (KYC), Anti-Money Laundering (AML) and Counter Terrorism Financing (CTF)?
Does it make sense that Ethereum could support any of them?


texts: In a permissioned blockchain network can a participant from one network transact with a participant in another network?

texts:
In my setup, each organization (organization A and organization B) has own quorum network.
Participant of organization A wants to transact with a participant in organization B.

Can it be achieved? I am following an example from this.


texts: Is there a way to reproduce a stack depth attack now?

texts:
I am trying to replicate the attack I found here:
Reproducing stack depth attack

contract Attacker {
Victim public victimContract;
uint x;

function Attacker(){
    victimContract = (new Victim).value(10 wei)();
}

function attack(uint y) {
    if (y > x) {
        this.delegatecall(bytes4(sha3('attack(uint256)')), --y);
    }
    else {
        victimContract.donate.value(1)(this, 1);
    }

  }
}

contract Victim {
    mapping(address => uint) karma;
    function donate(address someAddress, uint amount){
        if(msg.value == amount) {
            someAddress.send(amount);
            karma[msg.sender] += amount;
        }
    }
}

I have tried with Remix 0.3.4 solidity compiler but cannot get the contract to execute now because of the per block gas limit of 3,000,000 which the transaction exceeds.

I am interested in seeing its execution on the EVM, since I want to visualise it. Does anyone know the transaction hash(s) of any successful stack depth attacks?


texts: My Ethereum Wallet/Mist Stuck after Byzantium update

texts:
After updating my ethereum wallet and mist now they are stuck at around block 4,375,146. It actually keeps downloading new block but never goes up to the latest block (always +4000 block behind... and it has been like that since yesterday) Also some of my balances do not show real or current values.

What can I do to sync totally with the network? I´m running a iMac, macOS Sierra


texts: What is the right way to calculate gas price and limit for contract deployment?

texts:
I have tried several times and reached up to a gasPrice of 65 Gwei and a gasLimit of 500,000 which is $7.6 and still the deployment fails with error "Out of gas".
After spending tens of USD without getting the fees back - how can I calculate how much gas will be enough for deploying my contract?


texts: How to generate new address for new contract created by constructor

texts:
I'm trying to resolve a problem and google is not useful this time.

On my localhost truffle + testrpc I have a contract which returns a new instance of a new contract.

import 'contracts/MyBasicContract.sol';

contract Factory {

 function createContract() returns (address created){

  return new MyBasicContract();

 }

}

What I'm trying to do is to generate a new contract with a new address on which I'll be able to call functions from the front-end.
After deploying Factory I called function createContract which returns me address but still the same address again and again.

What am I doing wrong? Or how looks the best practise for generating new contracts with new address from frontend?

Thank you all for some hints.


texts: Does all full-client nodes require to execute each transaction in order to approve them?

texts:
As I understand: each epoch a winner-miner broadcasts a new block to the tail of the block-chain, which contains the block's transaction list, with n transactions executed by the block and some other information. This is well explained on Ethereum's white paper:

After a new block is selected, what will be the other miner's and full-nodes' role should will be, in order to approve/accept the new block?

[Q] Does all the miners and/or full-client nodes require to re-execute the each transaction in order to approve/accept the new block? If yes:

Would that consume additional computational power to re-execute each transaction by each node over and over again? and is there any alternative solution to over-come this additional computation.

If no:
Is there any other approval mechanism without doing re-execution of the approved transactions by the full-nodes?

Thank you for your valuable time and help.


texts: data transfer from one contract to another

texts:
I have deployed one contract in my private blockchain, now client has asked  some modification to existing contract and after changes we redeployed this into ethereum network and I got new contract address. Now can we migrate some data from previous contract address to newly deployed contract.

Thanks


texts:
I'm new to Ethereum

I just installed the Ethereum Wallet and Solidity on my Linux system. Before I installed everything I read the whole documentation of Ethereum and Solidity. Now I would like to start with programming some smart contracts. I have some basic questions:

What is the best way to start?
How can I test my smart contracts?
Do I have to install a private net? If yes, where can I find a documentation about it?
Do you have any other useful advises for a newbie?

Thank you very much for your help

Thank you very much. This is very valuable information.

I created a contract according to the first video. When the contract is confirmed I get the following Message:

"No data is deployed on the contract address!"

What does that mean?


texts:
I am using Etherum wallet (this thing: https://imgur.com/a/WGDLs)

I created a new account, transferred 0.01 etherum into it.

Then I went to accounts -> backup -> accounts, which took me to Users\USERNAME\AppData\Roaming\Ethereum\keystore

I made a copy of the file in keystore, and then shutdown etherum waller, deleted the keystore folder, and restarted etherum wallet.

When I restarted etherum wallet, the app showed no accounts present. I went to Accounts -> Import Accounts and added the file I'd copied earlier. To my surprise, it started displaying my balance again without prompting for a password.

Is this normal?
Does this mean Etherum wallet is caching my password somewhere? Or caching the decrypted private key (as I understand, the private key is present in the keyfile encrypted using your password) somewhere so it does not need to re-decrypt it?
If I want to make doubly sure I remember the password correctly, is there an 'easy' and safe way to test the password? i.e. is there some way to get Ethereum wallet to 'forget' so I can add my account, and it'll prompt me for my password?


texts: VM error (revert) when trying to send value to a contract's fallback function

texts:
I'm going through the Solidity docs and in the fallback function section, I'm having some issues running the example provided, specifically in terms of sending value to the receive function of TestPayable. These are the steps I've followed in Remix:

Compile
Deploy TestPayable contract
Deploy Caller contract
Top up the Caller contract with 4 ether (through low level interaction)
Input the TestPayable address into callTestPayable and execute it

As a result I get the following error:

transact to Caller.callTestPayable errored: VM error: revert. revert
The transaction has been reverted to the initial state. Note: The
called function should be payable if you send value and the value you
send should be less than your current balance. Debug the transaction
to get more information.

(tried debugging, but can't make sense of the assembly instructions).
Would be nice to know where am I going wrong, been stuck on this for quite a while now.
Thanks!
pragma solidity >=0.6.2 <0.8.0;

contract TestPayable {
    fallback() external payable { x = 1; y = msg.value; }
    receive() external payable { x = 2; y = msg.value; }
    uint public x;
    uint public y;
}

contract Caller {
    function callTestPayable(TestPayable test) public returns (bool) {
        require(address(test).send(2 ether));
        return true;
    }
    uint public fall;
    fallback() external payable {fall=msg.value;}
}


texts: Is it possible to send transactions to multiple recipients?

texts:
In other blockchain based platforms, it's possible to send transactions to multiple recipients. For instance, if I want to send 13 ETH to Alice and 7 ETH to Bob, Bitcoin has sendmany. Is it possible to accomplish this in one Ethereum transaction?

Or would I have to create a contract which forwards the ether?


texts: How to check that MyToken has been sent from one address to the other address?

texts:
What function that i should use? If you don't mind, please explain it in simple code.

Thanks


texts: Genesis block mismatch using a converted geth genesis file with parity

texts:
I've tried converting a geth genesis file to the parity format, in order to make a parity node join an already existing geth-backed private blockchain, but I'm getting a "Genesis block mismatch" error:

New peer 0 (protocol: 63, network: 42424242, difficulty: Some(11315973291), latest:4a8e…fcf2, genesis:96d0…b2e1, snapshot:None)
Peer 0 genesis hash mismatch (ours: 31cf…08ea, theirs: 96d0…b2e1)

And on the other side:

Adding p2p peer                          id=1e6033fe00282624 name=Parity/v1.6.8-beta-c...                                            addr=10.0.0.4:43516 peers=3
Ethereum peer connected                  id=1e6033fe00282624 conn=inbound name=Parity/v1.6.8-beta-c396229-20170608/x86_64-linux-gnu/rustc1.17.0
Ethereum handshake failed                id=1e6033fe00282624 conn=inbound err="Genesis block mismatch - 31cf7371d7c8d8ca (!= 96d001c8c6564893)"
Removing p2p peer                        id=1e6033fe00282624 conn=inbound duration=60.389ms  peers=2 req=true  err="disconnect requested"

The original geth genesis file is:

{
  "alloc": {
    "ad94486b5005418dbb46a77eb2fd0c8046bfb858": {
      "balance": "1000000000000000000000000000000"
    }
  },
  "config": {
    "homesteadBlock": 0,
    "chainId": 42424242,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "nonce": "0x0000000000000042",
  "difficulty": "0x6666",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
  "gasLimit": "0x4c4b40"
}

I manually converted this file into parity format (based on these examples https://github.com/5chdn/crossclient-chainspec):

{
    "name": "CrossClient",
    "dataDir": "CrossClient",
    "engine": {
        "Ethash": {
            "params": {
                "gasLimitBoundDivisor": "0x0400",
                "minimumDifficulty": "0x020000",
                "difficultyBoundDivisor": "0x0800",
                "durationLimit": "0x0d",
                "blockReward": "0x4563918244F40000",
                "registrar": "0x81a4b044831c4f12ba601adb9274516939e9b8a2",
                "homesteadTransition": 0,
                "eip150Transition": 0,
                "eip155Transition": 10,
                "eip160Transition": 10,
                "eip161abcTransition": 10,
                "eip161dTransition": 10
            }
        }
    },
    "params": {
        "accountStartNonce": "0x0",
        "maximumExtraDataSize": "0x20",
        "minGasLimit": "0x1388",
        "networkID" : "0x28757B2"
    },
    "genesis": {
        "seal": {
            "ethereum": {
                "nonce": "0x0000000000000042",
                "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
            }
        },
        "difficulty": "0x6666",
        "author": "0x0000000000000000000000000000000000000000",
        "timestamp": "0x00",
        "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
        "gasLimit": "0x4c4b40"
    },
    "accounts": {
        "ad94486b5005418dbb46a77eb2fd0c8046bfb858": { "balance": "1", "nonce": "0", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }
    }
}

Can anyone see what I did wrong?

Additionally, can anyone tell me exactly how the genesis hash is calculated?

Update
I forgot to mention that I've already tried https://github.com/keorn/parity-spec/ to convert between the two formats, but it requires the geth config to have a uint value for "eip150Block", while in my geth config I don't have a value for it so null is assumed (No fork).


texts: What's the relative advantage of using remix.ethereum.org over studio.ethereum.org?

texts: Studio and remix are two web-based IDE that are hosted at ethereum.org. What are the advantages of each? In which situation should they be used each?


texts: Truffle and Buidler are compiling to very different bytecodes despite having same compiler settings

texts:
Truffle is giving > 24kB and out of gas errors, but Buidler is not. I have checked the number of characters in the 'deployedBytecode' of the JSON:

Buidler 33k characters (so 16.5kB)
Truffle 55k characters (so 27.5kB)

I have the following compiler settings in both truffle config and buidler config:

compilers: {
    solc: {
      optimizer: {
        enabled: true,
        runs: 1
      },
      version: "0.6.6",
    },
  },

What's going on? I'm about to hand my code over for a formal audit. Truffle suggests I need to refactor to reduce file size, but buidler says I don't need to bother. I don't want to have my code audited only to have to refactor it later and hand it over to be audited again.

If you wish to try for yourself, the repo is here. It is the RealityCards contract that is relevant.


texts: Why isn't the DAO attack repeated, after the first proof that it works?

texts:
As of 18 June no hacker repeated the DAO attack, even if for a certain time (until the network is spammed and the recursion is stopped) the hack would work the same way the first attack worked.
What are the reasons that this does not happen?


texts:
I'd ike to know the date or block of the first transaction of an account that has more transactions than the Etherscan display limit, like this one for example: https://etherscan.io/address/0xb1690c08e213a35ed9bab7b318de14420fb57d8c

Any way to do that using geth and json rpc?

Thanks


texts: In what way does Sharding allocate transactions for each shard? state? or node selection?

texts:
In what way does Sharding allocate transactions for each shard?

I know that accounts are assigned to each shard based on prefix in the account's address and each shard processes the transactions related to that account.

Example)

shard1(0x00... ~ 0x01...), shard2(0x01... ~ 0x02...), ..., shard100

If not, I would appreciate it if you could let me know how ethereum Sharding is proposing this works.

Also, if you know how to allocate transactions in Sharding of other blockchain platforms, I would be grateful if you could let me know.


texts: Contract code size (and how to work around it?)

texts:
I'm writing some rather substantial Solidity smart-contracts, and believe I'm hitting the EIP170 24k bytecode size limit.  I've already

(a) factored my code into libraries

(b) today split my contract into two parts.

Nothing seems to be helping to get under the limit.  Heck, splitting into two contracts -increased- -severely- the code of one of the two resulting contracts -- much bigger than the original all-in-one contract.

Are there tools to help figure out where the code-bloat is coming from?  Other methods for splitting-up in order to reduce size?


texts: Can Ether be mined directly into a contract?

texts: For example, if I want a contract to automatically split the ether mined into different addresses instead of having a two step process whereby I first get the ether in an address in my wallet and then send it to a contract for further processing.


texts: Mist does not start anymore? Error: connect ECONNREFUSED

texts:
Most recently, I get the following error after executing mist:

CONNECT to IPC PATH: /home/santi/.ethereum/geth.ipc
CONNECT to IPC PATH: /home/santi/.ethereum/geth.ipc
NODECONNECTOR ERROR { [Error: connect ECONNREFUSED
/home/santi/.ethereum/geth.ipc]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '/home/santi/.ethereum/geth.ipc' }
Node type:  geth
Network:  main
Start node from /usr/share/mist/resources/node/geth/geth
Stopping nodes...
Starting geth node...
UNCAUGHT EXCEPTION { [Error: spawn EACCES] code: 'EACCES', errno:
'EACCES', syscall: 'spawn' }
Stopping nodes...

In my laptop works just executing mist without the need of executing
geth first... any ideas what I'm doing wrong?


texts: How to form the transactionObject in a metamask enforced async call?

texts:
Normally, for a contract call (i.e. something that does not update ethereum), I would simply do: var something = myContractObject.getSomething().

I've just started using metamask, and unfortunately, that breaks with the complaint that such calls are not asynchronous. Why? They've always returned synchronously for me! Is that because I've only used testrpc or a private network?

Anyway, if I must make such calls async', since I make many such calls, rather than write callbacks for every one of them, I'm trying to write a function to handle it all for me. Something like this:

callHandler (_transactionObject) {
  let value = undefined
  this.web3.eth.call( _transactionObject, function(err, result) {
    if (err) {
      console.log(err)
      return undefined
    } else {
      return result
    }
  })
}

That relies on the parameter _transactionObject. I've written a little function that tries forming that:

getTransactionObject ( _data ) {
  const account = this.account
  return { from: account, data: _data }
}

And here's how I call that function:

const data = myContractObject.getSomething.getData()
var transactionObject = getTransactionObject(data)

Then I simply try and replicate var something = myContractObject.getSomething(), by calling callHandler, i.e. var something = callHandler(transactionObject).

...but that's not working; it seems that myContractObject.getSomething.getData() (which I got from here: https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-methods), is not returning the right call data for the transactionObject. In which case, I'm a bit stuck - how do I get the call data I need and form the correct transactionObject?

ps. I realise there are other problems with that code, not least var something = callHandler(transactionObject) is not async', so the assignment to something needs wrapping in some async' handler....


texts: What are the differences between Monax/Hyperledger Burrow and Quorum?

texts:
Are there any significant differences between these protocols?
Thank you for answering.


texts: If Ethereum switches to POS, does that mean I can never mine coin if I just have a few Ethereum?

texts: If Ethereum switches to Proof-of-Stake, does that mean I can never mine it if I just have, let say, a few Ether? Does it mean the more Ethereum you have, the more chance you have to mine Ether?


texts: browser/demo01.sol:8:33: ParserError: Expected '{' but got 'return' function age() private view return (unit) ^----^

texts:
pragma solidity ^0.4.24;
//properties functions request
contract AttrFnDemo{
    uint private _age;
    string internal _name;
    int public _num;

    function age() private view return (unit)
    {
        return _age;
    }
    function age() internal return (string){
        return _name;
    }
    function age() private return (int){
        return _num;
    }
}


texts: Invalid Opcode Pushing to bytes32[] from transaction

texts:
I'm not sure why this doesn't work. I have the exact same pattern for addresses and it does fine.

bytes32[] public someStorage;

function addToStorage(bytes32 someData) {
  someStorage.push(someData);
}

Then using web3:

instance.addToStorage("Some Data", {from: web3.eth.accounts[0], gas:1000000})

I get a tx address but in testrpc console I see a matching Runtime Error: Invalid Opcode and it always consumes the max gas that I set.


texts: Persistent "deep transaction reorg" whilst syncing full geth node

texts:
Whilst syncing a new full node using the geth comand "geth --syncmode full", every other line after a few hundred blocks I see the following:

WARN [12-02|02:30:46] Skipping deep transaction reorg          depth=2048

This has continued all the way to ~1.6M blocks synced.

Terminal screenshot:

Is this a problem?  Is it a security issue?  Does it represent a 'bad' peer, a sybil attack, or something far more benign?

FYI, I'm using the latest geth version (Geth/v1.7.2-stable-1db4ecdc/linux-amd64/go1.9) on Ubuntu 17.10.


texts: I get msg.data as JSON. How can I parse it in my contract to create variables in my contract with given values?


texts: Is there any connection between Serenity Market and Ethereum 2.0 (codename Serenity)?

texts:
From what I gather, no... Simply an exchange that's named the same?
https://serenity.exchange/


texts: Etherscan Input bool is 1 or true or True

texts:
I want to execute a smart contract function that takes input bool.
Here for example makes the distinction that web3 uses javascript which doesn't consider 1 as true, but solidity does consider 1 as true.
So my question is, if a Write Function in Etherscan takes input bool, say I want to specify True, do I input 1 or  true or True?


texts: web3 v 1.0.0-beta.34 contract.methods.myMethod().send hangs

texts:
I am using web3 (installed from npm, version 1.0.0-beta.34) to write a nodejs script that should invoke the method update() defined in a contract I  deployed with Truffle on my private ethereum network.

I can succesfully invoke constant methods of the said contract, but when i try to call send on another method, the callback returns the tx hash but i cannot get the receipt, after a very long time waiting for the script to succeed (or fail) i get

  error Error: Failed to check for transaction receipt:
  {}

For reference here's my simple contract

pragma solidity ^0.4.17;

 contract MappingExample {
    mapping(address => uint) public balances;
    uint8 public test = 0;

    function getBalances() public view returns(uint){
            return balances[msg.sender];
    }

    function update() public {
            test = test + 1;
            balances[msg.sender] = test;
    }

    constructor() public {
            test = 0;
    }
 }

And here's the js code I wrote to interact with the contract

const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.HttpProvider('http://xxxx:8545'))

const contractAbi = [...]
const account1 = '0xaaaaaaaaaaaaaaaaaa'
const contractAddress = '0xcccccccccccccc'

const contractInstance = new web3.eth.Contract(contractAbi,
    contractAddress, {
      from: account1,
      gasPrice: '100000000000'
    })

web3.eth.personal.unlockAccount(account1, 'passphrase', 36000)
.then(response => {

    console.log('Account unlocked', response)

    contractInstance.methods.update()
      .send({ from: account1}, function (error, result) {
        console.log('Error', error)
        console.log('Result', result)

        // Now we get the balance
        contractInstance.methods.getBalances().call({ from: account1 },
        function (error, result) {
           console.log('Error', error)
           console.log('Result', result)
        })

      })
       .on('transactionHash', (hash) => {
        console.log('hash ' + hash)
       })
      .on('receipt', (receipt) => {
         console.log('receipt ' + receipt)
       })
       .on('confirmation', (confirmationNumber, receipt) => {
          console.log('confirmation ' + confirmationNumber + receipt)
       })
       .on('error', (error) => {
          console.log('error ' + error)
       })
   })

The output is

Account unlocked true
Error null
Result 0x64d057977bd27ad6248590fb245af3fa2409407da00ccda086dbc0c8994cafe7
hash 0x64d057977bd27ad6248590fb245af3fa2409407da00ccda086dbc0c8994cafe7
Error null
Result 0
// Here it hangs for a very long time and then prints:
error Error: Failed to check for transaction receipt:
{}

Where is the mistake?

More information:

Running Geth 1.8.7-stable on all nodes
The script is launched on my laptop (macOS)
The target node is a Geth 1.8.7 node on which i created some accounts using the personal api.
The contract address is taken from "truffle deploy --reset" output
The "sender" address is a test account i created (with Geth) on the node I am pointing web3 to.

UPDATE with more information

The network has 4 non mining nodes and 2 mining nodes
The web3 script is pointing at a non-mining node
It looks like transactions are just staying "pending" indefinetly. If I run eth.getBlock("pending", true).transactions I can  see all the transactions I tried.

UPDATE WITH PROGRESS
I was able to deploy my contract successfully and to make transactions against it  by running a new node on my laptop with the --mine flag on. It might be that geth (or the ethereum spec itself) requires at least two nodes actively mining on the network in order to correctly handle contract transactions, i've found some comments on the internet saying this but I cannot provide official confirmation yet .


texts: New Token Contract Disappears After Deployment

texts:
I'm attempting to deploy my version of the example token contract to the testnet.

This is how far I get:

The code compiles
The contract doesn't complain pre-deloyment
I see the contract deployment process appear in the Latest Transactions panel

These are the issues I'm seeing:

The contract deployment process doesn't make any progress
After about 1-2 minutes, the contract disappears entirely
My account does not get charged for the deployment

Other info:

On the first attempt I sent 2 ETH to the contract, and it failed. Now if I attempt to send any ETH to a new contract I see "It seems this transaction will fail..."
Now only sending 0 ETH apart from the fee will remove that warning

I've got Ethereum Wallet v0.8.9 and Geth v1.5.8-stable

What am I doing wrong?


texts: eth_sendRawTransaction:invalid argument 0: json: cannot unmarshal non-string into Go value of type hexutil.Bytes

texts:
I call the eth_sign to get signature of RawTransaction, then call eth_sendRawTransaction,but got the error

  "{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"invalid
  argument 0: json: cannot unmarshal non-string into Go value of type
  hexutil.Bytes"}}"

I have no idea in where it is wrong.

I use some libs of web3j,this is my method:

public JSONObject eth_sendRawTransaction(String contract, String from, String to, double amount, long gasLimit) throws Exception {
    walletpassphrase(from) ;

    JSONObject json = null;
    try {
        BigInteger nNonce = getNonce(from);

        String gasPrice = eth_gasPrice();
        BigInteger nGasPrice = Numeric.decodeQuantity(gasPrice);
        BigInteger nGasLimit = BigInteger.valueOf(gasLimit);

        BigInteger nAmount = Convert.toWei(Double.toString(amount), Convert.Unit.ETHER).toBigInteger();
        Function function = new Function(
                "transfer",
                Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(to),
                        new org.web3j.abi.datatypes.generated.Uint256(nAmount)),
                Collections.emptyList());
        String data = FunctionEncoder.encode(function);

        RawTransaction rawTransaction = RawTransaction.createTransaction(
                nNonce,
                nGasPrice,
                nGasLimit,
                contract,
                BigInteger.ZERO,
                data);
        byte[] encodedTransaction = TransactionEncoder.encode(rawTransaction);
        String encoded = Numeric.toHexString(encodedTransaction);
        String signature = eth_sign(from, encoded);
        String signed = encoded + Numeric.cleanHexPrefix(signature);

        String s = main("eth_sendRawTransaction", "[{"+
                " \"data\": \""+signed+"\""+
                "}]");

        json = JSONObject.fromObject(s);
        System.out.println("eth_sendRawTransaction - " + json);
    } catch (Throwable e) {
        e.printStackTrace();
    }

    lockAccount(from) ;

    return json;

}

I think that this code is wrong in below,but i don't know how to fix.

  String signed = encoded + Numeric.cleanHexPrefix(signature);


texts: Are newer solidity versions 'safer'? Should I update my existing code to use a newer version?

texts:
I have created a set of contracts that will shortly be undergoing an audit. It's a DeFi platform that is intended to hold real value.
The project began as a fork of a fairly old project, that uses Solidity version 0.5.13. I am still using this version. I am also using various older OpenZeppelin libraries (ERC721, ownable etc) that are compatible with this version.
Is it advisable to update my contracts, and the libraries, to use a more recent version of Solidity? If so, does it make sense to use the most recent, or perhaps a slightly less recent version- perhaps the late 0.6.x?
Of note: my code requires passing an array of strings as an argument, thus the current version of the contracts has pragma experimental enabled. Do more recent versions of Solidity allow for arrays of strings out of the box without needing to enable pragma experimental?


texts: Compatibility between ERC-1400 and ERC-1643

texts: How does a contract supporting both ERC-1400 and ERC-1643 should be written as their functions setDocument don't have the same arguments and their getDocument don't return the same types?


texts:
I am using Truffle and my contract is migrated fine and I am able to invoke necessary call from truffle console

The issue I have is how do I see the failure when a require condition is not met. I have this check: require(msg.sender == creator);

When making a call that fails the check how do I see a failure in the response? (the addr2 here is not the creator)

truffle(development)> instance.fundEscrow({from:addr2,value:web3.toWei(1,"ether")})
{ tx: '0x51e10...',
  receipt:
   { transactionHash: '0x51e10f9a...',
     transactionIndex: 0,
     blockHash: '0x9cd03...',
     blockNumber: 83,
     gasUsed: 21972,
     cumulativeGasUsed: 21972,
     contractAddress: null,
     logs: [],
     status: '0x00',
     logsBloom: '0x0000000000...' },
  logs: []
}


texts:
I was curious if metamask uses web3 for communication with eth node ? I tried google for it; showed bunch of other results but didn't precisely answered my question.
 Indepth answer on how metamask works in addition to my question would be just cherry on the top.
Thanks!


texts:
Here is my contract example.

pragma solidity ^0.4.18;
contract LocalEthereum {

    address public owner;
    event Created(bytes32 _tradeHash);
    function createEvent() onlyOwner external {
        Created(0x01);
    }
}

version one

import {default as contract} from 'truffle-contract';
import Web3 from 'web3';
const contractAbstraction = contract(abi);
contractAbstraction.setProvider(this.web3.currentProvider);
contractAbstraction.deployed().then(function(contractInstance) {

    }).catch(function(e) {
      console.log(e);
    })

version 2

const contractAbstraction = contract(abi);
contractAbstraction.setProvider(this.web3.currentProvider);
contractAbstraction.new().then(instance){}.catch(err){}

}

version 3

const contractAbstraction = web3.eth.contract(abi);
var contractInstance = contractAbstraction.at(address);

My first question is compared with code 1 and 2, if I am using the truffle framework to deploy the contract,  then I just need to contractAbstraction.deployed() for each call, so what is the use of new().

My assumption of new() will make a new instance of the contract, which initialize the contract, the owner address in the contract is the address of those who uses new().  But why do some examples I see  don't use new() at all?

Secondly, compared with code 1 and 3, what is the difference with them, I see different examples using the two, I assume they are the same?


texts: Why did sendRawTransaction lose some transactions although it returned those transactions' hash values?

texts: In a short time within 1 min, 5 transactions were submitted using sendRawTransaction of web3 and the 5 hash values of these txs had been got. But, only 2 transactions could be found in the ethereum private blockchain at last. Why did the ethereum network lose 3 transactions?


texts:
I am following this answer:

How do I set up a private ethereum network?

but my result of miner.start() will return null

Is it because my geth version is 1.6.6-stable?

Also welcome any beginner's guide to develop dApp.


texts: How to adjust "time slots" in Ethereum 2.0 (Sharding + PoS)?

texts:
In Ethereum 2.0 (Sharding and PoS), blocks are produced at a regular schedule, say once every t seconds.

What does this time slot depend on? The number of validators in the network who deposited Ether?
Is this time slot adjusted similar to the difficulty level of PoW (that is dependent on the total hashing power of the network)? Or it is a fixed value forever? If it is adjusted and is not fixed, is time slots duration dependent on the total deposited Ether in the network?

P.S. Regarding to the answer of Lauri Peltonen: Do you also understood how / why 12 seconds has been chosen / calculated? For example, why not 10 seconds? or any other values? Meanwhile, I know that in Ethereum 2.0 there is no PoW and thus hashing power of the network does not matter, but also I said maybe as PoW difficulty is calculated based on hashing power of the network, here, time slot duration should be logically calculated based on some parameters in the network. What are those parameters?


texts:
2 part question.

What are some blockchain-based messaging apps? What are their benefits?
Could an NFT based messaging app be built? If so what unique properties would it have?


texts: Can I figure out when transaction was submitted?

texts:
can I find out when a transaction was submitted to blockchain?
Imagine transaction was sumitted at 10:00 AM. It was added to a block at 10:20. Can I find time of the transaction submission (10:00 AM) later?


texts: web3 - Error when calling sendTransaction with @truffle/contract on Ropsten Infura

texts:
My smart contract is already deployed on Ropsten TestNet provided by Infura at 0x63865E0F065C7b865e1a2EE4d99C383A414Bec22 address.
I want to sendTransaction using NodeJS(v.10.16.1) + Web3(v.1.2.6) + @truffle/contract(v.4.1.11). This is my NodeJS code -

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var session = require('express-session');

var Web3            = require('web3');
var contract        = require("@truffle/contract");
var path            = require('path');
var MyContractJSON  = require(path.join(__dirname, 'build/contracts/contract.json'));

var provider    = new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/PROJECT_ID");

var MyContract = contract(MyContractJSON);
MyContract.setProvider(provider);
const contract_address = "0x63865E0F065C7b865e1a2EE4d99C383A414Bec22";

app.post("/register", function(req, res){
    var newUser = req.body.username;
    var account = req.body.account;
    req.session.currentUser = account;

    MyContract.at(contract_address).then(function(instance) {

        return instance.registerUser.sendTransaction(newUser, {from: account});

    }).then(function(result) {
        console.log(result);

        res.render("dashboard", {name: newUser, account: account});

    }).catch(function(error) {
        console.log(error);
        res.redirect("/");
    });
});

I am getting this ERROR on sendTransaction -

Error: Returned error: The method eth_sendTransaction does not exist/is not available\n    at Object.ErrorResponse (...\\node_modules\\web3-core-helpers\\src\\errors.js:29:16)\n    at ...\\node_modules\\web3-core-requestmanager\\src\\index.js:140:36\n    at XMLHttpRequest.request.onreadystatechange (...\\node_modules\\web3\\node_modules\\web3-providers-http\\src\\index.js:110:13)\n    at XMLHttpRequestEventTarget.dispatchEvent (...\\node_modules\\xhr2-cookies\\dist\\xml-http-request-event-target.js:34:22)\n    at XMLHttpRequest._setReadyState ...\\node_modules\\xhr2-cookies\\dist\\xml-http-request.js:208:14)\n    at XMLHttpRequest._onHttpResponseEnd (...\\node_modules\\xhr2-cookies\\dist\\xml-http-request.js:318:14)\n    at IncomingMessage.<anonymous> (...\\node_modules\\xhr2-cookies\\dist\\xml-http-request.js:289:61)\n    at IncomingMessage.emit (events.js:203:15)\n    at endReadableNT (_stream_readable.js:1145:12)\n    at process._tickCallback (internal/process/next_tick.js:63:19)'

I am using Metamask(v.7.7.8) and managing the account address via express-session. I know that Infura does not support sendTransaction but @truffle/contract does not support sendRawTransaction too.
Please help me find an easier solution with @truffle/contract.


texts: Get the first transaction from an account

texts:
I'm building a Dapp where, whenever a user creates an account, a contract is immediately created from his account. However, I need a way to quickly find the contract's address in the future.

The alternative I've been using is just to have a mongoDB storage per user, updating the contractAddress field there whenever the contract is mined. Ideally though, I'd like to avoid centralised storage. Is there a way to do this?


texts: What happens when an Oracle becomes unavailable?

texts: If all contracts in the chain must be verifiable by all nodes at all the time, what happens when an Oracle service goes down, e.g. because the company supporting it goes bankrupt?


texts:
Anybody used WalletConnect in react-native? How do you genreate a topic and key for the URI?
From the docs:

Android has the easiest integration as it's operating system is designed to handle multiple applications subscribing to the same deep linking schema. Hence you will only need to register to the wc: schema that is defined per the WalletConnect URI standard.
# Example wc:00e46b69-d0cc-4b3e-b6a2-cee442f97188@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=91303dedf64285cbbaf9120f6e9d160a5c8aa3deb67017a3874cd272323f48ae

Where is this link coming from?


texts: While it would not be possible to implement everything, could it be useful for domain specific applications to have a lisp based contract language that implements a certain subset of features? Probably couldn't have call/cc or TCO, but It would be nice to in theory write contracts capable of writing other contracts. Why has LLL been abandoned? Looking around I don't see any way of using it with geth. Serpent compiles to LLL supposedly so there should be some kind of interface.


texts: Recover all the account under Mnemonic using ethers.js

texts:
I am new using ethers.js
const { Wallet } = require('ethers');
const wallet = Wallet.fromMnemonic('one two three four ...');

I want to use that code to recover all the accounts from that Mnemonic. Maybe it is something that I do not understand quite well but it is just retrieving the first account for that Mnemonic.
How do I recover all the accounts?


texts: How to create a private ethereum network

texts:
I want to understand how to create a private blockchain using ethereum and create a minable coin. Also, I want to know if I can modify the consensus algorithm that runs on every node?

There are another two questions:

Can a private network cryptocurrency be sold or integrated with exchanges for trading?
Up to what level can I customize the ethereum blockchain and create my own, like TRON did?


texts: Smartcontract: Warning! contract execution experienced an error and gets [Reverted]

texts:
I have sent ropsten ETH to my newly created contract address (still on test mode on the Ropsten Test net). Unfortunately it kept "failing". The blockchain reports: Warning! Error encountered during contract execution [Reverted]

Please see my contract address and transaction failures here: https://ropsten.etherscan.io/address/0xe7a6fbf8a93e6c879907e0404881840a05978745

I have employed myetherwallet interaction functions, interacted and queried my smart contract for the totalSupply, CurrentDistribPublicSupply, OwnerDistribSupply_ and others. Everything seems to be in order and tallies. So am super confused and quite worried. Please someone help and explain what I am doing wrongly? All sort of help and correction would be appreciated. Thank you.


texts:
Which variables types are accepted by a constructor in Solidity? In particular, is it possible to pass an actual contract as an constructor input? For example:

contract ContractA {
    constructor (uint _id) public {}
}

contract ContractB {

    ContractA ContractAReal;

    constructor (ContractA _metaContractA) public {
        ContractAReal = _metaContractA;
    }
}


texts: The difference between web3.version.network and web3.version.ethereum

texts:
The return values of the commands web3.version.network and web3.version.ethereum are:

web3.version.network = "The network protocol version"

web3.version.ethereum = "The etherum protocol version."

I would like to know the difference between network protocol version and ethereum protocol version and what situations I use in practice.


texts: Are there plans to self-fund/self-govern the development of Ethereum software?

texts:
Are there any plans to get this project self-funded and self-governanced? Maybe some schemes as in DASH? They have developed an incentivisation model of network participants by dividing block reward into 3 parts.

1st part (45%) goes to miners, 2nd part (45%) goes to full-nodes (masternode in DASH), and 3rd (10%) goes to the budget, which is to be spent among different proposals (including core team reward) based on poll results.


texts: dynamic Node Membership management in Ethereum Blockchain

texts:
I am a new bee in Ethereum Blockchain in implementing this as a potential solution for decentralized application. In the process of identifying the solution i have came across a problem where what if i want to dynamically manage Nodes creation/deletion in an existing/functioning Blockchain.

For example : If i have a private blockchain which was initially created with 5 nodes running and communicating with each other. Each node has a static-nodes file with (enode) information for peering with each other. Now if i want to boot out one of the node out of the blockchain network i would update the static-node kicking the odd node out of the enode list and replicate it on each nodes. This would potentially kick out the deleted node out of the Blockchain network.

What if i wan to manage this deletion of nodes without touching each of the node (assuming nodes are not in our capacity to implement the changes). Is there a solution to add/delete nodes dynamically without making changes on each node? also without resetting Blockchain data (no reset of genesis block).

If anyone having any doubts on my question please write back to me.

Any help is highly appreciated.

Thanks.


texts: Months ago the idea of a "Global Name Registrar Contract" was thrown around. There is code to deploy one out there, but is there an official one that official clients (geth / Mist / etc) will use by default yet?


texts: How to handle dates in Solidity and web3

texts: Let's say I want to store a birth date in in a solidity contract. Which data type do I have to use in the solidity contract? How do I write the date with web3 to the contract and how do I retrieve it from the contract in a human readable format?


texts:
When I am trying to call a Write function of the smart contract deployed on the rinkeby network using truffle, I get error Invalid JSON RPC response: "" .

Can you please help with what is causing this issue and how to resolve it.
It is a bit urgent. Thanks.

Content of my truffle.js file is:

const HDWalletProvider = require("truffle-hdwallet-provider-privkey");
const privKey = "my-address's private key from which i want to deploy it";

module.exports = {
 networks: {
     development: {
        host: "localhost",
        port: 8545,
        network_id: "*" // Match any network id
     },
     rinkeby: {
         provider: function() {
              return new HDWalletProvider(privKey, "https://rinkeby.infura.io/mytokenid");
         },
         network_id: 4,
         gas: 7003605,
         gasPrice: 21,

    }
  }
};


texts: Can I somehow get the public key of an ethereum account knowing just the corresponding ethereum address (e.g. 0x54dbb737eac5007103e729e9ab7ce64a6850a310)?


texts: What happens when crypto is sent to my offline desktop wallet?

texts: I'm planning a switch to a desktop wallet for my crypto accounts.  My first choice is Exodus (exodus.io).  I understand that because it's a desktop wallet, the machine it's running on obviously needs to be powered, and the application needs to be running.  My concern is what happens to transfers to my wallet when it is offline?  Is the transaction held in the cloud network, until my wallet becomes available online, or do I need to plan to run it on a machine that is always active?


texts: Contract to interact with another contract written in vyper

texts:
I am trying to interact with another contract (Curve finance) via my own contract. (eg get prices, to execute trades , etc)
The thing is , the contract is written in Vyper. https://etherscan.io/address/0xA5407eAE9Ba41422680e2e00537571bcC53efBfD#readContract
I am unable to import https://github.com/curvefi/curve-contract/blob/master/contracts/pools/susd/StableSwapSUSD.vy
to my remix project as it would error when compile - ParserError: Expected pragma import directive or contract/interface/library/struct/enum/definition.
I would like to ask how to create a contract instance for contracts written in vyper. I am able to get the ABI from etherscan, but I do not know how to proceed further from here.
Thank you in advance.


texts: Does Solidity embed only the library functions that are consumed?

texts:
Suppose you have a library called MyAwesomeMathLib.sol, which contains only pure internal functions, and a contract Consumer.sol that consumes the library:
pragma solidity ^0.8.0;

import "./MyAwesomeMathLib.sol";

contract Consumer {
    function doAvg(uint256 x, uint256 y) external pure returns (uint256 result) {
        result = MyAwesomeMathLib.avg(x, y);
    }
}

Further suppose that there is more than just the avg function in the MyAwesomeMathLib.sol library. When compiling Consumer.sol, will Solidity include only the bytecode relevant to the consumer, or will it include the library as a whole?


texts: How to connect web3js to mainnet or testnet?

texts:
It might be a very basic question. But here's what I want to achieve:

I want to make a web app which interacts with a contract on testnet/mainnet.
I can see in the documentation that you have to provide the local port to web3js to connect to a local running ethereum instance/simulation:

web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

But I want to connect it to the testnet or mainnet. Is it possible to do that without actually hosting a real node(test or main)?

And if the only way to do this is by running an actual node on local computer, then what is the best way to connect to it with web3? I read somewhere that RPC is not that secure.

Please guide me on these noobie questions.

Thanks in advance!


texts: How can I Retrieve Wrong Transfer of Erc20 tokens

texts: I mistakenly Transfer an ERC20 token to a scammer Like(I created the Token) then I saw the Write function on etherscan.io. Is it possible to transfer it back to my wallet or not and if it is possible how can I do it?


texts:
If a function has no loops, should the gas usage be identical every time it's called with the same variables?

Should the gas used be the same on testrpc as it is on mainnet?


texts:
After long days I have finally gotten ethminer and Parity to talk to each other!

However when I ask them to, Parity returns: Cannot give work package - no author is configured. Use --author to configure!

ethminer says:  ethminer  Getting work package...
JSON-RPC problem. Probably couldn't connect. Retrying in 1...

What am I missing?


texts: If gas is refunded, is it required to call?

texts:
Suppose a smart contract external function uses very much gas, but refunds (with .transfer()) the used gas to the caller.
Question: Can it be called with a small amount of gas despite it uses much?
Moreover, can such a function be called by a user having zero on his account? (The gas is refunded to him, so I am unsure.)


texts: web3.eth.filter({fromBlock:0, toBlock: 'latest', address: account}) not working?

texts:
My goal here is to list all transaction from an given account, without any success yet.

I wonder why I always have an empty result when I'm using this web3.eth.filter. I know there is a valid solution: Listing transactions in a private blockchain, but going through all blocks each time takes a considerable amount of time, so it is not really responsive on the user side.

So I wonder what is wrong with my code:

web3.eth.defaultAccount = web3.eth.accounts[0];
var account = web3.eth.accounts[0];

console.log('Account: '+ account);

var filter = web3.eth.filter({fromBlock:0, toBlock: 'latest', address: account});
filter.get(function(error, result) {
   if(!error) {
      for (i=0; i<result.length; ++i) {
        var block = web3.eth.getBlock(i, true);
        block.transactions.forEach( function(e) {

            console.log("  tx hash          : " + e.hash + "\n"
             + "   nonce           : " + e.nonce + "\n"
             + "   blockHash       : " + e.blockHash + "\n"
             + "   blockNumber     : " + e.blockNumber + "\n"
             + "   transactionIndex: " + e.transactionIndex + "\n"
             + "   from            : " + e.from + "\n"
             + "   to              : " + e.to + "\n"
             + "   value           : " + e.value + "\n"
             + "   time            : " + block.timestamp + " " + new Date(block.timestamp * 1000).toGMTString() + "\n"
             + "   gasPrice        : " + e.gasPrice + "\n"
             + "   gas             : " + e.gas + "\n"
             + "   input           : " + web3.toAscii(e.input))+"\n";

      })
  }
   }
   else {
      console.log('Error: '+error);
   }
});

I also tried with filter.watch, but the results remains the same: results is still empty.

Thanks


texts: Subscribing to new blocks doesn´t work [ROPSTEN]

texts:
I'm trying to subscribe to newBlockHeaders on the ropsten network, but it does not seem to work. The following code works for mainnet but not ropsten. Any ideas?
const Web3 = require('web3')
const webSocketProvider = new Web3.providers.WebsocketProvider(
  'wss://ropsten.infura.io/ws/v3/<MY PROJECT ID>'
)
const web3 = new Web3(webSocketProvider)

async function notify() {
  var subscription = web3.eth
    .subscribe('newBlockHeaders', async function (error, result) {
      if (!error) {
        console.log(result)
        return
      }
      console.error(error)
    })
    .on('connected', function (subscriptionId) {
      console.log('Connected!')
    })
    .on('error', console.error)
}

notify()


texts: invalid opcode while getting an element from a string of array

texts:
I am having some problems executing the final function of this contract (getmsg)
this  is the code:
        struct req{
            uint yes;
        }
        struct fri{
            uint yes;
            string [] messages;
        }
        struct user{
        bool acceptReq;
        uint nreq;
        uint nfri;

        address[] requests;
        address[] friends;
        mapping(address  => req)  _req;
        mapping(address  => fri)  _fri;
        }
        string bigg;
        mapping(address  => user)  _users;
            function sendreq(address friend) public returns(string memory){
            _users[friend]._req[msg.sender].yes=0;
        return "this function has been executed properly";
    }
        function acceptReq(address friend) public returns (string memory){
        if(_users[msg.sender]._req[friend].yes== 0){
            _users[msg.sender]._fri[friend].yes=0;
            bigg="request accepted";
        }

        return bigg;

    }
    function sendmsg(address friend, string memory _msg) public returns (string memory){
        if(_users[msg.sender]._fri[friend].yes==0){
            _users[msg.sender]._fri[friend].messages.push(_msg);
        }
        return "message sent properly";
    }
    function getmsg(address friend, uint index) public view returns (string memory){
      return  _users[msg.sender]._fri[friend].messages[index];
    }

the problem that I am facing is that when I execute the last function I get an invalid opcode error, can you guys/girls find the error?
(quick tip : before executing "getmsg" you have to execute "sendreq" , "acceptreq" and "sendmsg")
update 1: if I change the "messages" array inside the "fri" struct to a simple string (not array of strings) everything works fine so the problem is somewhere here
_users[msg.sender]._fri[friend].messages.push(_msg);

or here
  return  _users[msg.sender]._fri[friend].messages[index];


texts: How do I add value to an erc20 token already deployed?

texts:
The contract is 0x1b016Ac4De0996b1f59EaB9c54A083aF496C811D.

For now my token shows no value. I would like each token to start from a value of 0.0001 Eth.

Thanks


texts: Is there a table detailing all Ethereum protocol versions and which hard forks they correspond to?

texts:
Ethereum nodes have a protocol version parameter (https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.protocol_version).
Is there a good source for Ethereum protocol versions and the hard forks they correspond to across public networks?


texts: Why can't I kill my contract on my private blockchain?

texts:
Deployed to my private net, can call the contract, but can't kill:

> greeter.greet()
"Hello World again."
> greeterSource
"contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }"
> greeter.kill()
invalid address
    at web3.js:3887:15
    at web3.js:3713:20
    at web3.js:4939:28
    at web3.js:4938:12
    at web3.js:4964:18
    at web3.js:4989:23
    at web3.js:4055:16
    at web3.js:4141:16
    at <anonymous>:1:1

Don't think kill needs an address, does it?


texts: web3 - new BigNumber() not a base 16 number when calling a contract constant function

texts:
I am struggling with a simple hello world contract:

Contract:

pragma solidity ^0.4.4;

contract Greeter {

    function Greeter() {}

    function sayHello() constant returns(string) {
        return "hello";
    }
}

web3 - Javascript code:

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

var contractArray = JSON.parse('{"contract_name": "Greeter","abi": [{"constant": false,"inputs": [],"name": "sayHello","outputs": [{"name": "","type": "string"}],"payable": false,"type": "function"},{"inputs": [],"payable": false,"type": "constructor"}],"unlinked_binary": "0x6060604052341561000c57fe5b5b5b5b6101118061001e6000396000f300606060405263ffffffff60e060020a600035041663ef5fb05b81146020575bfe5b3415602757fe5b602d60a9565b6040805160208082528351818301528351919283929083019185019080838382156070575b805182526020831115607057601f1990920191602091820191016052565b505050905090810190601f168015609b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60af60d3565b50604080518082019091526005815260d860020a6468656c6c6f0260208201525b90565b604080516020810190915260008152905600a165627a7a723058205c8157cef185e2881f9f3c49092242ef4418bb30363100e00c373e157ebb6a540029","networks": {"1496042639874": {"events": {},"links": {},"address": "0xc90f7594a02ecc8fe27dad58023537da569ebbc6","updated_at": 1496042652979}},"schema_version": "0.0.5","updated_at": 1496042652979}');

var MyContract = web3.eth.contract(contractArray.abi);
var contractAddress = '0x95c9aa274cc63ec2a0b52f1b19e0e67c3d059194';
var contractInstance = MyContract.at(contractAddress);

var result = contractInstance.sayHello.call();
console.log(result);

The call contractInstance.sayHello.call(); ends up throwing this error:

bignumber.js:1190 Uncaught Error: new BigNumber() not a base 16 number:
    at raise (http://localhost:3000/bower_components/web3/dist/web3.js:14728:25)
    at http://localhost:3000/bower_components/web3/dist/web3.js:14716:33
    at new BigNumber (http://localhost:3000/bower_components/web3/dist/web3.js:13750:28)
    at SolidityTypeString.formatOutputString [as _outputFormatter] (http://localhost:3000/bower_components/web3/dist/web3.js:1110:19)
    at http://localhost:3000/bower_components/web3/dist/web3.js:1634:25
    at SolidityTypeString.SolidityType.decode (http://localhost:3000/bower_components/web3/dist/web3.js:1635:11)
    at http://localhost:3000/bower_components/web3/dist/web3.js:826:29
    at Array.map (native)
    at SolidityCoder.decodeParams (http://localhost:3000/bower_components/web3/dist/web3.js:825:26)
    at SolidityFunction.unpackOutput (http://localhost:3000/bower_components/web3/dist/web3.js:4064:24)

UPDATE:

I am seeing a POST to my testrpc instance (http://localhost:8545/) with this payload:

{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"0x95c9aa274cc63ec2a0b52f1b19e0e67c3d059194","data":"0xef5fb05b"},"latest"]}

This is the result of the call:

{"id":1,"jsonrpc":"2.0","result":"0x"}


texts:
I'm trying to create an android Dapp by using the web3j library. I'm using connection to a local private Ethereum blockchain. When I'm trying to display the Client version it returns null.
This is the code:

 static public Web3j web3j = null;
 static String clientUrl = "http://192.168.1.33:8501";
 Web3ClientVersion client = new Web3ClientVersion();
 web3j = Web3jFactory.build(new HttpService(clientUrl));
       try {
        client = web3j.web3ClientVersion()
                 .sendAsync()
                 .get();

    }  catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
 Log.e("client info: ", "Client version:  " + client.getWeb3ClientVersion()
 + "\n");


texts: How can I accept already deployed ERC20 token in my staking contract

texts:
Got this question, I have an ERC20 staking contract (it will be deployed on Binance smart chain), that can accept itself to eventually mint itself, but I want to accept other, already deployed (on BSC as well) ERC20 token.
Standard staking/farming logic, lock X to farm Y, but it's a bit puzzling, how can i do that? Is there any ressource or example project that could be useful for my case?
Thanks.


texts: How to use Callbacks with web3 and reactjs?

texts:
I have been having trouble with callbacks in reactjs with web3.  In the code below my alert function is properly printing the number of players returned by my contract but otherFuction is not being called and setState is not changing the value printed in my paragraph.

class PracticeComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {players: ""};
  }

  componentWillMount(){

    simpleContract.methods.getPlayerNumber().call(function(error, result){
      alert(result);
      this.otherFunction(result);
    });

  }

  otherFunction(value){
    this.setState({
      players:value
    });
  }

  render() {
    return (

 {this.state.players}

    );
}

In previous attempts at a solution I have appended
    simpleContract.methods.getPlayerNumber().call()
with
    .then(this.otherfunction)
but have not had luck.

Any thoughts?  Any pointers?


texts:
I understand IPFS is public by design but can a record be placed in IPFS which is accessible only by the owners? Or accessible and readable (but excluding encryption solutions).

Edit -
This site has many references to IPFS which were not put on hold - eg How long does Infura store a file on IPFS?


texts: How to prove data you input is what an API call returned without using third-party service?

texts:
I know of Oraclize. As discussed in this answer How does Oraclize handle the TLSnotary secret? by Jeff Coleman there are disadvantages, and he suggests using TLSNotary oneself is safer than trusting Oraclize.

I need to fetch data from third-party API's to get private data with a private API key. It's not public data like ETH price where I can use a network of oracles to fetch this for me (like MakerDAO).

I'm wondering how you prove the information you're inputting is not altered since you received it. Oraclize uses TLSNotary, does anybody have any idea how that actually works/how to implement? I went to https://tlsnotary.org/ but don't see an automated service one can use (there is a browser extension).

If not TLSNotary, has anybody heard/used a different method to prove the data is not corrupted? Thanks for any help or ideas!


texts:
I'm tinkering with web3j and most of the things that I want to do succeed, however I seem to not be able to listen to events.

I've extended the ballot.sol contract you get with remix by adding an event VoteEnded, which is fired when a call is made to winningProposal and that works in the Remix JavaScript VM.

...
event VoteEnded();
...

function winningProposal() constant returns (uint8 winningProposal) {
    uint256 winningVoteCount = 0;
    for (uint8 proposal = 0; proposal < proposals.length; proposal++)
        if (proposals[proposal].voteCount > winningVoteCount) {
            winningVoteCount = proposals[proposal].voteCount;
            winningProposal = proposal;
        }
    VoteEnded();
}
...

I am able to deploy this contract and vote etc. in Web3j. Then I added a filter to listen to VoteEnded. I did it like:

    EthFilter filter = new EthFilter(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST, contract.getContractAddress());
    web3.ethLogObservable(filter).subscribe(new Action1<Log>() {
        @Override
        public void call(Log log) {
            System.out.println("log.toString(): " +  log.toString());
        }
    });

Which I found here: A problem with filters and events (web3j/TestRPC). SOS! ;)

However this doesn't print anything at all.

What am I doing wrong?


texts: Node Discovery Protocol - Node Table entries

texts:
I am currently trying to understand the node discovery protocol in ethereum. I found a few docs, where one of it is: https://github.com/ethereum/devp2p/blob/master/discv4.md

It says, that the distance between node is determined the following way

distance(n₁, n₂) = keccak256(n₁) XOR keccak256(n₂)

where n is the node ID.

Next, the information about neighbors is stored in a routing table consisting of 'k-buckets'.

What I don't understand is the following sentence:

For each 0 ≤ i < 256, every node keeps a k-bucket for nodes of distance between 2^i and 2^(i+1) from itself.

Let's say we have n1 = 0x80 and n2 = 0xF0. To keep it simple, we don't hash but use just the id. So we get the following distance: d = 0x70. The MSB differs now. In which bucket do I store the information now?


texts: Does ethereum generate any event whenever a new block is mined on the chain which can trigger a daemon process(lets say java code)?


texts: What should happen if I push a value into array and the function fail afterwards?

texts:
What should happen when I modify an array, afterwards in the same execution the function fails?

Should I expect the pushed value to be presented or does it get deleted?

for example:

contract MyToken is ERC721Token("My Token", "MYTKN"), Ownable {

    struct TokenInfo {
       // ...
    }

    TokenInfo[] public tokens;

    // ...

    function mint(string userId) public payable {

        uint256 tokenId = tokens.push(newToken) - 1;
        string tokenUri = concat(BASE_URI, tokenId);

        // >>>>>>>>> Maybe function fails here <<<<<<<<

        // ...

        _mint(msg.sender, tokenId);
        _setTokenURI(tokenId, tokenUri);

        // >>>>>>>>> Maybe function fails here <<<<<<<<
    }
}


texts: Is it possible to display numbers as hex in Remix?

texts:
I'm using a fixed-point math library that works with binary numbers, so values like 0x10000000000000000 are assumed to be 1.
I implemented a function that raises a given number to a given power. Raising 0x10000000000000000 to the power of 2 yields the same number:

I would prefer the result to show up as 0x10000000000000000 rather than 18446744073709551616, the latter being of course the former converted to decimal. Can I make Remix display numbers as hex?
My function:
function doPow(int128 x, uint256 y) external pure returns (int128) {
    return ABDKMath64x64.pow(x, y);
}


texts: Error on WebSocket connection to Infura Ropsten (broken close frame)

texts:
I am trying to connect to Ropsten with Web3js (1.0) via Infura using their WebSocket provider but I am getting the following error:

WebSocket connection to 'wss://ropsten.infura.io/ws' failed: Received a broken close frame containing a reserved status code.

This error shows up when I try to invoke a function from a contract using the send() method from Web3js. No issues arise at the time of creating my web3 instance, which by the way I create as follows:

web3 = new Web3(new Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws"))

Since the error I am getting says something related to a closed frame I tried something I found here regarding the clientConfig frame size with no success:

web3 = new Web3(new Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws", {
  clientConfig: {
    maxReceivedFrameSize: 100000000,
    maxReceivedMessageSize: 100000000,
  }
}))

I have also seen some other threads (e.g. here, here, here) related to WebSocket connection errors to Infura but none of them seem to be dealing with the same problem.

Thanks in advance!


texts: Using TORUS how i can sign a raw transaction?

texts: I am using TORUS wallet to make transactions over Quorum network. The requirement is to make a private transaction, for which we need to sign a raw transaction. TORUS does not allow to sign a transaction for security purposes. Is there any way to sign a raw transaction with TORUS wallet?


texts:
When I set an attribute to private it's not accessible from outside, but everyone who runs a node can still see it.

Someone told me to use encryption to hide attribute values, but how should this work, would not everyone also see than the key I used to encrypt my data? Is there a default way to handle this in Solidity?


texts:
i'm trying to access a dictionary within a list and cannot seem to get my for loop to get the key, then the value...

i've place an image herein so that its easy for me to explain.

so you can see, i would like to navigate to currency = AUD and assign the balance value to a variable, call it aud_balance =

for curr in result_bal_qrp:
   for k in curr:
      if curr[k] == 'AUD':

I cannot seem to get the key AUD... so im officially stuck.

I've tried to search for dictionary inside of lists etc but no examples of my problem, or maybe ive understood my problem wrong (highly likely)

Any help is appreciated.


texts: Unlocking account at startup immediately uses one attempt at passphrase

texts:
Whenever I start the geth client:

geth --unlock

the console gets populated with a couple of messages I0614 ....
Then the phrase Unlocking account 0 | Attempt 1/3 appears followed by more I06014... stuff, immediately on the same line like the passphrase request. It apparently considers tha startup messages as passphrase attemt, because then only comes the second try Phassphrase  |  Attempt 2/3, where I can actually start typing.

How can I prevent that?


texts: How to pass struct mappings to solidity functions?

texts:
I have two mappings (uint => customStruct) called listA and listB.  I want to run both through a single function to perform operations on the contents.

How do I pass this type into a function so that I can call someFunction(listA) and someFunction(listB)?

I get errors like Type is required to live outside storage.


texts: What's the difference between a solidity contract and an OOP class?

texts:
I learned that solidity contracts and OOP (object-oriented programming) classes, such as those in Java, are similar in many aspects. They can have constructors, class methods with public/private usage, and variable declaration/initialization. Also, they can be instantiated.

Those are some similarities and maybe I got something wrong, but I am very eager to know the differences between Solidity contracts and classes in OOP.


texts: Ethereum wallet address creation limit and ether storage limit/capacity per address

texts:
I am new to Ethereum.

I would like to know

How many addresses can you create in an Ethereum wallet (limit)?
Meaning is it 1K, 10K or 100K addressees you can create in a Ethereum wallet
What is the maximum number of ethers can an Ethereum wallet address
hold?
Meaning, the total number ether per wallet address is it 1 million, 2
million or 10 million etc.

I am sure there's limit to both addresses that one can generated and the maximum number of ethers an address can hold.

I searched online and didn't find an answer. I would appreciate a detailed answer.


texts: Computing the Uniswap V3 pair price from Q64.96 number

texts:
I am trying to compute a Uniswap v3 pool prize.
I can get the square root price of Q64.96 number as uint160 (e.g., 1234217676608908277512433764 - value of DAI/ETH pool (price at that time around 1 ETH for 4090 DAI)).
This can be retrieved via IUniswapV3PoolState.slot0()
As the function docstring says: "sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value"
How can I convert this number to uint256?
The calculated price should suggest the value of 1 ETH for 4090 DAI
Is there any other way of getting the Uniswap V3 pair price?
The answer would preferably be in solidity, but other answers are also acceptable.
Unsuccessful attempt
I tried squaring the number 1234217676608908277512433764 and then shifting it by 96, but the result was 1.922666416729829e+25 which doesn't seem too be correct.
(1234217676608908277512433764^2) >> 96 = 1.922666416729829e+25


texts:
I have a function that is called with some data - "SOMETHING".
function checker(address _from, uint _value, bytes calldata _data) external{
    //HOW to check if _data contains "SOMETHING"?
}

I have already tried:
if(string(_data) == ("SOMETHING")){...};
if(string(_data) == ("0x534f4d455448494e470a")){...}; // SOMETHING in hex
if(_data == 0x534f4d455448494e470a){...}
if(_data == hex"SOMETHING"){...}
if(_data == hex"534f4d455448494e470a"){...}

but it always says
Operator == not compatible with types string calldata and literal_string

in some form or the other...
How can I compare the calldata with a String value?
How to convert calldata to String correctly?
How to check if the calldata contains some String value?


texts: I am building an application that needs to verify the validity of ENS names as given by a resolver. Can resolvers attach a short proof to cryptographically guarantee that a given ENS name does indeed map to the corresponding Ethereum address?


texts: what is the difference between .json files and .metadata.json files in the artifacts folder in remix?

texts:
From here, I have read that:

artifacts saves the ABI, binary of contract and other info related to
the contract.

In Remix when I open the artifacts folder I see a .json and a .metadata.json file. What is the difference between these two files and what purpose does each serve?


texts:
I just started to learn about blockchain and I have a question related with ERC20 and ERC721.
In ERC20 we will set up the totalSupply of our token to X, so if I understand correctly the token value fluctuates depending on the number of sales and the number of token holders in DEX.
On the other hand, in ERC721 the totalSupply is set at each NFT level. Only when a transaction on a NFT is processed, a % of fee would be distributed to the development team. Or is there another way?
Are my understanding correct?
Thanks


texts: How to design a provably fair dyanamic between a central server and smart contract

texts:
I'm looking for a good design pattern that involves a central server but (hopefully) leverages the blockchain for provable fairness.

Let's say I intend to build a system that generates math problems, such as: 2x + 5 = z, which always include at least one variable element (in this case, x), and always produce some solution (z).

Note: This is an over-simplified example. In reality the problems are much harder, and trivial to compute going forwards (knowing x, finding z), but difficult to do in reverse (knowing z, finding x).

Performing the storage and generation of these problems in a smart contract would be prohibitively expensive, so instead a central server is to be used.
Given that this is the case, what is the best way to ensure a player can:

a) trust that the answer revealed by the server at the end is the right one, and

b) trust that their success will be honored, should they find the correct answer.

My current intention is to have the central server submit a hash of the random input it uses to generate the problem (x), and a hash of the problem's subsequent solution (z), to the smart contract, before a player begins. For example, if the server picks x = 3, and therefore calculates that z = 11, it sends the hash of 3 and the hash of 11 to the contract, then presents the problem to the player as "2x + 5 = 11. What is x?"

Then when the player is ready they can hash both their answer (hopefully 3), as well as the solution to the problem they were given (11), and submit those directly to the smart contract for confirmation.
At this point, the server can also reveal (in plain text) the input it used (3), meaning the player can:

a) verify that the hash of that input is the same as the one the server sent to the smart contract at the start, and

b) verify that that input, when applied to the problem they were given, results in the same solution (11)(and was also sent to the contract at the start)

Now I realize that with this system the server can still cheat (e.g. by sending the hashes of 4 and 11 to the contract), and the contract would lack the knowledge needed to detect that, but at least the player will always find out (e.g. if the server then reveals 4 to be the correct answer, the player will know it doesn't produce the solution of 11, or else if the server reveals 3, the player will know that that's not what the server told the contract). Likewise if the server were to send 3 and 12 to the contract, the player could immediately detect the discrepancy.

And since no one will want to play against a server that can be proven to be cheating, the server will play fair.

So my question is: Is this the optimum design pattern here? What might be improved/altered?

Note: I realize that in order to prevent players using rainbow tables to cheat, the hashing process would need to be more robust (possibly including some seed that changes for each player after each use).

For what it's worth, I have considered using an Oracle to generate the random input via the smart contract (though this would have to use encryption) and send that to the server. However, I don't believe this adds any trust, as the server could just as easily ignore the contract.


texts: Are Delegated PoS or "normal" PoS blockchains as secure as PoW blockchains?

texts:
I have heared in some videos regarding new blockchains and Delegated PoS that DPoS does not have same cryptographic security than PoW, apparently because:

In PoW, if you are an attacker, as soon as you are able to change a particular block, you need to recalculate the entire chain, which is not something pretty easy (huge amount of energy).
But, apparently, in DPoS, this is not the case.

I do not have more details about this statement, not sure whether this statement is true, or whether is true, this is only that affects DPoS, being normal PoS having same security levels (probably other procedures) in order to avoid any malicious attack and change any block in the chain.


texts: Proof of Stake how many blocks are proposed each round

texts: So. I understand that the "nothing at stake" problem requires more than one chain being proposed. How can more than one chain be proposed? how many blocks are proposed each round? I thought that only one validator was supposed to win the selection and propose the block to be "forged". Please help me understand this.


texts:
I have a contract A, which has an instance of contract B, i.e., B b.

Contract A calls a function of contract B via the instance, i.e., b.func().

Contract B is stateless, i.e., no global non-constant variables.

I therefore decided to redeclare it as a library.

After that, when I compile contract A, I get the following error:

TypeError:
Member "func" not found or not visible after argument-dependent lookup in type(library B)

I can resolve the problem by changing the access-level of func from external to internal.

However, that prevents me from calling the function via Web3 (Python).

Can someone please explain this odd behavior, i.e., why do I need to reduce the function's access-level from external to internal after I "reduce" the contract to a library?

UPDATE:

I think I got it:

The library code is "embedded" into the contract which imports it (like a macro in C if you will).

Then, only functions that are either private, internal or public can be invoked from inside the contract, while external functions can be invoked only from outside the contract.

So my question really is:

How can I reconcile the fact that I want these functions to be internal when used by a contract, and external when accessed via Web3 (for testing purpose)?

Thank you!


texts: How to calculate ethereum dataset bytes?

texts:
https://github.com/ethereum/wiki/wiki/Ethash

I have compiled above code but I am not able to write the dag into a file.

Could anyone please help me on this?

I have combined all code mentioned in link above but nothing is printing.

I also executed test\*.py (provided in the test directory), but no luck.

Again, I tried below code, but it's throwing an attributes error:

with open("cache","rb") as fcache:
    cache = fcache.read()
# Using same block 0 from benchmark code
data_size = pyethash.get_full_size(0)
print("Generating dataset (DAG) of size %d." % data_size)
dataset = pyethash.calc_dataset_bytes(data_size, cache)
with open("dataset","w+b") as fcache:
   fcache.write(dataset)

===========================================

I have successfully compiled ethash:

[root@localhost build]# ./src/benchmark/Benchmark_FULL

ethash_mkcache: 580ms, sha3: 6a286c5fc0f36814732c86c3e71c036dd96d58def86b9244bb1480571e67d2a8

ethash_light test: 10ms, a7ea1de3a8007134900cd2c86f7e55af68a1d3e4537438a0a966b6cbafa23c90

ethash_compute_full_data: 178740ms

ethash_full test: 0ns, a7ea1de3a8007134900cd2c86f7e55af68a1d3e4537438a0a966b6cbafa23c90

hashrate:   156038, bw:   1219 MB/s

[root@localhost build]#

[root@localhost build]# cat dag_generation.py
import pyethash

with open("cache","rb") as fcache:
    cache = fcache.read()

# Using same block 0 from benchmark code
data_size = pyethash.get_full_size(0)

print("Generating dataset (DAG) of size %d." % data_size)
dataset = pyethash.calc_dataset_bytes(data_size, cache)

with open("dataset","w+b") as fcache:
    fcache.write(dataset)
[root@localhost build]#

error :

[root@localhost build]#

[root@localhost build]# python dag_generation.py

Traceback (most recent call last):

  File "dag_generation.py", line 7, in <module>

    data_size = pyethash.get_full_size(0)

AttributeError: 'module' object has no attribute 'get_full_size'

[root@localhost build]#


texts: In MetaMask (web3.js 0.20.x) how to get events happened during a transaction?

texts:
In MetaMask (web3.js 0.20.7) I send a contract method with .sendTransaction().
Now I need to check the values of arguments of UpdateItem event created by this contract during the call of this method.
How?
My actual code:
    function createItem(string calldata _title,
                        string calldata _shortDescription,
                        string calldata _longDescription) external
    {
        itemOwners[++maxId] = msg.sender;
        emit ItemUpdated(msg.sender, maxId, _title, _shortDescription, _longDescription);
    }

async function createNewItem() {
    const contract = web3.eth.contract(await categoriesJsonInterface());
    const contractInstance = contract.at(categoriesContractAddress);
    const title = document.getElementById('title').value;
    const short = document.getElementById('short').value;
    const long = document.getElementById('long').value;
    contractInstance.createItem.sendTransaction(title, short, long, {gas: '5000000'}, (error, receiptHash) => {
        web3.eth.getTransactionReceipt(receiptHash, (error, receipt) => {
            console.log(receipt.logs)
            const event = receipt.logs.ItemUpdated;
            const itemId = event.returnValues.id;
            open('upload.html?id=' + itemId);
        });
    });
}

It aims to get information from a Web form and store it in the Ethereum logs.


texts:
I tried to install swarm in windows.swarm comes up with mist browser .after that I have started running a private block chain using my custom genesis bloc and started running swarm using this below command swarm --bzzaccount BZZKEY .this command have started the swarm but i am getting an error when i try to access the http://127.0.0.1:8500/..Any Help on this ....

Hmmmmm....Swarm was not able to serve your request! Error message: Bad request GET : Invalid URI "/": unknown scheme "" Error code: 400enter image description here


texts: How do events influence a transaction's gas?

texts: Since events are stored in the transaction receipts trie they should influence the gas a transaction costs since storage costs, right?


texts: How should I track orders in my E-Commerce app?

texts:
In my E-Commerce application, I have to associate each incoming Ethereum payment with my internal order ID in order to distinguish different purchases. In Bitcoin world, I could simply record an address in my database when sending a user to payment page, then use it to pick a that order from my DB when Bitcoin payment will be received & confirmed.

Do I understand right that

I shouldn't use the same approach in Ethereum, because accordingly to that article, I shouldn't expose personal.newAccount to RPC. Also, in that case I will not be able to withdraw all accumulated funds to another address in a single transaction.
If I use an approach described in another article which seems idiomatic for me, I will also have to teach each of my customers how to load my smart contract in his Ethereum client because there is no widely-accepted standard of embedding smart contracts in QR codes and pay URLs?


texts:
I´m having problem migrating my contracts to the private blockchain. That blockchain is located in a CentOS VirtualMachine instance. With the Geth console I connect to the blockchain and I unlock one account.

Then I open a new terminal and I open the Truffle console. First I compile the code (compile --reset) and then I migrate the contracts (migrate --reset). But the Truffle console answer me the following:

  Error encountered, bailing. Network state unknown. Review successful transactions manually.
  Error: authentication needed: password or unlock
      at Object.InvalidResponse (C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\errors.js:38:1)
      at C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:86:1
      at C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:225:1
      at C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-provider\wrapper.js:134:1
      at XMLHttpRequest.request.onreadystatechange (C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\httpprovider.js:128:1)
      at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:64:1)
      at XMLHttpRequest._setReadyState (C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:354:1)
      at XMLHttpRequest._onHttpResponseEnd (C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:509:1)
      at IncomingMessage. (C:\Users\emendez\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:469:1)
      at IncomingMessage.emit (events.js:187:15)
      at IncomingMessage.EventEmitter.emit (domain.js:460:23)
      at endReadableNT (_stream_readable.js:1094:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)

My truffle migration js file:

var Migrations = artifacts.require("./Migrations.sol");
var Strings = artifacts.require("./lib/Strings.sol");
var DateTime = artifacts.require("./lib/DateTime.sol");
var Travel = artifacts.require("./Travel.sol");

module.exports = function (deployer) {
  deployer.deploy(Migrations);
  deployer.deploy(Strings);
  deployer.deploy(DateTime);
  deployer.deploy(Travel);
};

All the files works because doing proves with Ganache was working, now that I have changed the test environment to a virtual host with a private implemented blockchain i have this problem.

I change also the truffle config parameters:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 22000,
      network_id: "*" // Match any network id
    }
  },
  compilers: {
    solc: {
      version: "0.4.24"
    }
 }
};

I look to many post with the same error response but I still having the issue. So I make this post to try to solve the problem.

EDIT

I execute this commands in the geth console but still having the same issue.

eth.defaultAccount = eth.accounts[4]
miner.setEtherbase(eth.accounts[4])
personal.unlockAccount(eth.accounts[4], "blockchain")


texts: Does gas price go up when I send a lot of Ethers?

texts: If I send a lot of Ether to a different wallet, does it mean that I also have to pay higher gas price because if I remember correctly, gas price varies based on the complexity of the operarion but would the content would affect the prices as well?


texts: Why are there no bit shifting opcodes in Ethereum?  What's the fastest and cheapest way (in terms of gas) to implement them?


texts: Is it possible for someone to write his own Ethereum miner who would choose which transactions to execute according to own logic? Is there a mechanism for the network to discourage this type of behaviour?


texts:
I just have a question in my mind. can I use the contracts which are already deployed so that I can use them without even myself have to deploy it again.

For example, take SafeMath I think I would have been deployed already on the network.how can I use it.


texts:
I just wanted to mine ETH with my CPU. I use Windows 7 64 Bit with ethminer.

I started the cpu miner with a batch

ethminer -t 6 -C -F http://ethereumpool.co/?miner=5@0x17C0Bea7c44*******9569EBA3d9B605CF2@RigCPU

It starts up and starts mining with about .5-.6 MH/s but after about 1 minute i get

  Exception -32700 JSON_PARSE_ERROR: The JSON-Object is not JASON-Valid: Database Error

I have no idea how I could solve this.

CPU is an i7 3630QM


texts:
I have two contracts that both inherit from OpenZeppelin's Whitelist. After deploying both contracts, I use an instance of the first contract to add a "trusted" address to the whitelist. Since both contracts inherit from the same Whitelist, I would assume that the second contract also sees that "trusted" is whitelisted. However, I don't see that when running tests. My questions are below the code.

contracts A and B:

pragma solidity ^0.4.23;
import "openzeppelin-solidity/contracts/ownership/Whitelist.sol";

contract A is Whitelist {
}

contract B is Whitelist {
}

migration 2_deploy.js:

var A = artifacts.require("./A.sol");
var B = artifacts.require("./B.sol");

module.exports = function(deployer, network, accounts) {
    var owner = accounts[0];
    var trusted = accounts[1];

    deployer.deploy(A, {from: owner})
    .then(function(){
        console.log("A deployed");
        return;
    });

    deployer.deploy(B, {from: owner})
    .then(function(){
        console.log("B deployed");
        return;
    });

    A.deployed()
    .then(function(instance) {
        instance.addAddressToWhitelist(trusted, {from: owner})
        .then(function() {
            return;
        });
    });
};

test.js:

const A = artifacts.require("A");
const B = artifacts.require("B");

contract('A', async (accounts) => {
    let owner = accounts[0];
    let trusted = accounts[1];

    a = await A.deployed();
    b = await B.deployed();

    let isWhitelistedA = await a.whitelist(trusted);
    let isWhitelistedB = await b.whitelist(trusted);
    console.log("before adding trusted, contract A: "+isWhitelistedA);
    console.log("before adding trusted, contract B: "+isWhitelistedB);

    await a.addAddressToWhitelist(trusted, {from: owner});
    isWhitelistedA = await a.whitelist(trusted);
    isWhitelistedB = await b.whitelist(trusted);
    console.log("after adding trusted to A, contract A: "+isWhitelistedA);
    console.log("after adding trusted to A, contract B: "+isWhitelistedB);

    await b.addAddressToWhitelist(trusted, {from: owner});
    isWhitelistedA = await a.whitelist(trusted);
    isWhitelistedB = await b.whitelist(trusted);
    console.log("after adding trusted to B, contract A: "+isWhitelistedA);
    console.log("after adding trusted to B, contract B: "+isWhitelistedB);
})

truffle test output:

before adding trusted, contract A: false
before adding trusted, contract B: false
after adding trusted to A, contract A: true
after adding trusted to A, contract B: false
after adding trusted to B, contract A: true
after adding trusted to B, contract B: true

Questions:

Why trusted is not whitelisted before being added in the Test? Migration should have added it.
When trusted is whitelisted via A's instance, why is it not whitelisted according to B? Inheritance should have taken care of that.

Notes:

This might be me not understanding how "deployed" and instances work, so please enlighten me what is happening :).
test.js is obviously not a proper Truffle Test (as nothing is really tested), but it is a reduced example of a problem I am facing.

Other info:

Truffle v4.1.8 (core: 4.1.8)
Solidity v0.4.23 (solc-js)
using Ganache with localhost


texts:
Can someone explain to me how proof of stake works in detail? And in particular, which is the difference (if it exists) between proof of stake in general and Casper protocol of Ethereum?
Thank you all!


texts: Unable to transfer entire balance? what is the minimun amount needed for transfer?

texts:
Trying to transfer from myEtherwallet and it says "insufficient funds" - I lowered the amount and it worked, but I can't get the rest out. I've been searching for several hours (I told you I'm a rookie) and I still have .477 or so Ether in there, but it says insufficient when I know the transaction (gas?) shouldn't be too much? It defaults to 21000 and I've tried to adjust that, but I get the same message every time now for several hours.

I put in "Send entire balance" which still is a bit less than full amount (which I'm assuming is to cover transaction fee ), I hit "Send Transaction and then "yes, I'm sure" and every time, a box pops up saying "Insufficient Balance for Transfer"??

At that point, it appears I can adjust the gas limit and/or the gas price, but the only options after doing so are "Reset, Buy, or Reject" - none of which seem to be "Save" or "Update" w/ regard to if I adapt one or both of those numbers.

I don't even know if I understand what I just typed, but I would greatly appreciate any insight - thank you!