texts: Geth says it's synced, but is about 50 blocks behind everyone else

texts:
So I run a small eth mining pool and the eth node says it's synced, but when I compare the block to the ones on other pools we are about 50-100 blocks behind.  When I check in geth it says it's fully synced.

I recently did a re-sync because the blockchain was getting much too large, but it kept locking up and causing me to have to start the sync again.

I did just setup an etc node and synced it, but in doing so I think it may have changed my geth version to a much older one.  I updated it but still having the issues.  I would hate to have to delete the chaindata and sync again as my miners would be really upset at loosing their progress on the current block, but also being so many blocks behind we will either never find a block or get an orphan.  Any suggestions?


texts: Is having 1 smart contract for an ICO good practice?

texts:
I wrote a smart contract which will be used in an ICO. The contract is an erc20 token but it also provides functionality to mint tokens so basically users can call the payable function. This in turn calls a internal function to calculate the number of tokens that should be minted for that amount of eth, mints the tokens and transfers them to the caller.

My question is, is this the way to go? Is having an erc20 token which also contains the crowdsale functionality good practice? The reason I am asking this is because I read about the possibility of having an erc20 contract and a crowdsale contract, but I do not see the point of having 2 seperate contracts rather than 1.

My contract also has logic that when the ICO is over, minting of new tokens and so on cannot occur anymore and the contract then simply acts as a ledger and to allow token transfers between accounts.

Any clarifications would be greatly appreciated.


texts: How do I control compiler settings with truffle?

texts:
I'm using truffle development environment for prototype contract development and I need to change compiler setting (e.g. turn optimization on and off).

The documentation for the development environment does not say how to control the compiler settings.  How do I do so?


texts: truffle migrate hanging on Deploying Migrations

texts:
I am deploying a contract on Ropsten Network,These are my settings

2_deploy_contracts.js

var SafeMath = artifacts.require("./SafeMath.sol");
var TahaCoin = artifacts.require("./TahaCoin.sol");
var Crowdsale = artifacts.require("./Crowdsale.sol");
module.exports = function(deployer) {
var owner = web3.eth.accounts[0];
var wallet = web3.eth.accounts[1];

//var owner = '0x398DB5039aA7f064a8cBDe5c302E09E2cAc46487';
//var wallet = '0x6A0a14e7aAF404D0E5Cc118ECA740568d936fC9F';

console.log("Owner address: " + owner);
console.log("Wallet address: " + wallet);

deployer.deploy(SafeMath, { from: owner });
deployer.link(SafeMath, TahaCoin);
return deployer.deploy(TahaCoin, { from: owner }).then(function() {
    console.log("TahaCoin address: " + TahaCoin.address);
    return deployer.deploy(Crowdsale, TahaCoin.address, wallet, { from: owner }).then(function() {
        console.log("Crowdsale address: " + Crowdsale.address);
        return TahaCoin.deployed().then(function(coin) {
            return coin.owner.call().then(function(owner) {
                console.log("TahaCoin owner : " + owner);
                return coin.transferOwnership(Crowdsale.address, {from: owner}).then(function(txn) {
                    console.log("TahaCoin owner was changed: " + Crowdsale.address);
                });
            })
        });
    });
});
};

truffle-config.js

// Allows us to use ES6 in our migrations and tests.
require('babel-register')
var bip39 = require("bip39");
var hdkey = require('ethereumjs-wallet/hdkey');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
 var Web3 = require("web3");

 // Get our mnemonic and create an hdwallet
 var mnemonic = "My phrase  12 words  12 words 12 words";
   var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));

 // Get the first account using the standard hd path.
 var wallet_hdpath = "m/44'/60'/0'/0/";
 var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
 var address = "0x" + wallet.getAddress().toString("hex");

 var providerUrl = "https://ropsten.infura.io/";
 var engine = new ProviderEngine();
 engine.addProvider(new WalletSubprovider(wallet, {}));
 engine.addProvider(new Web3Subprovider(new
 Web3.providers.HttpProvider(providerUrl)));
 engine.start(); // Required by the provider engine.

 module.exports = {
    networks: {
     ropsten: {
        network_id: 3,    // Official ropsten network id
        provider: engine, // Use our custom provider
        from: address,     // Use the address we derived
        gas: 3000000
         }
        },
     rpc: {
     // Use the default host and port when not using ropsten
        host: "localhost",
        port: 8545
        }
       };

important things

Migration was created by my Wallet on Ropsten
I have tow accounts on MetaMask
I have enough gas "22ETH" in my deployer account
i used pragma solidity ^0.4.11 on my contract files


texts: What is the purpose of mapping an object to another mapping?

texts:
I have seen examples like the following code many times:

mapping (bytes32 => mapping (bytes32 => bytes32[])) items;

And I have tried to recreate something similar here:

mapping(address => uint) public addresskey1;

mapping(uint => mapping(address => uint)) public addresskey2;

function addAddress(address _address, uint _pin) public {

    addresskey1[_address] = ID;

    addresskey2[_pin] = addresskey1[_address];

}

Aside from remix telling me that mappings can't be assigned to, I can't quite figure out what this does.  I know that a mapping creates a hash of the keytype which points to a location where the value is stored, but how does it work when

a hash of a key points to another hash of another key which points to the value?  My first thought is that the hash immediately tells the computer where to go, and so mapping like this would just create two jumps to the desired value.

In other words, it is a way of creating multiple keys for the same value without having to save the value in multiple locations - but then, the hash of the first mapping must be stored separately anyway, so it wouldn't really save space.

I keep trying to play around with this, but I cannot figure out what it does.


texts: Using getTransactionReceipt to get cumulativeGasUsed in truffle javascript

texts:
Trying to parse the transaction result, for example the exact gas used by a transaction.
How can I do it in javascript?

The below is not working btw, any idea?

return metaInstance.deposit({ from: accounts[0], value: web3.toWei(5, "ether") }).then(function (tx) {
  var rcpt = web3.eth.getTransactionReceipt(tx).then(function (rcpt) {
    console.log(rcpt.cumulativeGasUsed.toString());
  });


texts:
I see something I assume to be akin to javadoc at https://www.npmjs.com/package/solidity-doc and Github at https://github.com/vitiko/solidity-doc.  However, I see no documentation... the closest I get is a line in Github mentioning /// notation.

Can anyone tell me where this, or anything similar, may be documented?  From a quick glance at the code, I'm not finding the relevant info.


texts: Cannot connect to private testnet with web3.js

texts:
I have setup a local private test net and now I want to connect from Node.js to a node in the testned using IPC. I started a node with this command:

./geth --identity "5"  --datadir /home/davide/Documents/Ether/5th/ --networkid 4999 --port 30600 --nodiscover --ipcpath /home/davide/Documents/Ether/5th/geth.ipc --shh

This is my node.js scrypt

const http = require('http');
var fs = require('fs');
var net = require('net');

var Web3 = require('web3');

var web3 = new Web3(new Web3.providers.IpcProvider('/home/davide/Documents/Ether/5th/geth.ipc', net));

console.log(web3.version);

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
   res.statusCode = 200;
   res.setHeader('Content-Type', 'text/plain');
   res.end(web3.version+' '+console.log(web3.currentProvider)+' '+console.log(web3.eth.accounts)+' '+web3.contentProvider);

});

server.listen(port, hostname, () => {
   console.log(`Server running at http://${hostname}:${port}/`+web3.eth.accounts[0]);
});

and on the web page I get the following output:

1.0.0-beta.33 undefined undefined undefined

If I try to connect through geth attach everything works but with node.js it doesn't. What is the problem?


texts: Smart Contracts without ETH Transactions

texts:
Maybe I'm wrong, but I understand that Smart Contract Transactions must always contain a "VALUE" field, that's to say, the amount of Ether Alice will transfer to  Bob in case certain condition accomplishes.

Taking this into consideration, ¿does it means that Ethereum Smart Contracts can't be used to set clauses which don't involve Ether? Like for example:

a) IF Alice transfers the Property Title of a house to Bob, THEN Bob in exchange transfers her another Property Tittle;

Or for example:
b) IF Temperature value for January is below X, THEN Insurance decreases the insurance prime for next month;

c) IF consumer A buys something but it's broken, THEN gets (non monetary) compensation from the seller.

In case this is possible, nodes will have a compensation according to used Gas, even if there's no an Ether transaction between the parties. Isn't it?

Thanks in advance.


texts: Why isn't Ethereum Frontier a "safe" platform?

texts:
On the Ethereum homepage, underneath the Ethereum Frontier header, there's a tag line which reads "A safe decentralized software platform", but with the word "safe" crossed out.

Is this simply because Frontier is an early-release version, and therefore comes with the expected bugs, security problems, and unknowns, or is it because certain things are explicitly and deliberately missing in Frontier which makes it inherently less safe than later releases such as Homestead and Metropolis.

(I'm not concerned with qualifying exactly what "safe" means in this question.)


texts: Security of PoS if/when Assets (Tracked or Native) to Ethereum exceed the total Value of Ether

texts:
Given that Ethereum naturally allows for the creation of arbitrary tokens that can either have value themselves or track a real-world asset, can Ethereum be secured by PoW/PoS when the total assets on chain exceed the market cap of the Ether token?

Does this security guarantee breakdown after the assets exceed 2x, 10x, 100x the market cap of the Ether token... or never?


texts:
My Remix has started to throw out this error as of recently, I'm not really sure what it is as the code didn't trigger it previously only as of recently, and all other code is triggering it as well.

Failed to decode output: TypeError: Cannot read property 'length' of undefined


texts: Trying to be a validator in blockchain but I have got the error : Mining aborted due to sync

texts:
I try to run blockchain in local to be a validator with this command :
geth --config ./config.toml --datadir ./node -unlock {your-validator-address} --password password.txt  --mine --allow-insecure-unlock  --pprofaddr 0.0.0.0 --metrics --pprof

But I get this error :

Always get Mining aborted due to sync and after that ####BAD BLOCK#####


texts: Safemath Library version for Solidity v0.5?

texts:
Is there a version of the SafeMath library that is compliant to SOlidity v0.5?

Thanks for your inputs in advance


texts:
I am trying to solo-mine.  I am using geth and ethminer on windows.

I recently added ether-proxy so that I can see progress.

However, ether-proxy now thinks that I am part of a pool and its forcing me to set a difficulty.  I am guessing it is asking what difficulty do I want to solve.  Since shares do not matter to solo mining, does anyone know what difficulty I should set in Ether-Proxy so that my node tries to solve a full block?  There is zero documentation.  According to the author, the fields are self-described.

To make matters more confusing, Ether-proxy is also reporting that the network difficulty is Difficulty: 79,764,482,404,251

Since ether-proxy is forcing me to enter a difficulty, I put it in 500.  Which its reporting as 50000000000.

2017/12/18 13:36:55 Valid share at height 2427590/2427590 from R01@192.168.1.248 at difficulty 50000000000

My question is, does anyone know what difficulty do I need to set so that my node tries to resolve the entire block and not just a share?

Thanks!


texts:
web3.eth.accounts.signTransaction(transactionObject, process.env.WALLET_PRIVATE_KEY, function (error, signedTx) {
    if (error) {
        log(`${error}`.red);
    } else {
        web3.eth.sendSignedTransaction(signedTx.rawTransaction)
            .on('confirmation', function (number) {//dostuff
                log(`Success: ${number}`.green);

            });

        // Note this address. It will be used to create contract instance from Angular 5 application.
        //console.log("contract deployed to", result.options.address);
    }
}).catch(function(err){
    log(`${err}`.red);
});

I get:

  TypeError: Cannot read property 'slice' of undefined

in proximity of web3.eth.accounts.signTransaction, why?


texts: Purchase real Ether and add to base/default account

texts:
I created an Ethereum Consortium Leader instance on Microsoft Azure and they provided us with an Admin site and RPC endpoint:

http://someName.eastus.cloudapp.azure.com/

http://someName.eastus.cloudapp.azure.com:8545

Why these are publicly accessible ? Is it because its a test account ? How can I create a real Ethereum blockchain on Azure and put some real Ether in it after purchasing from crypto-currency exchange ?


texts:
I am developing an app that uses Ethereum as its payment method, and in the app, users will have their own balances. But there is a slight problem and it has to do with fees.

If a user deposits funds, he is obviously paying a fee to send the money. And that is understandable
Now in my app, users will be able to give their friends funds as well. HERE is where the problem arises.

If a wallet is created for each new client, not only is there a fee when they first deposit money, but they would be charged money every time they gave someone else money.

POSSIBLE SOLUTION:

I then thought of making it so that each user deposites into the same Ethereum wallet, and then have a separate database that registers how much of that total balance is of each user. So that makes it possible for having balances shifting in the database without it actually shifting in the Ethereum blockchain, until a user wants to withdraw.

ISSUE WITH THE SOLUTION:

How would I know which user sent the money? It is possible for a user to first specify which account they are sending the money from and then sending, but I see holes here for security reasons. For instance, what if a bad person knows the persons Ethereum address and pretends he is sending the funds and gets the funds credited to his account.

There was also the option of using the data variable in the transactionObject in the code:

web3.eth.sendTransaction(transactionObject, myCallbackFunction);

And in this option, if the data variable was a code that was randomly generated, it would make it easy to track what is happening. HOWEVER not all ethereum wallets online give the option of using that data variable during a transaction, and this might limit the amount of potential clients that can use my app.

QUESTION:

How might I go about fixing the previous issue of finding the right way to store user balances? I am not sure if there is another way of getting this done and if someone has a solution please let me know.


texts:
I have two geth nodes, each has an account:

node1(IP:192.168.43.12): account1
node2(IP:192.168.43.39): account2

the two accounts are created using geth --datadir /root/chain/node1/data account new, the keystore files are generated and saved on each node.

I use web3 to attach node1 in nodejs environment:

const Web3 = require('web3');
const web3 = new Web3('http://192.168.43.12:8545');

and try to unlock account2 created on node2 before sending a token transaction like below:

await web3.eth.personal.unlockAccount(account2, "account2 password", 1000);

I got an error like below:

Error: Node error: {"code":-32000,"message":"no key for given address or file"}

I also tried if attach to node2 and the unlock process is correct.

const Web3 = require('web3');
const web3 = new Web3('http://192.168.43.39:8545');
await web3.eth.personal.unlockAccount(account2, "account2 password", 1000);

How can I unlock an account use web3 without the limitation of node connection?

Thanks.


texts: Problem with meteor server side call to Ethereum node

texts:
I try to interact with Ethereum node via web3 lib. (meteor add ethereum:web3)

Meteor 1.5.4.1

lib.js

if (typeof web3 === ‘undefined’){
web3 = new Web3(new Web3.providers.HttpProvider(‘http://127.0.0.1:21045’));
 }

main.js

web3.eth.defaultContractEvent = “0x*************************************”;
contract_event = web3.eth.contract(abi_event).at(web3.eth.defaultContractEvent);
 var events = contract_event.allEvents({fromBlock: 0, toBlock: ‘latest’});

get error at last line

C:\Users***\AppData\Local.meteor\packages\meteor-tool\1.5.2_2\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280
 throw(ex);
 ^

TypeError: XHR2 is not a function
 at [object Object].HttpProvider.prepareRequest (packages\ethereum_web3.js:4315:15)
 at [object Object].HttpProvider.sendAsync (packages\ethereum_web3.js:4364:22)
 at [object Object].RequestManager.sendAsync (packages\ethereum_web3.js:6369:19)
 at Object.send [as newFilter] (packages\ethereum_web3.js:5080:42)
 at new Filter (packages\ethereum_web3.js:3568:25)
 at [object Object].AllSolidityEvents.execute (packages\ethereum_web3.js:2716:12)
at server/main.js:135:30

at Function.time (C:\***\.meteor\local\build\programs\server\profile.js:309:28)
at C:\***\.meteor\local\build\programs\server\boot.js:348:13
at C:\***\.meteor\local\build\programs\server\boot.js:389:5

Exited with code: 1

what is the problem?


texts: Can I deploy a smart contract from studio.ethereum.org to mainnet?

texts: I found this website quite useful: studio.ethereum.org. However, it seems that I cannot deploy smart contracts from there to mainnet. Is this correct, or is there a way to do it?


texts: How to call variadic function in erc223 contract

texts:
There is two transfer function in my contract,
And i m trying to call transfer function of erc223 for transfer token to contract address using this function.

 Token.deployed()
 .then(function(i) {
   i.transfer.call('0x5f71b35ed4bdd29d0183b5a11d0b3dfd025d7556','12','test_data')
   .then(function(j){
     console.log(j)
   })
 })

but it throw an error as below:

  (node:12048) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): Error: Invalid number of arguments to Solidity function


texts:
I have deployed a Quorum Network on Azure and now I would like to have ssh access. In the creation process I had to set a VM-user and a VM-password. But if I use them like this:

ssh VM-user@Public-IP-address

I get this:

ssh: connect to host <ip_adress> port 22: Connection timed out

Does anybody know how use ssh with Azure and Quorum?


texts: How many blocks can a cache of 1gb (1024) hold tentitively?

texts: If I use a command geth --cache=1024, how many blocks it will hold runtime in cache. And what will be the size of each block. Is there any calculation? And is there any way using which we can force to write the data present in cache to leveldb files.?


texts: How to connect to the Private BlockChain in Azure consortium

texts:
How using Web3 in geth client to conect to the private blockchain
when i use

  var web3 = new Web3(new Web3.providers.HttpProvider("
  http://alexyy73n.northeurope.cloudapp.azure.com:8545"));

So how can i connect to the chain and interact with contracts?
With metamask all works fine. But need to do client part. And connect it with azure blockchain.


texts: How to build an API that communicate with Smart contract Event?

texts: I want to build an API to manage the smart contract events and I wonder how to do it using Node.js. Anyone that can help?


texts: Does staking on ETH 2.0 require a full node and how much space would that take?

texts: I read that ETH 2.0 staking with 32 ETH requires users running a full node on their server. But doesn't a full node take up 500+ GB of space? What are the proposed system requirements?


texts:
I am deploying a Smart contract with set of fields.
Updating some fields using events.Till here is fine.

Now here i need to fetch the root data(data while deploying the contract)

Please suggest.

Thanks
Veera


texts: Why is avg. block time growing so much latley

texts:
how come average block time is growing this much latley? In March it was around 14.5 and today is around 24. I know that hash rate is growing fast, but shouldn't every difficulty adjustment reset avg. block time to around 14-15?

Thnx,
Tomo


texts: after --fast sync in geth is there a way to rebuild the old states?

texts: getBalance() is not working after fast sync as it queries too far into history, is there a way to rebuild all the states without redownload of all the blocks?


texts:
I use latest version stable geth:
[root@localhost ~]# geth version

WARN [05-30|06:27:22.750] Sanitizing cache to Go's GC limits       provided=1024 updated=612
Geth
Version: 1.8.27-stable
Git Commit: 4bcc0a37ab70cb79b16893556cffdaad6974e7d8
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.11.9
Operating System: linux
GOPATH=
GOROOT=/home/travis/.gimme/versions/go1.11.9.linux.amd64

The web3 version info:

> web3.version
{
  api: "0.20.1",
  ethereum: "0x3f",
  network: "123456",
  node: "Geth/v1.8.27-stable-4bcc0a37/linux-amd64/go1.11.9",
  whisper: undefined,
  getEthereum: function(callback),
  getNetwork: function(callback),
  getNode: function(callback),
  getWhisper: function(callback)
}

I use node 10.15.3 and installed web3, its version is:

> web3.version
'1.0.0-beta.55'

When I set up a ERC20 Token contract and call the function balanceOf in node env, I got the result below:

contract_instance.methods.balanceOf('0x3c46b43e683b5addd7e66b3d1d958854ffb58361').call().then(console.log);
    Promise {
      <pending>,
      domain:
       Domain {
         domain: null,
         _events:
          [Object: null prototype] {
            removeListener: [Function: updateExceptionCapture],
            newListener: [Function: updateExceptionCapture],
            error: [Function: debugDomainError] },
         _eventsCount: 3,
         _maxListeners: undefined,
         members: [] } }
     BigNumber { _hex: '0x3635c9adc5dea00000' }

I check the bigNumber, it's correct number I issue token.
From my expection, the result should be balance number, why I got these returns?

Another question is:
when I call contract function to get the balance of token like below:

> var balance = contract.methods.balanceOf('0x3c46b43e683b5addd7e66b3d1d958854ffb58361').call();
undefined
> console.log(`balance before send: ${balance}`);
balance before send: [object Promise]

the return result is not a number, why and how to get correct number?
Thanks!


texts: :8:42: ParserError: Expected token LBrace got 'string' function setName(string name) public string returns(string) { ^

texts:
//This is the code:
pragma solidity ^0.4.16;

contract FunctionTest {

  bool public foo = true;
  string public name;
  uint256 public counter = 0;

  function setName(string name) public string returns(string) {
    string a = name;
    return a;
  }

  function writeToStorage() {
    foo = !foo;
  }

  function readFromStorageConstant() public constant returns (bool) {
    return foo;
  }

  function readFromStorageView() public view returns (bool) {
    return foo;
  }

  function increaseCounter(uint256 counter)  public returns(uint256)
  {
    counter = counter + 10;
    return counter;
  }
}


texts: Does Exporting tokens from a metamask account with private key to a wallet, export the ethereum too?

texts: Wanting to know if I’m exporting with my private key from metamask to a wallet will all contents of the MM account be exported? iE will the ethereum be exported along with my Theta token? Or would there be a different private key generated for both tokens. Thanks.


texts: Why are there discrepancies between client message signatures?

texts:
I have been investigating message signing using an Ethereum account, and have become somewhat bemused by the different signatures that I receive from different clients and different libraries.

I have attempted to get answers by contacting library/client creators directly but have gotten no definitive answers.

When I utilise jsonrpc to send off a signing (web3.eth.sign) request to a Parity (1.6.6) backend, and a Geth (1.6.1) backend I get the following signatures back:

Geth
0xf6e5ce6040407c688c54c4b15949923e94651790afe4c53070c4765869cdbd713e4ea40b3b6f4a59397cb6a0880f265e9d1a0d1ed97fa9b757dc3799086fe6b91c

Parity
0x1cf6e5ce6040407c688c54c4b15949923e94651790afe4c53070c4765869cdbd713e4ea40b3b6f4a59397cb6a0880f265e9d1a0d1ed97fa9b757dc3799086fe6b9

Now.. I do not have an in depth understanding of elliptical curve cryptography, but i can see here that Geth returns a RSV format signature, and Parity a VRS.

Question 1
Is there a consistent way of determining which format the signature is in (for backwards compatibility)?

Now.. I am trying to work with these signatures using the fantastic ethereumjs-util library.

Utilising their ecsign method returns me a completely different signature:

0x1557765e35991c5ef5b09f7a7b4061be1e8daef873c94dc79089a861ec3284564b8fa3938f4a9f729c465c6bb9e23b80e6e91ae83a4e44fb39e70a11b467992500

I managed to recreate this signature from my Geth/Parity signatures by calling their toRpcSig method with the r,s, and v values extracted from the Geth/Parity sigs.

Looking at the code it seems to concatenate Buffer versions of these values and converts the result to a string.

Question 2
Why does ethereumjs-util do this?

The end result is that geth, Parity, and ethereumjs-util all return different signatures when signing an arbitrary message. Etherscan, and etherchain have signature verification libraries which believe the ethereumjs-util signature to be correct. This may well be because they use the library under the hood. If this is correct..

Question 3
Why do Geth and Parity both return incorrect message signatures?

There seems to be a lot of github discussions etc about appending prefixes to messages before signing them etc, yet seemingly no-one has addressed the issue of client inconsistencies in signing.. which in my opinion is pretty important.


texts: Changing password of an account through web3

texts: Can we change the password of an existing account through web3.js ?


texts: Are there any wrapped ERC20 tokens that are privacy coins?

texts: ERC20 tokens by itself are not private as anyone can see everyone's balance. But a wrapped token for a privacy coin like Monero or Zcash can be anonymous when converted from the wrapped version. Does anything like this exist yet as of OCT 2020?


texts: Getting a, "ReferenceError: artificats is not defined" - Error running a simple "approver" test

texts:
(Working from the Lynda Ethereum course)

Running the test code below I get the following error:

truffle tests
Warning: Both truffle-config.js and truffle.js were found. Using truffle-config.js.
Using network 'test'.

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

/home/iii/Digital Ledger/contracts/migrations/2_depoly_contracts.js:1
var ApprovalContract = artificats.require("ApprovalContract");
                       ^

ReferenceError: artificats is not defined
    at /home/iii/Digital Ledger/contracts/migrations/2_depoly_contracts.js:1:24
    at Script.runInContext (vm.js:107:20)
    at Script.runInNewContext (vm.js:113:17)
    at Object.file (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:354543:12)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:462577:24)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.15 (core: 5.1.15)
Node v10.15.2

Here is the contract as well:

pragma solidity ^0.5.16;

contract ApprovalContract {

  address payable public sender;
  address payable public receiver;
  address constant public approver = 0xd268143B6FBD9BC6533F778052710C962eaAa68C;

  function deposit(address payable _receiver) external payable {
    require(msg.value > 0);
    sender = msg.sender;
    receiver = _receiver;
  }

    function viewApprover() external pure returns(address) {
    return(approver);
  }

   function approve() external {
    require(msg.sender == approver);
    receiver.transfer(address(this).balance);
  }

}


texts: When can BLOCKHASH be safely used for a random number? When would it be unsafe?

texts:
I've seen more complicated ways for a contract to generate a random number.  But the Ethereum Yellow Paper itself suggests a "trivial solution" using the BLOCKHASH opcode (see below, bold is mine).

If a contract just needs a couple of random numbers (not hundreds), how secure would this method be?  What example use cases would this method be satisfactory?  Which use cases are attackable in a practical way, if this method was used?

  Random Numbers. Providing random numbers within a deterministic system is, naturally, an impossible task. However, we can approximate
  with pseudo-random numbers by utilising data which is generally
  unknowable at the time of transacting. Such data might include the
  block’s hash, the block’s timestamp and the block’s beneficiary
  address. In order to make it hard for malicious miner to control those
  values, one should use the BLOCKHASH operation in order to use hashes
  of the previous 256 blocks as pseudo-random numbers. For a series of
  such numbers a trivial solution would be to add some constant amount
  and hashing the result.


texts: Create ethereum wallet inside android dapp

texts:
I am creating a DApp for android and want to be able to create a wallet for each user when they register. I am using web3j, can see how to make wallets in the command line but can't see how to do it in java code. Ideally it would save the users private key and data on their phone or on an equally safe server. Does anyone know how to do this?

Thanks.


texts: liaison entre web3 et nodejs [using web3js and nodjs]

texts:
Bonjour,

j'ai développé une app avec nodejs et je voulais la transférer vers une dapp en intégrant le web3 librairie.

En effet j'ai crée les smart contract il le me reste juste la façon de faire la liaison entre le layout et le nodejs et webjs de tel façon qu'au moment du clique sur ajouter des données cela les envoie vers la blockchain en appelant la smart contract.

Merci


texts:
It seems that on my computer/web browser Google Chrome is slow to inject meta-mask. Therefore I have to write something like this for my App to actually get the web3 instance instead of failing:

setTimeout(function(){
    if (typeof web3 !== 'undefined'){
        console.log('getting web3');
        App.web3Provider = web3.currentProvider;
    }
    else {
        console.log('No Web3 instance given!');
        // flash modal saying "please download Metamask"
    }
    web3 = new Web3(App.web3Provider);

    return App.initContract(web3);

}, 500);

However, this doesn't play nice with Truffle-Contract js library, which needs the web3 instance straight away. Does anyone have a workaround or a fix for this? Thanks.


texts: Testnet blockchain sync stuck at Ancestor below allowance

texts:
I am expereincing problem while syncing testnet with tail of log:

WARN [01-09|06:53:30] Ancestor below allowance                 peer=1061607032be098f number=1082429 hash=000000…000000 allowance=1082429
WARN [01-09|06:53:30] Synchronisation failed, dropping peer    peer=1061607032be098f err="retrieved ancestor is invalid"
WARN [01-09|06:54:46] Ancestor below allowance                 peer=a6134934cc2d3f31 number=1082429 hash=000000…000000 allowance=1082429
WARN [01-09|06:54:46] Synchronisation failed, dropping peer    peer=a6134934cc2d3f31 err="retrieved ancestor is invalid"

Already asked at -
Synchronisation failed, dropping peer
However I do not want to delete whole of data. What can I do?


texts:
Does mist support reading default startup options from a configuration file?

geth doesn't support configuration files, so when starting mist, I need to pass:

--syncmode light --node-datadir "XDG_DATA_HOME/etherium"

I don't want to type this every time.

Does mist support a configuration file?


texts:
const config = require('../truffle-config.js');
const token_parameters = require('../token_parameters.json');
const ExampleToken = artifacts.require('ExampleToken');

module.exports = function(deployer, network, accounts) {
  const networkId = config.networks[network.replace(/-fork$/, '')].network_id;
  const deploymentAddress = accounts[0];
  console.log('Deployment address: ' + accounts[0]);
  deployer.deploy(
    ExampleToken,
    token_parameters[networkId].name,
    token_parameters[networkId].symbol,
    token_parameters[networkId].initialAddress,
    web3.utils.toWei(token_parameters[networkId].totalSupply),
    { from: deploymentAddress, gas: 1500000 },
  );
};

how do I fix below error?
TypeError: Cannot read property 'name' of undefined
    at module.exports (/Users/*/*/*/*/2_deploy_token.js:12:33)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:54:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)


texts: I am reading about ethereum (from technology stand point). I want to create an ICO smart contract (a typical ERC20 test token) where say if someone sends 0.1 ether to the contract address then they receive 10000 test tokens. However, can the receiving value (ie. 10000) be in fractions/floats like 1000.4500000000. I have read that EVM does not support floats. Is there a work around. Please assist


texts: How do I recieve DAO tokens? What's the address?

texts: I'm trying to buy some DAO tokens via shapeshift and it asks a DAO address to send the tokens to. Where do I find that address? Is it the same as my Ether wallet address?


texts: Could A Solidity Developer with Binance Chain Familiarity Explain This?

texts: I am a large holder of a certain token. We recently notice that one wallet where liquidity was being sent regarding 8% of transactions was unwrapping and selling those tokens. We confronted the developer. Right around the same time, we noticed a strange change to the contract. It was not verified, so I decompiled it with ByteCode. Here is the decompiled version. If you would be willing to help us dig further on telegram and potentially catch a scammer in the act, let me know. I'm not sure if this is enough info without the original contract which I can also post if that is helpful. Looking for any information you can provide. Thank you.


texts: Why is my Ethereum Wallet balance wrong, even after sync? Etherscan vs. Wallet mismatch

texts:
Why does my Ethereum wallet disagree with Etherscan? It's been 24h. I made the transaction from Kraken myself, so I know the Wallet is wrong.

I don't think this is a duplicate question, because I've downloaded all the blocks.

Complete Noob.

Please help, thank you


texts:
In Ethereum-Mist_wallet, Under accounts, I see:

  Accounts can't display incoming transactions, but hold and send ether. To see incoming transactions create a wallet contract to store ether.

What does this exactly means? On my private network I am able to see transactions of specific account under Latest Transactions. So what this is for?


texts: I want to clear out my idea of mining. Could someone verify and add missing concepts?

texts:
I will start with a scenario:

Alice, Bob, Adam, Eve, Hansel, Gretel, Rupanzel are the ethereum nodes. Alice has 100 Ether. She sends 100 Ether to Bob. Now this transaction is dispatched in the ethereum network. Everyone starts running the hashing algorithm. The competirion is to generate a hash that has 3 zeros in the start. Of all the successful nodes doing this, the network will select one successful node (based on some probability, which I am not sure what). Now this node is for example Hansel. Hansel receives the reward for mining the block. Before mining, Hansel checks if Alice has a 100 ether balance or not. If yes, Hansel verifies the transaction, and updates his blockchain, decreases Alice's balance by 100 Ether in his blockchain ledger and sends a broadcast message to every other node on the network. Every other node, upon receiving the broadcast message from Hansel, re-verifies the transaction, (checking if Alice had 100 ether). After all the nodes reach to a consensus (proof of concept) the transaction is verified and everyone has the new updated blockchain with Alice's transaction being the latest block. Each new node joining the network, will verify all these transactions and keeps on updating their blockchain to have a latest version of the blockchain.

Fraud Scenario:
 Alice sends 100 Ether to Bob and immediately sends another 100 Ether Gretel. For the first transaction, say Hansel verified it and updated his chain and the reduced the  ledger of Alice by 100 Ether and for second transaction, Adam verifies it(assuming he has not received Hansels broadcast) reduces Alice's balance and sends another broadcast for this second transaction. Now all the nodes that had previously received Hansel's broadcast will have already updated Alice's new balance which is 0 Ether, so now this new update from Adam can't get a consensus and hence the transaction is dropped.

In this fraud scenario, the resources of minera are used to check the transaction. But since the transaction never took place, will there be any reward for the miners?

Is my idea of blockchain correct?


texts: Why does difficulty affect the block header nonce range?

texts: Section 4.3.4, item 48 of the yellow paper states the has nonce, n, must be lte 2^256/current difficulty. The effect of this, assuming current difficulty is < 2^256, the range of the nonce gets smaller, making it easier to validate a block due to less possible nonce values to try. This seems counterintuitive to the purpose of increasing the current difficulty. Am I missing something?


texts: Why is there a SHA256 pre-compiled contract when SHA256 is also an opcode?

texts: The question is in the title :). Trying to understand why there is both an opcode and pre-compiled contract for SHA256. To execute the computation, would people canonically "CALL" into the pre-compiled contract or just use the SHA256 opcode directly?


texts:
Can any one help me in Making Smart contract for My NFT market place .
I have My solidity contract but its not working like i want ! i want smart contract which when  Transfer tokens to Seller to Buyer and  for payment sending  Buyer to seller to their Wallets  using my NFT market place can any one guide me or is any one have source code they can help me in it Please


texts: Which of MyContract.new(...) and MyContract.deploy().send(...) is better to deploy a smart contract?

texts: Suppose MyContract is the name of the given contract. I tried two commands to deploy that, MyContract.new(...) and MyContract.deploy().send(...), and the both worked. So, i interest to know which of them is better and What difference do they make in performance?


texts:
I sent ETH from ED to my ledger. The coins never made it. IN Etherscan I  can see the internal transactions (whatever that is). Is there a way to retrieve  the ETH from the transactions?

https://etherscan.io/address/0x7228540deb07F45a562203F3Cb185f079E88b16d#internaltx


texts: What attacks have been performed against the Ethereum network and contracts?

texts:
Every time I fire up a new Ethereum node, I run into that very slow patch of syncing from 2016Q3 due to a DoS attack on the network. What other attacks have been performed against the Ethereum network and, since I'm already asking, contracts? When did they occur and what remedies, if any were taken? For completeness, I suppose I'll include any existing and forthcoming major forks of the Ethereum mainnet and test networks.

Also useful to have this information when writing scripts to parse blockchain data.

I'm answering in the form of a wiki because the sad fact is that this will probably keep growing (and I also don't have the complete answers myself).


texts:
Sometimes in the scripts I run there are errors (for example one variable is undefined), and geth doesn't stop, it tries to run every line of the script, throwing errors everywhere.

I want to abort the script if I detect an error, but I don't how I can do that, the usual javascript functions don't work here. exit() (or exit) gives ReferenceError: 'exit' not defined, which is weird because when I'm in the console exit works fine.

How do I exit the script ? Is it possible ?


texts:
I've been reading about an account's nonce, that it's supposed to be an incremental number that increments with every transaction. I found about transactions pool and queue, about what happen if you don't send a consecutive nonce, but I couldn't find someone that would tell me if this nonce has a limit.

If I keep making transactions from an account and I increment the nonce by 1 each time, will there be a time that I reach the maximum transactions that can be performed for an account?

I also thought that maybe this nonce is per block, so once transactions were mined the nonce may be restarted so there would be not actual limit. But I saw examples that use geth's getTransactionsCount() method to calculate the next nonce, so it couldn't be per block.


texts: What is the alternative to using **label** in solidity inline assembly code?

texts: What is the alternative to using label in Solidity inline assembly code? Label is deprecated in new version.


texts:
I'm trying to return sender address and value in truffle under private blockchain. When function is called from truffle console I'm not getting proper msg.sender address.

Contract code

pragma solidity ^0.4.13;

contract Sample {

mapping (address => uint) Id;
event log(address sender, uint value);

function getSender() payable returns (uint,address) {

    Id[msg.sender] = msg.value;
    log(msg.sender,msg.value);
    return (Id[msg.sender],msg.sender);
}

}

Truffle console function code

Sample.deployed().then(function(i) {i.getSender(web3.eth.coinbase,2,{from : web3.eth.coinbase, value : web3.toWei(1, "ether")}).then(function(f) {console.log(f)})});

Sample.deployed().then(function(i) {i.getSender.call(web3.eth.coinbase,2,{from : web3.eth.coinbase, value : web3.toWei(1, "ether")}).then(function(f) {console.log(f)})});

Output

truffle(development)> [ BigNumber { s: 1, e: 0, c: [ 0 ] }, '0x' ]

This contracts fine in remix.


texts: Does address.transfer() method prevents underflow/overflow?

texts:
I'm not sure if this is a legit concern but I would still want to know. If anyone can enlighten me. I know that the address.transfer() method is mostly viewed as the safest way to send eth within the contract so this is what I mostly use that is why I want to know if it can prevent an underflow or an overflow even though it is highly unlikely that someone can acquire that much ether [Please refer to the note as well] to cause an overflow.

  Note that there is not enough ETH in existence to cause an overflow, the total amount of wei fits well within 256 bits


texts: My Token wont send from My Ether wallet- keeps saying pending

texts:
Myetherwallet Keeps saying pending and nothing will transfer?
tx Hash: 0xa01498ed5b18cdfa4795261f49c06f279ddbfb6bac8a5335e11ba70ec61ffd39

What should I do? Thanks in advance


texts: set method works fine in Remix browser (with Test-RPC) but out VM out of gas error while using web3 object

texts:
When I try to use this call this method in remix browser it gets mined.

//addAsset function adds an asset along with an owner
    function addAsset(address newOwner,bytes32 description, uint cost) returns(string) {
        if (msg.sender == issuer) {
            assetCount++;
            Asset memory tempAsset = Asset(assetCount,newOwner,description,cost);
            setAssetOwnership(newOwner,assetCount,tempAsset);
            return "asset created";
    } else {
        return "you are not the owner of contract";
    }
    }

But when I call the same method in the browser via web3 object, I get this.

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

        console.log(web3);

        web3.eth.defaultAccount = web3.eth.accounts[0];
        var vishContract = web3.eth.contract(CONTRACT-OPCODE);

//trying to increase the gas limit here, not sure if its correct
// var contract = vishContract.at('CONTRACT ADDRESS', {gasLimit: "10000000"});
        var contract = vishContract.at('CONTRACT ADDRESS');

        function getIssuerId(){
                 document.getElementById("issuerId").innerText = contract.issuer();
        }
</script>

I saw similar questions posted, most of them were resolved by changing string to bytes32 or it was mentioned that their contract is huge, mine isn't.

I am still fairly new with smart contracts. Can anyone please help me out here?

Thanks in advance :)


texts:
I want to test web3.js functionality, then I connect to Ganache, when I run the program web3.eth.getAccounts works properly, but web3.eth.accounts.signTransaction went wrong. I have no idea to solve it.
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));

web3.eth.getAccounts(
    function (error, result){
    if(!error){
      console.log(result);
    } else{
      console.log(error);
    }
});

web3.eth.accounts.signTransaction({
        to: '0x93......',
        value: '1000000000000000000',
        gas: 2000000,
    },'19ec......', function (error, result){
        if(!error){
          console.log(result);
        } else{
          console.log(error);
        }
});

It returns
TypeError: web3.eth.accounts.signTransaction is not a function
    at Object.<anonymous> (C:\BC\coursetro-eth\test_web3.js:302:19)
[90m    at Module._compile (internal/modules/cjs/loader.js:956:30)[39m
[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)[39m
[90m    at Module.load (internal/modules/cjs/loader.js:812:32)[39m
[90m    at Function.Module._load (internal/modules/cjs/loader.js:724:14)[39m
[90m    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)[39m
[90m    at internal/main/run_main_module.js:17:11[39m

When I try another web3.eth.accounts, like web3.eth.accounts.hashMessage, it also returns the same problem.
web3.eth.accounts.hashMessage("Hello World", function (error, result){
    if(!error){
      console.log(result);
    } else{
      console.log(error);
    }
});

TypeError: web3.eth.accounts.hashMessage is not a function
    at Object.<anonymous> (C:\BC\coursetro-eth\test_web3.js:315:19)
[90m    at Module._compile (internal/modules/cjs/loader.js:956:30)[39m
[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)[39m
[90m    at Module.load (internal/modules/cjs/loader.js:812:32)[39m
[90m    at Function.Module._load (internal/modules/cjs/loader.js:724:14)[39m
[90m    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)[39m
[90m    at internal/main/run_main_module.js:17:11[39m

This is the web3 version that I installed
"dependencies": {
     "web3": "^0.20.7"
}


texts:
Can I force making changes to the value of variables not paying attention to require statement?
For example, I have the next code:
contract_runs = contract_runs + 1;
success = exchange();
require(success);

I want changes initiated by the exchange function to be applied only if success is true but increase contract_runs regardless of the value of this variable.


texts: Ethereum Uncles - What if there are conflicts?

texts:
In questions like here - In Ethereum, what is an uncle block? - people are saying that uncles are just being included in some of the next 7 blocks. So far so good.

What if a uncle is conflicting with the corresponding sibling block?

Is it discarded?
Can this concept being misused to attack the consensus?
How often does these conflicts occur?

To me the chance of having conflicts in two sibling blocks seems fairly reasonable, since both miners tend to choose the transactions with the most payout.


texts: Unable to Add Liquidity from ERC20 Token Contract

texts:
I am trying to include the Uniswap addLiquidityEth() function in this simple ERC20 token that I am deploying via Remix. When calling the addLiq() function, I get the rather unhelpful error message Warning! Error encountered during contract execution [execution reverted] which can be viewed here: https://rinkeby.etherscan.io/tx/0x9a46a0e6b4296649042c3105b80d346f94d128d0751dee3acb8d48650e37b182
The inputs I am using for the function are:

token: (address of deployed contract,
0xEf9831A8F063fB78747dC4F9C90A0E37b6eb8299)
amountTokenDesired:
5000000000000000000 (5 tokens)
amountTokenMin: 5000000000000000000 (5
tokens)
amountEthMin: 100000000000000000 (0.1 tokens)
deadline: 1622219281 (currently ~20 mins in the future)

I am including 0.1 ether in the attempted transaction, as can be seen on the error page.
The solidity code for the token is:
pragma solidity ^0.6.6;

interface IUniswap {
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);

}

interface IERC20 {
    function approve(address spender, uint256 amount) external returns (bool);
}

contract TestAddLiquidity {

    address internal constant UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;

    IUniswap public uniswap;

    constructor() public {
        uniswap = IUniswap(UNISWAP_ROUTER_ADDRESS);
    }

    function addLiq(address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        uint deadline) external payable {

        IERC20(token).approve(UNISWAP_ROUTER_ADDRESS, amountTokenDesired);
        uniswap.addLiquidityETH{ value: msg.value }(
            token,
            amountTokenDesired,
            amountTokenMin,
            amountETHMin,
            msg.sender,
            deadline
        );

    }

}```

What do I need to change in my code to successfully add liquidity through a function in the ERC20 token contract? How could I better troubleshoot this myself?


texts:
I am using solidity 0.5.0 when i compile code i am throwing exception as
Explicit type conversion not allowed from "bytes32" to "address".

code is working fine in remix IDE

and my code is as

function orderItem(uint _itemid,string memory _itemname ) public returns(address){
    address uniqueId = address(sha256(msg.sender,'block.timestamp'));
    packagemapping[uniqueId].isuidgenerated = true;
    packagemapping[uniqueId].itemid = _itemid;
    packagemapping[uniqueId].itemname = _itemname;
    packagemapping[uniqueId].transactionstatus = " Your package is ordered and is under processing ";
    packagemapping[uniqueId].orderstatus = 1;
    packagemapping[uniqueId].customer = msg.sender;
    packagemapping[uniqueId].ordertime = "block.timestamp";
    return uniqueId;
}

error line: address uniqueId = address(sha256(msg.sender,'block.timestamp'));


texts: Truffle .call() returns values with array index instead of keys

texts:
I am currently writing tests for solidity contract using truffle. When I invoke a function from the contract with .call(), the object that is being returned to me has the values included twice, once with their keys and a second time with an array index associated with the values.

For example, I would expect my return value to be:

{
  name: 'jeff',
  id: '0'
}

Instead, I am receiving:

{
  '0': 'jeff',
  '1': 0,
  name: 'jeff',
  id: '0'
}

While the correct data is there, it would make my tests much cleaner if I only received the key value pairs, and not this strange array structure in addition.

How can I prevent truffle from returning these duplicates?


texts: Function should return all objects stored in the mapping array

texts:
Here's my solidity code. And I want all the objects to be returned stored in mapping array contracts in the getContract method by giving address as a parameter to the getContract function.

pragma solidity ^0.5.0;

contract company {

    struct contractDetails {
        string contractId;
        string companyA;
        string companyB;
        address A;
        address B;
        uint256 timestamp;
        string signHash;
        bool isSigned;
    }

    mapping (string => contractDetails) contracts;
    mapping (string => string) hashMap;

    event contractSigned (
        string contractId,
        string companyA,
        string companyB,
        address A,
        address B,
        uint256 timestamp,
        string signHash,
        bool isSigned
    );

    function createContract(string memory _contractId, string memory _companyA, string memory _companyB, address _B) public {
        contracts[_contractId] = contractDetails(_contractId, _companyA, _companyB, msg.sender, _B, now, '', false);
    }

    function signContract(string memory _contractId) public {
        contractDetails storage signDetails = contracts[_contractId];
        signDetails.isSigned = true;
        signDetails.timestamp = now;
        emit contractSigned(_contractId, signDetails.companyA, signDetails.companyB, signDetails.A, signDetails.B, signDetails.timestamp, signDetails.signHash, signDetails.isSigned);
    }

    function verifySign(string memory _contractId) public view returns(bool) {
        contractDetails storage verify = contracts[_contractId];
        return(verify.isSigned);
    }

    function getContract(address _address) view public returns(/* Array containing all objects */) {
      /* Code Here */
    }
}


texts:
What is the XETH Wallet? I see it's some kind of wallet dapp on top of a geth instance.

But what is the Bitprofile and what makes it different to other wallets like Mist?


texts: Storing a monero address in smart contracts?

texts:
Assuming I would have to store Monero addresses or any cryptonote based coins addresses in a smart contract, would there be any issues?

Consider that those addresses are as long as this random monero address:

  43ZmqBKrvcL7nRYfTTrpngJ8M9bB6HyuvVnQzqJJW5Gai1ScVVDeSy5jDkKtt7qgB1Ld4Fx3MHEw1HkwZNPVkpmN7rhk9YT

The following smart contract stores the above address, however are there any drawbacks such as potential cybersecurity issues? Also could that smart contract be improved to be more efficient by storing the monero address as bytes rather than string??

pragma solidity ^0.5.1;

contract Addresses
{

string public moneroAddress;

function setAddress(string address_)public returns(bool)
{
moneroAddress = address_;
}
}


texts: How can I calculate the average time to mine a block?

texts:
How can I calculate the average time to mine a block knowing the current global hashrate?

My first gues is very simple: (global_hashrate / my_hashrate) * 15 [s]. So in my case (850 000 H/s) it will be

(887 [GH/s] / 850 [kH/s]) * 15 [s] = 1.04 * 1 000 000 * 15 [s] = 180 [days]

Am I right?


texts: Why isn't the from address included in a transaction?

texts:
Building transactions with ethereumjs-tx and I'm confused as to why the from address is not included in the transaction. The transaction parameters are:

• nonce - transaction nonce

• gasPrice

• gasLimit

• to - to Address

• value - amount to be sent

• data

• chainId - EIP 155 chainId - mainnet: 1, ropsten: 3

And the private key is used to sign the constructed transaction. But how does the ethereum network know from who to deduct the money from?


texts: How to recover my ether.li wallet with any other wallet software?

texts:
I am facing the following problem with my ether.li wallet, I never had Problems in the past with sending transactions but for the last two days transactions stopped working for me. Whenever I try to send ether, the message "Request initiated by (user account)" pops up. Ether.li stopped asking for approval and according to etherscan a transaction is beeing made from my user account to my wallet contract adress charging me a TxFee but no internal transaction is beeing generated.

Did the ether.li wallet stopped working for everyone or am I missing a crucial point here?

I am not very educated in this technology but I would be grateful for any response.


texts: Migrating or representing a Microsoft SQL Database on the Chain

texts: I am wondering what is the best way to migrate or represent a massive, 50 table, Medical Health Records SQL Database on the Blockchain.  Is it best done with IPFS hash on Ethereum or is Hyperledger a better solution?


texts: How strings are stored in Solidity on a low level?

texts:
So, the question is in the title, let me describe scenario:

I make raw rpc call via method eth_call to contract Token to a function name to get token name of type string. Below is my original response and some metrics:

Original response: 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000557494e4753000000000000000000000000000000000000000000000000000000
Length of response (with 0x prefix): 194
Formatted uncut response:               // just whitespace
Formatted cut response (only last 32 bytes): WINGS
Unused bytes (first 64 bytes): 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000005

It would be great to understand what lays in those first 64 bytes and how is it calculated.

First I thought that it is somehow related to RLP, but I didn't find any evidence of that, so this is just my assumption.

Thanks for help.

P.S.: For formatting I used this answer.


texts:
constructor(string memory enterOrganizationName) public {
    owner = msg.sender;
    status = true;
    addUser(0, "", "");
    addUser(owner, 'Creator and Owner of Smart Contract', "");
    organizationName = enterOrganizationName;
    numberOfUsers = 0;
    addEndorsee(0, "");
    numberOfEndorsees = 0;
}

giving below error.

TypeError: Invalid type for argument in function call. Invalid implicit conversion from int_const 0 to address requested.
        addUser(0, "", "");
                ^

I'm still new in Ethereum platform so I'm not sure what that error means.


texts: Ethereum Yellow Paper: "more powerful" statement question

texts: I have a question regarding the following statement in the current Ethereum yellow paper. It states that a state and it's transition function is really powerful than any-other existing comparable system. Further explanation would be helpful to understand. Thanks in advance.


texts: Is is possible to insert objects into an Array at the specified position and shift indexes?

texts:
I have following code piece:

  struct PaymentReceipt{
    uint   start_block;
    uint   end_block;
  }
  PaymentReceipt[] paymentReceiptList;

  function verfiyPayment(uint block_start, uint block_end) returns (bool success) {
    paymentReceiptList.push(PaymentReceipt({start_block: block_start, end_block: block_end }));
    return true;
  }

As I know, each new Struct will be pushed on top of the stack, so latest element (paymentReceiptList.length) will always point to the latest pushed Struct.

https://github.com/ethereum/wiki/wiki/Solidity-Features:

  Dynamically-sized storage arrays have a member function push, such
  that var l = arr.push(el); is equivalent to arr[arr.length++] = el;
  var l = arr.length;.

For example, Java has following approach that: we can insert the specific element at the specified position in the list.

[Q] Is it possible to push an object into an Array with a given index and shift indexes, like the example on Java?


texts: Error when writing --datadir in terminal

texts:
I'm trying to follow this tutorial :

https://hackernoon.com/heres-how-i-built-a-private-blockchain-network-and-you-can-too-62ca7db556c0?lipi=urn%3Ali%3Apage%3Ad_flagship3_messaging%3B0b%2F8A0z8RdyP%20D3E%2F%20bJLA%3D%3D

I am not exactly sure if I am following the steps correct but I get an error when I write the command in the terminal CustomGenesis.json --datadir

The error is:

  This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.

Does anyone can help me solve this error and explain me what it is?


texts:
I bought some ETH back in 2018.  I kept it in a wallet app on my Mac then I forgot about it.  I have changed my Mac since then.
I think the app was just called Ethereum Wallet.  I recorded a key that looks like this:
154f61a5-dc90-8193-1123-94e22718d67b (not the actual key)
How can I recover my ETH?


texts: Are there cases where you don't want to explicitly declare a variable as memory or storage?

texts: I am writing a solidity project and I have added the memory keyword to every variable I don't want to store under storage. Are there cases when I shouldn't be using the memory keyword or the storage one?


texts: Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings

texts:
Getting error while creating ethereum raw transaction

var rawTx = {
  nonce: '0x2a',
  gasPrice: '0x4a717c800',
  gasLimit: '0xc340',
  to: '0x73F7Ced8cc9D27DC426210c32fc6d0a40f941eE1',
  value: '0x2386f26fc10000',
  data: '',
  chainID: 4
}
var cTx = await new EthereumTx(rawTx, { 'chain': 'rinkeby' });
cTx.sign(privateKeyInBuffer);


texts: How to get Ethereum transaction list by address in java web3j quickly?

texts:
Im trying to fetch transaction logs from ganache using web3j library to send it as an api ,is there any way where i can get all transactions from ganache quickly?

@GetMapping("/test")
public List<Transaction> test() throws InterruptedException, ExecutionException, IOException {
    String address = "0xeedc155ae507fb0a9becae6315286183a23229b0";
    List<Transaction> transactions = new ArrayList<Transaction>();
    Web3j web3j = web3jConfig.initializeWeb3j();
    System.out.println("test Running.......");
    BigInteger block = web3j.ethBlockNumber().send().getBlockNumber();
    System.out.println("blockno:" + block.intValue());
    int block_no = block.intValue();

Flowable<Transaction> replyBlocks   = web3j.replayPastTransactionsFlowable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST);
replyBlocks.forEach(temp->{
    System.out.println("into replyBlocks");
    System.out.println(temp.getBlockNumber());
        transactions.add(temp); //It's an collection object,and value is not adding into it
})  ;

    return transactions;
}

web3j.replayPastTransactionsFlowable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST); *this function is working fine when print data to console but don't know why its not adding its data into an List object which i want to send as an api


texts:
I'm building a basic analytics framework for the Ethereum blockchain.  As a first step I need to extract the data and I'd like to do this in Python.  I've been using Geth as a client on OSX and so, as far as I understand, the blockchain is stored locally at ~/Library/Ethereum/chaindata in LevelDB, i.e. in binary files like 496355.ldb.

How do I parse the .ldb files?  Is there a Python library I can use for this?  I've looked at pyethereum but am not sure where to look as the documentation is pretty sparse.
I can use the etherchain.org API but this would involve many API calls and will probably make the good people at etherchain.org unhappy.  This is why I prefer to parse the blockchain as stored locally on my machine.  But ignoring this problem for a moment, does anyone know a short guide to the result of an API call for transaction data resulting in data like this:

{'accountNonce': '200642',
   'amount': 2678970350000000000,
   'blockHash': '0x47525d00eab0dcd87e9f8b0e9de2fe9f553f72576ef4f892ace49b2832e985bd',
   'block_id': 1039153,
   'gasLimit': 21000,
   'hash': '0x41bb75d8b20ae7e23fa7457d21a30a4007d0eb97fdb887caac834b759eeb3572',
   'isContractTx': None,
   'newContract': 0,
   'parentHash': '0x41bb75d8b20ae7e23fa7457d21a30a4007d0eb97fdb887caac834b759eeb3572',
   'price': 50000000000,
   'recipient': '0x30906581413d556de1a018adbe6cc63c88d58512',
   'sender': '0x2a65aca4d5fc5b5c859090a6c34d164135398226',
   'time': '2016-02-21T18:53:56.000Z',
   'txIndex': None}

I believe I understand most of this data but would really appreciate more information to fill in the gaps of my understanding.


texts: My mist browser Win64 0.6.2 doesn't show up

texts:
I was downloading the blocks in the test-network and when I noticed it stopped downloading. I decided to restart the app. resulting into this:

This is what I see for a brief second before showing the first picture, what can I do. The wallet is still on the test-network. I don't know how to put it back to the main net.

Redownloaded, restarted my pc didn't fix the problem either.


texts: What does idx mean or do in this contract?

texts:
Here is a contract from https://www.etherchain.org/account/0xc18a451d4ef2a85e7bf8404131c5f994a98bdb15#code

What exactly does idx mean or do?

    function enter() {
    if (msg.value < 500 finney) {
        msg.sender.send(msg.value);
        return;
    }

    // add a new participant to array
    uint idx = participants.length;
    participants.length += 1;
    participants[idx].etherAddress = msg.sender;
    participants[idx].amount = msg.value;

    // collect fees and update contract balance
    if (idx != 0) {
        collectedFees += msg.value / 10;
        balance += msg.value;
    }
    else {
        //code
    }


texts: I am looking at coming up with a ERC standard to define X509 standards. Understand there is ERC725, ERC 735. Wanted to know if there are any existing ERC standards for this?


texts: How do I see how much ether was sent to a contract when it was called?

texts: I want to implement a contract where users are required to deposit a certain amount of money in order to participate. If the user doesn't send enough money, I simply want to send it back to them and not include them in the protocol. How do I see how many eth msg.sender sent to the contract when they called it? Is this even possible?


texts: Truffle & TestRPC: how to use another address for transaction / sendTransaction Function parameters

texts:
I have a Smart Contract, created / migrated with Truffle to TestRPC. TestRPC provides several default accounts. If I call functions within the Smart Contract from the Truffle console it does that always from the same address, even if when I set web3.eth.defaultAccount = 'anotherAddress';.

What I want is to be able to call functions from different addresses provided by TestRPC. How can I achieve that?

And if I want to use web3.eth.sendTransaction, where I can specify from and to how do I specify the parameters of the function?

Thanks


texts: 'Assert' and 'require' atomicity while internally calling another contract

texts:
contract one{

unint number;

function saveNumber(unint _number){ number = _number; }

}

contract two{

function callOtherFunctionAndAlsoTransferFunds(){

oneContract = one('contractaddress');
oneContract.saveNumber(6);
assert(msg.sender.transfer(10000000));

}
}

The line I am concerned about is

 assert(msg.sender.transfer(10000000));

Can I do this ?
If this throws an exception, will the internal transaction that called contract one also be reversed ?


texts: I know we cannot use Smart contract to be used as large database. But my client is asking for proof. Can you guys provide any link that will support this.


texts: What happened in 2016 so that "2GB cards stopped working" for mining?

texts:
I know this is a terrible question.  I am trying to figure out what a friend asked me.  We were talking about mining ETH and he said:

  Back in 2016 2GB cards "stopped working" and that means that if the
  same thing happens again 8GB cards might be necessary

What could that mean?  Was there a difficulty adjustment in 2016 that made a certain class of GPU cards obsolete for mining ETH?  Was it part of ice age?


texts:
I'm trying to understand why assembly for this sum is required?
// 1
        _structHash = keccak256(
            abi.encode(
                _blockhash,
                totalAddresses,
                gasLeft,
                _externalRandomNumber
            )
        );
        _randomNumber  = uint256(_structHash);
        assembly {_randomNumber := add(mod(_randomNumber, _maxNumber),1)}
        winningNumbers[0]=uint8(_randomNumber);


texts: Where can I find and check the source code of a token

texts:
How can I find the source code for a token launched via an ICO? What is for instance the source code for this token and where do I find it: https://tokenmarket.net/blockchain/ethereum/assets/herocoin/

p.s. could be any other ico, I just want to be able to check before investing what they programmed into the token.


texts: If for each setter I can get the blockchain state at the moment and make it queryable, will I still need events?

texts:
That question came as part of understanding better the role of events in Ethereum.

Can the mechanism which index the blockchain state at each setter and makes it queryable for all parties can replace the need for emitting events?

The only reason I can think of is to eliminate the trust of the party who manages that indexing and make it queryable.


texts: Truffle promise: Why reassign instance in callback?

texts:
In the Truffle documentation, for interaction with contracts, the returned contract instance is assigned to meta before being interacted with:

var account_one = "0x1234..."; // an address
var account_two = "0xabcd..."; // another address

var meta;
MetaCoin.deployed().then(function(instance) {
  meta = instance;                               // <- Reasignment!
  return meta.sendCoin(account_two, 10, {from: account_one});
}).then(function(result) {
  // If this callback is called, the transaction was successfully processed.
  alert("Transaction successful!")
}).catch(function(e) {
  // There was an error! Handle it.
})

Why do this?


texts: Command line command to get last block hash

texts:
In order to know last block hash in bitcoin I can just call

bitcoin-cli getbestblockhash

from command line.

Is there something like that in ethereum or I should use RPC and curl?


texts: Is the result of getBlockByNumber final?

texts:
Will the result of getBlockByNumber change due to the longest chain issue?

Say, I called getBlockByNumber(100000) now and got block A. 10 mins later, it turns out block A is not in the longest chain. Will the result of getBlockByNumber(100000) change then?


texts: Pushing/Pulling data from data storage contract

texts:
Is there any way I can have a smart contract that stores the a value and name and then is callable from another smart contract? Something like this..(but that works)

Contract D {
    struct Document{
      string name;
      uint value;
    }

    function StoreDocument(bytes32 key, string name, uint value) returns (bool success) {
     var doc = Document(name, value);
     documents[key].push(doc);
     return true;
    }
}

And then I would like another contract to take the key, contract address, and name and be able to return the value to use in a contract.  Any help would be great.

Contract E {
    function RetrieveData(address ConDadd, bytes32 key, string name) {
    //some funciton to get the data from Contract D
    }
}


texts:
My question is a little odd, but I will ask it anyways.

From a development perspective, knowing that there is a service such as Infura, why would a developer download the whole ledger? Infura provides a ready ethereum node that will allow the dev to interact with.

Is there value from operating the node yourself? I know having a personal node means being in full control of the node but can you elaborate? Please provide examples I'm just starting out with ethereum.

from another question linked

  It means that one direct benefit for you is that you won't have problem with overloaded tier nodes that would prevent you from including your transactions on the network. You'll still have problem including your transaction to a block as mining nodes may include transactions with higher fees first, but at least you will skip the first obstacle.

Getting your transactions in the network faster, this is definitely a benefit for the developer. Are there others?


texts:
I am developing a dapp/smart contract, where users will be able to sell/buy NFTs from each other (market). Users grant authority to the smart contract to sell any of their items on their behalf using the setApprovalForAll openzeppelin function. Once this authority granted, users can put their items on sale. I am having difficulty understanding how to actually execute a sale. If another user accesses the front-end dapp with their wallet to purchase an NFT from another user, since they are initiating the token transfer, the transfer fails since they are obviously not authorised to initiate this transfer (but only the owner and the contract are). How is this logic usually implemented in such smart contract so that the purchaser (initiating the transfer) has the ability to buy an item from another owner. Do I need to transfer the token ownership to the smart contract? I thought that the setApprovalForAll function was meant to avoid this.
 // Front-end Code
 let totAmount = price + commission
 this.contInst.methods.tokTransfer(tokOwner, this.account, aId, price, commission).send({
    from: this.account,
    value: this.web3.utils.toWei(totAmount, 'ether')
    }).then((receipt) => {
    ...
    }

 // Smart Contract Code
 function tokTransfer(address payable from, address to, uint256 tokenId, uint256 price, uint256 commission) payable external {
    safeTransferFrom(from, to, tokenId);
    ...
 }

Thank you. J


texts: How secure is the update-process of Ethereum-Wallet & Co

texts:
Today I installed (again) an update for my Ethereum Wallet by downloading a file (Ethereum-Wallet-macosx-0-9-0.dmg) from https://github.com/ethereum/mist, checking it's md5 sum and then just installed it.

But how can I be sure that this version is not tampered with? Both the download source and the md5 hash are published on the same site (github.com) and secured by a single SSL-certificate. As we know the SSL-chain of trust is weak by it's design - ok for everyday transactions but I do not know a single bank which solely depends on SSL when it's customers money is at stake.

Does anyone know a more secure (at least redundant) way of checking if the code I run is released by a trustworthy party?


texts: geth reports nothing after allocating cache and handles

texts:
INFO [05-16|10:32:21] Starting peer-to-peer node               instance=Geth/v1.6.1-stable-021c3c28/windows-amd64/go1.8.
  1
  INFO [05-16|10:32:21] Allocated cache and file handles         database=C:\Users\Tariq\AppData\Roaming\Ethereum\ge
  th\chaindata cache=128 handles=1024

the disk is being used by geth while this is happening, and then after say 20 minutes? geth closes it self,
do i have to redownload the blockchain? is there another solution since it takes quite some time for me to sync.


texts:
I'm exploring option to add parity peers, however my my peers are in a different networks. Should I still use internal IPs that are visible when starting a parity?

I've loaded reserved peers and used parity_netPeers method to pull list of connected peers. Nodes from the list are there, however protocol field is null both for eth and pip, which means that they are not connected.

What am I doing wrong?


texts:
I was going through the solidity docs and in a contract example given I have seen keccak256 used.
// Perform checks to determine if transferring a token to the
// `OwnedToken` contract should proceed
function isTokenTransferOK(address currentOwner, address newOwner)
    public
    pure
    returns (bool ok)
{
    // Check an arbitrary condition to see if transfer should proceed
    return keccak256(abi.encodePacked(currentOwner, newOwner))[0] == 0x7f;
}

From this video I was able to understand that:

A hash function is a function that takes in an arbitrary size input
and outputs data of fixed size.

I also understood that keccak is a hash function.
When is hashing used when creating a smart contract? What is its purpose? An example would really help me understand.


texts: How to connect to Rinkeby without using Geth / Parity?

texts:
First let me explain my development environment. I am using Jupyter Notebook to play around with the Web3.py front-end code and Remix for the Solidity smart contract code. I am using the Metamask wallet

firstly i configure the Metamask wallet to pick the Rinkeby network. The i use the Remix IDE to configure it to use Rinkeby, using Injected Web3.

I want to connect to the Rinkeby testnet, using an Infura RPC URL like this;

https://rinkeby.infura.io/v3/YOUR_INFURA_API_KEY_GOES_HERE

and i succeed in doing so through the Web3.py code.

when i call a function, which is a call and not a state modifying function, it works fine

e.g the below code works

contract.functions.getMessage().call() # displays a message string

However, whenever i try to make a transaction or call a state modifying function in the contract, say something like

tx_hash = contract.functions.setMessage('Call from Jupyter').transact()

It gives me the following error

  The field extraData is 97 bytes, but should be 32. It is quite likely that you are connected to a POA chain.

  Refer http://web3py.readthedocs.io/en/stable/middleware.html#geth-style-proof-of-authority for more details.

  The full extraData is:
  HexBytes('0xd883010900846765746888676f312e31322e34856c696e757800000000000000d2c6d883001d158bf0718c1dc64b2809d4c90c9a9450324c22be595e598205e85f5f73d61bd864b3aac4e7ec8f101564cde8faf72cd3ef52b15d3c8a3c6ab6c900')

( I have spaced out the error, into 3 parts, to allow for more legibility )

From what i read in the provided link, i have to use Geth or Parity to successfully conduct transactions on test networks like Rinkeby.

I am also quite confused with the IPC provider mentioned in the above link. I have no idea how to use it ( i think it conflicts with HTTP provider, which is what i intend to use. but feel free to elaborate and clear up any misconceptions on this )

However, if i don't want to use Geth or Parity, is there any method i can use to  connect to Rinkeby and conduct transactions by simply using my Infura URL and Web3.py ?

Please let me know any prospective solution or even any relevant work around to this issue

Many thanks


texts:
I am receiving the error: 'TypeError: Operator == not compatible with types bool and uint256'

my code is:

if (orderedScreening[0]/4 == orderedScreening[1]/4 == orderedScreening[2]/4 == orderedScreening[3]/4 == orderedScreening[4]/4) {
              f = true;
              }

^orderedScreening is a dynamic uint array.

I have already tried:

if (uint(orderedScreening[0]/4) == uint(orderedScreening[1]/4) == uint(orderedScreening[2]/4) == uint(orderedScreening[3]/4) == uint(orderedScreening[4]/4)) {
                  f = true;
                  }

and:

a = orderedScreening[0];
b = orderedScreening[1];
c = orderedScreening[2];
d = orderedScreening[3];
e = orderedScreening[4];

    if (a/4 == b/4 == c/4 == d/4 == e/4) {
                      f = true;
                      }

I also tested:

if (orderedScreening[0] == orderedScreening[1] == orderedScreening[2] == orderedScreening[3] == orderedScreening[4]) {
              f = true;
              }

and received the same error. How can I resolve this error?


texts: Ethereum: How to create node and access it?

texts:
I created address using web3.py and get balance of it.
Result is '0'. It's OK.
But provider URI is 'https://api.myetherapi.com/eth'(indicated here)
I think this is live net.
I want to test in testnet.
How can I create ethereum node and use it?
(Is that I create ethereum node necessary?)


texts:
I'm a Ruby newbie and I need to implement a Geth-compatible key import/export in Ruby.

I was looking at the Geth implementation in Go, as well as keythereum. For generating the key, I am using the Gem https://github.com/se3000/ruby-eth. I verified with Geth that it generates the correct address for the private key.

This is what I have:

require "eth"
require 'fileutils'
require 'json'
require 'openssl'
require 'securerandom'
require 'test/unit'

class SimpleTest < Test::Unit::TestCase

  def test_create_keys

    # hardcoded password
    password = "password"

    # create new keypair using https://github.com/se3000/ruby-eth
    # This key generates address a8a659893d9d458d7c9ae88215c55f6a7cc561e6
        keypair = Eth::Key.new priv: "a0d10d8045ed900e74a0a662e288646569f12a1624efcaed0c639d1f6d09e993"

        # key version
        version = 3

        # Generate key uuid v4
        uuid = SecureRandom.uuid

        # address
        address = keypair.to_address

        # more on aes-128-ctr:
        # https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_.28CTR.29
        cipher_name = "aes-128-ctr"
        cipher = OpenSSL::Cipher.new cipher_name

        # iv "Initialization Vector"
        iv = SecureRandom.random_bytes(16) #store this with the generated value

        # Derive encryption key from password
        # kdf = key derivation function, for password-based keys
        digest_name = "sha256"
        prf = "hmac-" + digest_name
        digest = OpenSSL::Digest.new digest_name
        key_length = 32
        salt_length = 32
        iterations = 65536
        salt = SecureRandom.random_bytes(salt_length) #store this with the generated value
        derived_key = OpenSSL::PKCS5.pbkdf2_hmac(password, salt, iterations, key_length, digest)

        # Encrypt private key with key derived from password
        cipher.encrypt
        cipher.iv = iv
        iv = cipher.random_iv
        cipher.key = derived_key
        encrypted = cipher.update([keypair.private_key.to_hex].pack("H*")) + cipher.final

        # Generate mac
        derived_key_hex = derived_key.unpack("H*")[0]
        encrypted_hex = encrypted.unpack("H*")[0]
        mac = Eth::Utils.keccak256(derived_key_hex[32, 64] + encrypted)

        json = {
            "address" => address,
            "crypto" => {
                "cipher" => cipher_name,
                "ciphertext" => encrypted_hex,
                "cipherparams" => {
                    "iv" => iv.unpack("H*")[0]
                },
                "mac" => mac.unpack("H*")[0],
                "kdf" => "pbkdf2",
                "kdfparams" => {
                    "c" => iterations,
                    "dklen" => key_length,
                    "prf" => prf,
                    "salt" => salt.unpack("H*")[0],
                }
            },
            "id": uuid,
            "version": version
        }

        file_name = "UTC--" + Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%LZ") + "--" + address

        FileUtils.mkdir_p 'keystore'
        File.open("keystore/" + file_name,"w") do |f|
            f.write(json.to_json)
        end
  end

end

In Geth, I see my generated address, but I can't unlock the account with the password I have used.

> personal.listAccounts
["0xa8a659893d9d458d7c9ae88215c55f6a7cc561e6"]
> personal.unlockAccount("0xa8a659893d9d458d7c9ae88215c55f6a7cc561e6")
Unlock account 0xa8a659893d9d458d7c9ae88215c55f6a7cc561e6
Passphrase:
could not decrypt key with given passphrase

Something wrong in my implementation, but I can't find the issue.


texts: What percentage of the transaction cost is related to persistent data storage?

texts: Simple question I guess.  Of the total transaction cost for a typical ethereum block, how much do people spend on storing data vs executing code?  Where can this statistics be found for the chain as a whole?


texts: Generating an address from a public key in C++

texts:
Example:

Input key = 0x025f37d20e5b18909361e0ead7ed17c69b417bee70746c9e9c2bcb1394d921d4ae

Output address = 0xd09D3103CcABfb769eDc3e9B01500Ca7241D470A

I have been using an algorithm from keccak-tiny.c by David Leon Gil, with the following change:

Padding with 0x01 instead of 0x06: 7 bytes of message "testing" give me 5f16f4c7f149ac4f9510d9cf8cf384038ad348b3bcdc01915f95de12df9d1b02 as is in "Which cryptographic hash function does Ethereum use?"

In "Generating an address from a public key" is algorithm, but I have questions:

how exactly means getPublic,keyFromPublic ?
before keccak I must convert from a 33-byte key to a 65-byte key (address will be compact-independent) or keccak is applied on hex string text form, not bytes?
how checksum address with upper/lower case?

How to do it with C++?


texts:
I just installed Parity (1.8.2) and made sure that it is fully synced, and am running into a couple of weird issues. (I installed Parity on a MacBook via Homebrew, config is all at default values)

I can connect to my local node using MetaMask via http://localhost:8545, but cannot connect to it using MEW (downloaded/offline version). I keep getting this error:

  Could not connect to the node. Refresh your page, try a different node (upper right corner), check your firewall settings. If custom node, check your configs.

I notice that I've a similar issue as described here: https://github.com/kvhnuke/etherwallet/issues/922, I don't see a Request Payload.

When using Parity's Javascript console, commands like web3.eth.blockNumber, web3.eth.syncing all work and return values. However, when I install web3.js via npm, and then run the following:

var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://127.0.0.1:8545'));

Commands like web3.eth.blockNumber all return undefined. However, web3.eth.getBlockNumber().then(console.log); returns a value.

Thanks for the help!

Update:
I've also tried all of the below commands (or combination of them):

parity --jsonrpc-cors '*' --jsonrpc-hosts all --jsonrpc-interface all

parity --jsonrpc-cors '*' --jsonrpc-hosts all --jsonrpc-interface all --rpccorsdomain 127.0.0.1

None of them work. MEW is throwing this error (in Console):

  index.html:1 Failed to load http://127.0.0.1:8545/: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.


texts: newPendingTransactions returning old transactions

texts:
I'm building an application where i need to keep track on new pending transactions.
I'm somehow receiving old pending transactions, an example is this one
https://etherscan.io/tx/0x716544baa4987e72265c001ecd953dad8a36383b786a06211fe6ce86d80841c6
Which has been pending for 11 days. How does this come through the newPendingTransactions subscription?
Thanks in advance!


texts:
I am doing some gas analysis work and I really want to find or generate a dataset for historical SafeLow gas prices as defined by EthGasStation:

“A price that at least 5% of the network hashpower will accept.
(I don’t want to wait for hours for a confirmation)

AND

A price that was mined within a reasonable time (< 50 blocks) the last time
it was posted to the network as a pending transaction.
(i.e. protect against scenario where miners were previously accepting low gas
prices but have now changed their policies, and the transactions are no longer
confirming)”

SafeLow is a 50-block moving average. The ideal dataset for me would contain a daily average/median of all 50-block SafeLow's for that day and would range back to 01/01/2017.

Does anybody know of such a dataset?

I know that etherscan offers a dataset of avg gas prices, but those are always above 10gwei even when SafeLow is 1gwei. I am also aware the ethgasstation-backend is open source but I figured I'd ask this question before diving in to try to get it to do this analysis for me.


texts: web3.sha3 dealing with hex in both geth and web3.js

texts:
in both geth and web3.js, when we call

> web3.sha3("0x536f6d6520415343494920737472696e6720746f20626520686173686564")

we get:

requirement of using web3.fromAscii before sha3 is deprecated
new usage: 'web3.sha3("hello")'
see https://github.com/ethereum/web3.js/pull/205
if you need to hash hex value, you can do 'sha3("0xfff", true)'
"b21dbc7a5eb6042d91f8f584af266f1a512ac89520f43562c6c1e37eab6eb0c4"

So I proceed to do this:

> web3.sha3("0x536f6d6520415343494920737472696e6720746f20626520686173686564",true)

upon which I get:

"bf328f7c064d78daf8fa3e2ffe36c1c3cb22ae02832d4ead2995130ca21a8524"

This does not match the original value that I intended to get, namely

"b21dbc7a5eb6042d91f8f584af266f1a512ac89520f43562c6c1e37eab6eb0c4"

I was wondering if someone could explain to me why the two values are different.  The reason I'm asking is that I'd like to sha3 this:

sha3("0xfff")

which gives me a invalid byte index error, but I know that

sha3("0xfff",true)

is not going to get me what I want, based on the above observations.


texts: Noob having trouble connecting to the Infura Mainnet

texts:
I've been attempting to run a script from my terminal, and have been getting this error:

  Error: CONNECTION ERROR: Couldn't connect to node https://mainnet.infura.io.

I've installed Web3j on my local machine, and unless I'm missing something, I've successfully generated a token (though it'd be great if Infura's site had some way to confirm that the digits I previously saved when doing so are correct).

So from here, I tried the the following command:

Web3j web3 = Web3j.build(new InfuraHttpService("https://morden.infura.io/your-token"));

And it's telling me:

  syntax error near unexpected token `('

I'm so green that I'm unsure where the specific syntax error may be - or even if running this command was the right step to take.  I swapped out "your-token" for the 20 digits I understood my token to be comprised of, to make sure that's clear.

Appreciate any help.  Thanks!


texts:
I need to connect geth rpc using https://60.248.172.3 in web3.js because my website is running in secure mode(https://example.com)
I tried this and got error:

geth --rpc --rpcaddr "https://60.248.172.3"

  Fatal: Error starting protocol stack: listen tcp: address
  https://60.248.172.3:8545: too many colons in address

How can I add https:// in start of my ip(60.248.172.3) using --rpcaddr?

The main issue is chrome browser can't allow web3.js to send ajax post request to http://60.248.172.3:8545 when my site is opened with https://example.com(https)


texts: Return values after verifying an account balance on private network

texts:
When i verify the balance of an account after deploing an ERC20 token, i receive this returns:

  BN { negative: 0, words: [ 50, <1 empty item> ], length: 1, red: null }

I know that "50" is the number of token. May someone explain me what do the other things mean please?


texts: What would web3.js respond with in this case?

texts:
I have a mapping to a struct in my contract

mapping (uint=> Student) students;

struct Student {
    bool passed;
}

Now I want to call a particular student with a particular ID to see if he has passed a course or not. I'll do that using

students[ID].passed

Which is ok. What I want to know is that if the student passed the course at a later point of time, and I assign the same ID to a new block, what would

students[ID].passed

return?


texts: How to catch reverted transaction while using metamask

texts:
I'm working with metamask and was testing a transaction that should trigger a revert statement inside my contract. When the error is thrown metamask gives the following output:

this was while using Firefox with Metamask extension installed

the following is the result of using on Chrome without the metamask extension

So as you can see i suppose the error message the extension gets its the same as the one on screenshot #2

and here is the code that produces the throw

my question is, do we have a way of catching these errors in a more 'elegant fashion' so we can know what caused the error or this the only way of catching such errors.

The approach i'm using here is similar to How to catch JSON RPC exception in front end web3
EDIT:
here is my contract's code:

pragma solidity ^0.4.18;

contract Ive {

    address public creator;
    address public owner;

    mapping (address=>bool) allowedVisitors;
    address[] allowedVisitorsList;

    struct Client {
        address wallet;
        string apellido1;
        string apellido2;
        string apellidoCasada;
        string nombre1;
        string nombre2;
        string fechaNacimiento;
        address modifiedBy;
    }

    Client[] private clients;

    event OwnerAssigned(
        address creator,
        address owner
    );

    event VisitorAllowed(
        address owner,
        address newVisitor
    );

    event VisitorDisallowed(
        address owner,
        address newVisitor
    );

    modifier onlyAllowed() {
        if(allowedVisitors[msg.sender] == false)
            revert("Account is not allowed to obtain client info");
        _;
    }

    modifier onlyCreator() {
        if(msg.sender != creator)
            revert("Only creator can execute this action");
        _;
    }

    modifier onlyOwner() {
        if(msg.sender != owner)
            revert("Only owner can execute this function");
        _;
    }

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

    function setClientInfo (
        string apellido1,
        string apellido2,
        string apellidoCasada,
        string nombre1,
        string nombre2,
        string fechaNacimiento
    )
        external returns (uint)
    {
        Client memory newClient;

        newClient.apellido1 = apellido1;
        newClient.apellido2 = apellido2;
        newClient.apellidoCasada = apellidoCasada;
        newClient.nombre1 = nombre1;
        newClient.nombre2 = nombre2;
        newClient.fechaNacimiento = fechaNacimiento;
        newClient.modifiedBy = msg.sender;

        clients.push(newClient);

        return clients.length;
    }

    function getClientsLength () view public returns (uint) {
        return clients.length;
    }

    function setOwner(address _owner) onlyOwner external {
        owner = _owner;
        allowVisitor(_owner);
        // emit OwnerAssigned(msg.sender, _owner);
    }

    function obtainOwner() view external returns (address){
        return owner;
    }

    function allowVisitor(address visitor) public {
        if(!allowedVisitors[visitor]) {
            allowedVisitors[visitor] = true;
            allowedVisitorsList.push(visitor);
            emit VisitorAllowed(msg.sender, visitor);
        }
    }

    function isAllowedAccount(address account) view public returns (bool) {
        return allowedVisitors[account];
    }

    function disallowVisitor(address account) onlyOwner external {
        allowedVisitors[account] = false;
        emit VisitorDisallowed(msg.sender, account);
    }

    function getVisitorsLength() view public returns (uint) {
        return allowedVisitorsList.length;
    }

    function obtainClient(uint32 index) view onlyAllowed public returns (string, string, string, string) {
        return (clients[index].nombre1, clients[index].apellido1, clients[index].fechaNacimiento, clients[index].apellido2);
    }

    function getAllowedVisitors() view onlyOwner public returns (address[]) {
        return allowedVisitorsList;
    }

}


texts: Do I even need users to sign in to my Dapp if I'm using MetaMask? Or could I just use their public address? Any action they try take in the Dapp will need to be agreed upon by them in any case through MetaMask.


texts: Contract changing another contract's state

texts:
In my system, users can request to be verified by a trusted contract. When a user creates an account he deploys this contract (omitting non-related parts)

pragma solidity ^0.4.11;

contract User {
    // State variables
    address owner = msg.sender;
    bool verified = false;
    uint creationTime = now;
    struct PersonalInfo {
        string firstName;
        string LastName;
        string email;
    }
    uint level = 0;

    function requestVerification(address trustEntity) {
        /*
            This function should send a verification request
            to a trust entity's contract
        */
    }
}

There is a known trusted entity, whose contract address will be known to everyone, who should be the only entity capable of verifying the users.
Its contract (omitting non-related parts) is

pragma solidity ^0.4.11;

contract TrustEntity {
    address owner;
    address registry;
    address[] public pendingRequests;

    function verifyUsers(address user) {
        /*
            Whenever a user requests verification, his
            address should be pushed to the pendingRequests
            array, so it can then be fetched to verify or
            reject
        */
    }
}

Every example I see of a contract interacting with another contract, they're both in the same file (docs, this question) so I don't know if it is possible for a contract to call another contract (or, in this specific case, to push an address into another contract's state variable / change another contract's state variable).


texts: What is the shortest bytecode that will publish a contract with non-zero bytecode?

texts:
Yes, it's golf. So sue me.

Rules

The response to getCode() should have some characters that aren’t either 0 or x.

To test it out, you can use the following with a local testrpc:

web3.eth.sendTransaction({data:'BYTECODE', from:web3.eth.accounts[0]});
web3.eth.getCode('THE_ADDRESS');

Or you can use the evm command that comes with Geth:

evm --debug --code BYTECODE run.

Example:

This is a valid, but long-ish example: 0x600180600b6000396000f3

Don't spoil it

If you use a leading >! before your answer

  it will be hidden


texts:
I have the following contract, with just one function, which is to accept the ether sent.

According to the docs, all addresses have a balance member. Why doesn't the commented line below compile then? The error on the offending lines are: TypeError: Expression has to be an lvalue.

pragma solidity ^0.4.15;

contract testbalance {

     function() payable {
       address myAddress = this;
       myAddress.balance += msg.value; // doesn't work
       myAddress.balance += msg.value;   // doesn't work too
     }

}