texts: What is best what to store a string's compressed version on a smart-contract?

texts:
Storing string is expensive on smart-contracts and charge us expensive fees even if we want to store them in Events. Instead I want to store each string's decoded version in a smart-contract in order to save some memory and gas-fee charge. Overall, when I return string's decoded version, it also should be able to decoded into the original string.

As an example I want to pass my string as compressing base64 input format and its code. But when I stored compressed base64 string on a smart-contract, its returned version is not same as the one I passed.

Example example.js:

var Base64String = require('./base64-string');

var string = "QmWmyoMoctfbAaiEs2G46gpeUmhqFRDW6KWo64y5r581Vm";
console.log("Size of sample is: " + string.length);
var compressed = Base64String.compress(string);
console.log("compressed:" + compressed)
console.log("Size of compressed sample is: " + compressed.length);
string = Base64String.decompress(compressed);
console.log("Sample is: " + string);

Results node example.js: //as you can see 46 length string is compressed into 19 length.

Size of sample is: 46
compressed: ł斦쪃⡲ퟛƨ蒳憸幒桪ᔐ훨ꖨ릯鼵嗐
Size of compressed sample is: 19
Sample is: QmWmyoMoctfbAaiEs2G46gpeUmhqFRDW6KWo64y5r581VmAA

Passed base64 compressed string: //I want to store it on my smart-contract.

ł斦쪃⡲ퟛƨ蒳憸幒桪ᔐ훨ꖨ릯鼵嗐

Contract.set("ł斦쪃⡲ퟛƨ蒳憸幒桪ᔐ훨ꖨ릯鼵嗐");

From the smart-contract its returned version seems not same as the string I passed. // Contract.get()

ł斦쪃⡲<d7db>ƨ蒳憸幒桪ᔐ훨<a5a8>릯鼵嗐

Overall: "ł斦쪃⡲ퟛƨ蒳憸幒桪ᔐ훨ꖨ릯鼵嗐" != "ł斦쪃⡲<d7db>ƨ蒳憸幒桪ᔐ훨<a5a8>릯鼵嗐"

Please note that I have tried this on remix-solidity.

-

pragma solidity ^0.4.0;
contract Contract {
    string str;

    function set(string val) public {
        str = val;
    }

    function get() public constant returns (string) {
        return str;
    }
}

Please also not that we can provide string's IPFS-hash, but still I want to compress the IPFS-hash which will bring the string size from 46 to 19, this will save nearly around more than half memory.

So possible approach would be:

Large File → IPFS-hash (46 characters) → compress base64(IPFS-hash) (19 characters)

[Q] How should I pass compressed base64 string into a smart-contract? or basically what should I do to store my string compressed version on a smart-contract that when I returned it, it should match with the string I passed?

Thank you for your valuable time and help.


texts: Getting "insufficient funds for gas * price + value" with geth on Ropsten no matter what

texts:
I'm having geth 1.7.3 (tried 1.8.x too) running in docker container:

  --verbosity 4 -rpc --nousb --ipcdisable --rpcaddr "0.0.0.0" --rpccorsdomain "*" --syncmode "fast" --rpcapi="db,personal,eth,net,web3,admin" --cache=${CACHE_SIZE:-512} --testnet --networkid 3 --unlock "0x2fe90fe5e4f90cc07c00512888a4ced12015blabla" --password "/misc/key_password.txt"

I'm getting "insufficient funds for gas * price + value" no matter what gas price i set for transaction:

  20:39:54.914 [main] DEBUG HttpLoggingInterceptor - {"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf88a80874e28e2290f000082c35094b63550b69a502d579e5406e59f5e7b4079810b4480a4c3e190eb00000000000000000000000000000000000000000000000000000000000000051ba077b3aa0489b93c54bfbdec5a1ade540118b669ec7bfe1e2f46cf491ecc10abbda06819146122246134012781d9a1dbb3a818f555a8f88716ac7fec7604fa3a3bab"],"id":104}

  20:39:54.924 [main] DEBUG HttpLoggingInterceptor - {"jsonrpc":"2.0","id":104,"error":{"code":-32000,"message":"insufficient funds for gas * price + value"}}

I've tried programmatically with java web3j and with Remix IDE connected to geth over http://127.0.0.1:8545.

I've tried to set average gas price 22 Gwei but getting this error. Tried 22 * 1000 Gwei but having the same.

Any geth arguments missing? Is it correct that i don't have to mine on my ethereum node to make it working (there are another miners on Ropsten)?


texts: Is there the start/stop script of geth after Debian/Ubuntu booting?

texts:
Is there any start/stop shell script for geth which is executed after Debian or Ubuntu OS boot up?

For example, startup scripts usually located under

/etc/init.d/
/etc/rc.local


texts: Why lastblockhash validation mismatch in integration tests but unit tests all pass

texts:
I have successfully built go-ethereum (release/1.3.5) and godep with go v1.5.1 on LINUX 14.02.  When I run 'godep go test ./...' all of the existing unit tests pass beautifully.  I can also run geth with testnet with no problems.  However, when I run the integration tests ('ethtest --test all' or 'ethtest --test --file BasicTests' for example), I see a "lastblockhash validation mismatch" in ChainAtoChainB_blockorder1.  At the Go language level, the problem appears to be an attempt to access a slice that hasn't been allocated.

I don't see anyone else reporting this problem, so I suspect that I've missed a step in setting up my environment, but I can't figure what I've missed.  Does this sound familiar to anyone?


texts: Is reading data free unlike a transaction?

texts:
I understand that writing data to a smart contract is a transaction and it will cost gas. Will reading data from blockchain cost gas?

For example, I have a struct to collect data about a person - name, age, gender. Now I seeded 1000 persons during contract initialization. Can I query to get all the Persons information? Can I write a function to iterate through the mapping Persons and return all the records? Please let me know if there's any efficient way to do this and if this will cost gas.

struct Person {
    uint age;
    string name;
    string gender;
}
mapping(uint => Person) Persons;


texts: Why setting balanceOf instead of just using public variable in ERC20 tokens?

texts:
Good day,

ERC20 specify the following 2 functions as its most important ones:

function balanceOf(address _owner) constant returns (uint256 balance){}
function transfer(address _to, uint256 _value) returns (bool success){}

But the balanceOf function is nothing more than a fancy way to access the info stored inside a simple mapping array.
Why not just set the balances mapping array to be public and be done with it?

mapping (address=>uint) public balanceOf;

I feel as if I'm missing something here.
As always, your help is appreciated.


texts:
I have a fresh new installation of Ubuntu 16.04 and I've followed manual to setup geth

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo add-apt-repository -y ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install ethereum

And after starting geth it hangs up on

I0925 07:53:21.655924 node/node.go:308] IPC endpoint opened: /home/username/.ethereum/geth.ipc
I0925 07:53:21.656651 p2p/server.go:576] Listening on [::]:30303

0 peers, nothing happens, no syncing. htop shows occasional activity in CPU, console answers but shows 0 peers:

geth attach
Welcome to the Geth JavaScript console!

instance: Geth/v1.5.0-unstable/linux/go1.6.2
coinbase: 0x4c49eed9cc104695593cd2a9745ce108e28efc09
at block: 0 (Thu, 01 Jan 1970 03:00:00 MSK)
 datadir: /home/username/.ethereum
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> net.listening
true
> net.peerCount
0

Am I doing something wrong?


texts:
ApprovalContract.sol

pragma solidity ^0.5.1;

    contract ApprovalContract{
    address public sender;
    address payable public reciever;
    address public constant approver=0xe05cE3f89b5Ab28d6d2Ac8A503473Cd5A23e616a;

    function deposit (address payable _receiver)external payable{

        require (msg.value > 0);
        sender=msg.sender;
        reciever=_receiver;
    }

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

    function approve () external payable {

        require (msg.sender==approver);
        reciever.transfer(address(this).balance);
    }
    }

2_deploy_contract.js

const ApprovalContract = artifacts.require("ApprovalContract");

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

For testing, ApprovalContract.js

const ApprovalContract = artifacts.require('ApprovalContract');

console.log("something");
  contract('ApprovalContract', function(accounts) {

    it('initiates contract', async function() {

      const contract = await ApprovalContract.deployed();
      const approver = await contract.approver.call();
      assert.equal(approver, 0x0feeede47d471276377ed83e3ef749995fc0ebe2, "approvers don't match");
    });
    it('takes a deposit', async function () {
      const contract = await ApprovalContract.deployed();
      await contract.deposit(accounts[0], { value: 1e+18, from: accounts[1] });
      assert.equal(web3.eth.getBalance(contract.address), 1e+18, "amount did not match");
    });
    it('makes the transaction when approved, approver: ' + accounts[2], async function () {
      const contract = await ApprovalContract.deployed();
      await contract.deposit(accounts[0], { value: 1e+18, from: accounts[1] });
      await contract.approve({ from: accounts[2] });
      assert.equal(web3.eth.getBalance(contract.address), 0, "didn't transfer ether");
    });
});

truffle compile,truffle migrate run successfully. When I do truffle test,this error comes-

1) Contract: ApprovalContract
   takes a deposit:
 AssertionError: amount did not match: expected {} to equal 1000000000000000000
  at Context.<anonymous> (test/ApprovalContract.js:15:14)
  at <anonymous>
  at process._tickCallback (internal/process/next_tick.js:189:7)

2) Contract: ApprovalContract

makes the transaction when approved, approver: 0xAD90b2dd2A7E8091349A96e50c4112E1EA0159fE:
 Error: Returned error: VM Exception while processing transaction: revert
  at Object.ErrorResponse (/home/neha/.nvm/versions/node/v8.16.0/lib/node_modules/truffle/build/webpack:/~/web3-core-requestmanager/~/web3-core-helpers/src/errors.js:29:1)


texts: How to execute Smart contracts on a private Blockchain network

texts: I have created a private Blockchain network on my Windows system with one node.  I have created accounts and was able to transfer ethers across them. Now I want to deploy smart contracts on this network, how should I accomplish this task?


texts: I understand that the underlying consensus model changes from PoW to PoS. However, will it also result in changes to how wallets interact with the network? Will transaction fees still have to be paid to get a transaction processed?


texts:
I've been tring to code a bot to run on pancakeSwap and for some reason, all the transactions I try with this script keep getting reverted.
API_URL = 'https://data-seed-prebsc-1-s1.binance.org:8545/' #testnet
CONTRACT_ID = Web3.toChecksumAddress('0xc3f9c723ce06ee0fa420c8c88cee115fa0147748')

SENDER_ADDRESS = '00'
SENDER_PRIVATE_KEY = '00'

ROUTER_ADDRESS = '0xD99D1c33F9fC3444f8101754aBC46c52416550D1' #pancakeswap V2 router tesnet
Spend = Web3.toChecksumAddress('0xed24fc36d5ee211ea25a80239fb8c4cfd80f12ee') #spend binance

Receive = CONTRACT_ID
max_approval_hex = f"0x{64 * 'f'}"
max_approval_int = int(max_approval_hex, 16)
w3 = Web3(Web3.HTTPProvider(API_URL))
contract = w3.eth.contract(address=ROUTER_ADDRESS, abi=ABI)

erc_20_contract = w3.eth.contract(address=Spend, abi=ERC20_ABI)
nonce = w3.eth.get_transaction_count(SENDER_ADDRESS)

#send coin to router
approve_txn = erc_20_contract.functions.transferFrom(SENDER_ADDRESS, ROUTER_ADDRESS, 1).buildTransaction({
    'from': SENDER_ADDRESS,
    'gas': w3.toWei('250000', 'wei'),
    'nonce':  nonce,
})
signed_txn = w3.eth.account.sign_transaction(approve_txn, private_key=SENDER_PRIVATE_KEY)
w3.eth.send_raw_transaction(signed_txn.rawTransaction)

#approve the coin
approve_txn = erc_20_contract.functions.approve(ROUTER_ADDRESS, max_approval_int).buildTransaction({
    'from': SENDER_ADDRESS,
    'gas': w3.toWei('250000', 'wei'),
    'nonce': nonce + 1,
})
signed_txn = w3.eth.account.sign_transaction(approve_txn, private_key=SENDER_PRIVATE_KEY)
w3.eth.send_raw_transaction(signed_txn.rawTransaction)

start = time.time()
pancakeswap_txn = contract.functions.swapExactTokensForTokens(
    100,
    10,
    [Spend, Receive],
    SENDER_ADDRESS,
    (int(time.time()) + 1000000)
).buildTransaction({
    'from': SENDER_ADDRESS,
    'gas': 100000,
    'gasPrice': w3.toWei('100', 'gwei'),
    'nonce':  nonce + 2,
})
signed_txn = w3.eth.account.sign_transaction(approve_txn,
              private_key=SENDER_PRIVATE_KEY)
w3.eth.send_raw_transaction(signed_txn.rawTransaction)

I've tried approving and not approving and the results are the same.
I'm running on binance TestNet and I have BNB on my testnet wallet.


texts: Storing gas in a contract for next interaction to be "free"

texts:
I have a contract where the user has to interact twice.

Is it possible to deposit GAS and store it in the contract for the first interaction, so the later interaction will be "free"? (and additional gas will be refunded to the user).


texts:
We need a template of a fully workable crowdsale contract
It should be with the time frame and we should specify rate and the wallet where all raised funds will go


texts: Is it possible to create an ethereum smart contract using remix from the browser of your android device and then linking it to your android ether wallet app without using a PC anywhere along the token creation process?


texts: Restrict a method call on one contract by another contract

texts:
This is very similar to another question. I was wondering if it is a proper design to have a function to transfer ownership. In the example below, I am trying to restrict Dao.add to be called only by Service.add. Are the following steps correct:

Create Dao contract
Create Service contract with the address of Dao contract
Call Dao.transferOwnership with the address of Service contract
Call Service.add

Code:

pragma solidity ^0.4.11;

contract Dao {

    address public owner;

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

    modifier onlyOwner {
        require (msg.sender == owner);
        _;
    }

    function transferOwnership(address newOwner) onlyOwner {
        owner = newOwner;
    }

    struct Lookup {
        uint id;
        string name;
    }

    mapping(uint => Lookup) internal lookupById;

    function getLookupById(uint _id) public constant returns (uint, string) {
        return (lookupById[_id].id, lookupById[_id].name);
    }

    function add(uint _id, string _name) onlyOwner {

        Lookup memory newLookup;
        newLookup.id = _id;
        newLookup.name = _name;
        lookupById[_id] = newLookup;
    }
}

contract Service {

    Dao dao;

    function Service(address daoAddress) {
        dao = Dao(daoAddress);
    }

    function add(uint _id, string _name) {
        dao.add(_id, _name);
    }
}


texts: Length of state array is not changeable in Solidity

texts:
Consider there are 3 contracts: BankA, customer, and BankB.BankA transfers some ethers to customer and after that some customer's state variables must be changed (in a better words be updated). It must also happen for BankB and customer. But the changes are not stable and their values return back to default.

customer:

pragma solidity^0.5.12;
contract customer{
  address payable[]  public onboarded;
  bytes public fullname;
  bytes public id;
  bool public KYC;
  uint256 public categor;
  function prime(bytes memory fname, bytes memory iden, bool KYCresult, uint256 level, address payable bank) public{
    fullname=fname;
    id=iden;
    KYC=KYCresult;
    categor=level;
    onboarded.push(bank);
  }
  function() external payable{}
  }
function Array() public returns(uint256){
return onboarded.length;
}

BankA==BankB:

pragma solidity ^0.5.12;

import "./customer.sol";
contract BankA{
  function creation() public returns(string memory){
    customer client=new customer();
    client.prime("Alireza Kiakojouri","5000077563", true, 2, here);
    return uint2str(uint(client.Array()));
  }
  function uint2str(uint _i) internal pure returns (string memory ) {
    if (_i == 0) {
        return "0";
    }
    uint j = _i;
    uint len;
    while (j != 0) {
        len++;
        j /= 10;
    }
    bytes memory bstr = new bytes(len);
    uint k = len - 1;
    while (_i != 0) {
        bstr[k--] = byte(uint8(48 + _i % 10));
        _i /= 10;
    }
    return string(bstr);
  }
  function() external payable{}
  }

Whenever i call creation function of BankA in Truffle, it represents length of the onboarded array equal to "1" that is true:

But whenever i call creation function of BankB, it represents "1" again while it should be "2".

What is the problem and is there any solution? Thank you.


texts: Why does confirm that there is always 1 block apart on the mainnet when initiate multi-transactions simultaneously- by web3.py and Infura.io

texts:
1.I have a need to initiate multiple transactions to the same contract address in the fastest time and get confirmation from the network. Means that multiple transactions are recorded in the same block.

2.By use Web3.py and  Infura.io .On the kovan network test was pass.But on Mainnet each transaction initiated at the same time was confirmed on the block separated by 1 block.

3.Gas limit was 1 million，gas price was instant maximum price.

4.Nonce is no question.I get the first transaction nonce through getTransactionCount(), then the second transaction is set by myself (nonce+1) to ensure the correctness of the nonce, and the test is passed on the kovan network.


texts: How to get type of a contract internal transaction?

texts:
I'd like to get type(create, call, ...) of a contract internal transaction, like [this page of etherscan.][1]
However, I couldn't find it any responses and documents of web3js.

I'm getting a contract internal transaction by following procedure.

Use eth.getTransactionReceipt() about a transaction.
See a contractAddress property in the response of step 1.
If the contractAddress property has an address, the transaction is a contract internal transaction.

Is this right ?

However, if the procedure is right, the response of step 1 does not have type of a contract internal transaction. Also a response of eth.getTransaction() about same txHash as step 1 does not have type of contract internal transaction.

I saw this post.
However I couldn't uncderstand clearly.
Is it impossible getting type of contract internal transaction?

My environmet is here.

geth:1.9.11-stable
web3js:2.0.0-alpha.1


texts: What diagrams exist to illustrate the Ethereum blockchain creation process?

texts:
I have found the below diagram (and this explanation) useful in understanding how blockchains work in general:

 [Illustration by Matthäus Wander (Wikimedia)]

This answer goes on to say that

  Ethereum's actual blockchain structure is somewhat more elaborate...

I'd like to understand how the turing complete smart contract programming language fits into Ethereum's blockchain creation and confirmation.

This diagram, from here, shows a similar diagram, adapted for Ethereum:

What other diagrams are there to illustrate the Ethereum blockchain process and overall architecture?


texts: How to check if key exists in array of bytes?

texts:
I have an array of bytes10 inside a mapping, like this:

mapping(uint => bytes10[]) public Players;

I want to check if a certain index exists in the bytes10 array.
I tried to check it with .length but it throws opcode error when the index does not exist.


texts: i want to know the limit request on etherscan API with API key, and limit if we go on paid service. thanks in advance.


texts: Does address.send(0) make an actual call or simply return false?

texts:
Does address.send(0) makes an actual message call forwarding some small amount of gas(2300?) to fallback function or does it simply return false without making a message call to another contract? It wouldn't be unreasonable to assume that EVM detects 0 value and simply returns false, because what's the point of making a call in this case if there's nothing to send?

I'm asking this, because I want to understand how this example from a post on security works

contract auction {
  address highestBidder;
  uint highestBid;
  mapping(address => uint) refunds;
  function bid() {
    if (msg.value < highestBid) throw;
    if (highestBidder != 0)
      refunds[highestBidder] += highestBid;
    highestBidder = msg.sender;
    highestBid = msg.value;
  }
  function withdrawRefund() {
    uint refund = refunds[msg.sender];
    refunds[msg.sender] = 0;
    if (!msg.sender.send(refund))
     refunds[msg.sender] = refund;
  }
}


texts: Why would gasLimit be read as 4,700,036 instead of 4,712,388?

texts:
I have the Block Gas Limit of a private Parity-based blockchain set to 4,712,388.  That's the "gasLimit" parameter.  But when I view it on a block explorer on the very first block running on this network, it reads it as 4,700,036.  That is a factor of 1.0026281/

And when I set it as 44,712,388, it reads in as 44,364,406.  That is a factor of 1.0078437.  So it's not consistent.

There must be some reason though.  Right?


texts: Why does Solidity use an invalid jump instead of an invalid opcode for throws?

texts:
In Solidity's 0.4.9 release:

  Internal exceptions are now thrown by using an invalid opcode (0xfe),
  manual exceptions still use an invalid jump.

and

  Code generator: Internal errors (array out of bounds, etc.) now cause
  a reversion by using an invalid instruction (0xfe - EIP141) instead of
  an invalid jump. Invalid jump is still kept for explicit throws.

Why the difference?  Is there an advantage to using an invalid jump destination rather than the 0xfe opcode for explicit throws?


texts: Simple but important question: How to get the value of contract's state when using Metamask?

texts:
I'm designing an HTML file (or a user interface: UI) for my smart contract.

let's assume that my contract has a state as follows:

address public owner;// it is set to "0x5574Da45Ce5115055BB46c668D9982868ABd1382" when the contract's deployed

As we all know, to get the value of "owner" we can use the following command line in "geth":

myContract.owner.call({from: "0xEE42224D91492247da80724CAD937C2273f1D5ed"})

But the above code does not work if I use it in my HTML file (I get an error mentioned here). It should have the following form to let Metamast work with it (might be other way too, but I'm not aware of it):

myContract.owner.call({from: "0xEE42224D91492247da80724CAD937C2273f1D5ed"}, function(err, result) { if(!err)
// do something
});

Apparantly the value allocated to "owner" is stored in "result". But I don't know how to get it and print it on my HTML page!

Question: How to get/store the value returned by the above callback function?

Note that we can use console.log(result) in the above function but, in this way, the result does not still appear on the webpage and it appears in the background.


texts: ETH stolen from two MEW wallets & moved to an unknown address & then to ShapeShift

texts:
I recently found out that my ETH funds were stolen from two MEW wallets and moved to an unknown address.

Below are addresses of my two MEW wallets.

1) 0x16bf750Ee569F0A173BCCfD7b3F92F9Bb46c6AfC (19.99 ETH stolen)
https://etherscan.io/address/0x16bf750Ee569F0A173BCCfD7b3F92F9Bb46c6AfC

2) 0xe781A741342e35d21C12352a8e3465bED03e8109 (24.99 ETh stolen)
https://etherscan.io/address/0xe781A741342e35d21C12352a8e3465bED03e8109

The above funds were stolen and moved to an unknown address below, and last moved to ShapeShift:
0xD8d594f8dAba1091c5cbECD99Bc84DC15359E2a2
https://etherscan.io/address/0xd8d594f8daba1091c5cbecd99bc84dc15359e2a2

The above 2 wallets were created in Sep 2017 about 148 and 145 days ago.  The funds were stolen in Nov 2017 about 62 days later as seen from https://etherscan.io/.

When I created the above wallets, I had my keystore file (JSON) stored offline (in a USB), and also my printed paper wallet stored offline at a safe place.
I did not visit any phishing sites before.  When checking balance in the wallets, I only used etherscan.io, and did not use the private keys to open the wallets.  I followed every security procedure suggested from MyEtherWallet site on how to protect my funds.

I just could not think of a reason how the funds got stolen.  It is almost impossible to happen with the fact that the funds were stolen 2 months later.
With the JSON file containing the password (second layer of security) for access, I would rule out that this was used to steal the funds.

However, with the printed paper wallet containing the private key,  I have a strong opinion that somebody managed to brute force the private keys.  I have a question below.

Question on Creating Paper Wallets from MEW

I would like to ask whether it is possible to assign a password/ pin when creating a paper wallet from MyEtherWallet site.  What I mean is if I would like to access funds on my paper wallet, I would first need to enter the private key printed on the paper and then enter the password created as an additional security step.  Is it possible to assign a password/ pin when creating paper wallets from MyEtherWallet site as a second layer of security?

I also have thought of using Trezor or Ledger hardware wallets for storing ETH.
They are more secure than generating your own MEW paper wallets for storing ETH.

I am wondering if anyone could offer any advice on the above question and any useful security measures that I can take in future.

Thank you


texts: Is it possible to upload a file to IPFS using HTML's  tag?

texts:
I'm trying to upload a file to IPFS and display the returning hash address on a browser using JavaScript and HTML. But I don't know how to handle the JavaScript API.

My HTML code:

<p id="text"> This is the IPFS address </p>

<input type="file" id="myFile">

<button onClick="submitFile()"> Submit </button>

My JavaScript code looks something like this (assuming to be linked from an external file):

submitFile(){
   var tempFile = document.getElementById('myFile').value;
   var nameHash;

   ipfs.add(tempFile, function(err, hash) {
      nameHash = hash;
   }

   document.getElementById("text").innerHTML = nameHash;
}

I know I am missing a lot of stuff. I've been trying to read the documentation on GitHub but it just gets more confusing.

Specifically, I don't know how to manage the modules. As in, which one am I supposed to import and what do I do with them once that is done?

Reference: https://www.reddit.com/r/ipfs/comments/4cf6pe/ipfs_browser_file_upload/

Reference: https://www.npmjs.com/package/ipfs-js


texts: selfdestruct: why am I able to execute the function containing selfdestruct(...) twice?

texts:
I have created the following contract with a destroy function invoking selfdestruct:
pragma solidity >=0.5.0 < 0.7.0;

contract Terminate{
   function destroy() public {
      selfdestruct(msg.sender);
   }
}

$ truffle consoletruffle(development)>

undefined
truffle(development)> T = await Terminate.at('0xA79abEbDb5396053aC4Be4b73282fFef060e410A');
undefined
truffle(development)> await T.destroy();
{ tx:
'0xaaf88fb64a0531d4dd708bbd58908cbf931549519ddbf5e7c5cea40ff30a7bc7',

Now if I try to call 'destroy()', it would be again executed. I thing I must get some error message because I have already destroyed the contract.

truffle(development)> await T.destroy(); { tx:
'0x96166648453aa8653c194e055590849e6bef028ef6017e3e894690b3270f3ff4',
receipt:    { transactionHash:
'0x96166648453aa8653c194e055590849e6bef028ef6017e3e894690b3270f3ff

Why I couldn't destroy the contractusing my earlier call to destroy?
I have stored a copy of the contract in the Github:
> here
Somebody please guide me how to kill the contract using selfdestruct?
Zulfi.


texts: Is it possible on Ethereum to create a token this way?

texts:
Can I make a token using Geth or another Dapp or method and meet these conditions:

a) I should be able to create the token conveniently without too much programming involved
b) I should be able to list the token on a decentralized exchange
c) I should be able to distribute the token to a list of 100 Ethereum addresses at once without paying more than about 0.01 USD in transaction fees


texts:
uint256 public max_contribution = 50 ether;
    uint256 public min_contribution = 0.1 ether;
function transfer(address to, uint tokens) public payable returns (bool success) {
    require(msg.value >= min_contribution);
    require(msg.value <= max_contribution);
    balances[msg.sender] = safeSub(balances[msg.sender], tokens);
    balances[to] = safeAdd(balances[to], tokens);
    emit Transfer(msg.sender, to, tokens);
    return true;
}

using this to set the minimal ETH investement, still receiving tokens when sending 0.1> amount of ETH. Testing on the testnet. Any ideas?
Contract: 0xb1a89c746ecec28bfdf7f06f44b603bf9c035be8 with verified code.


texts: Missing create2 opcode in ethereum yellow paper

texts:
In eip 1014 Vitalik added Create2 at opcode 0xf5

  Adds a new opcode at 0xf5

But in ethereum yellow paper opcode i don't see opcode 0xf5 or any create2 opcode, it doesn't appear in https://www.ethervm.io/ either. But in https://github.com/crytic/evm-opcodes opcode 0xf5 create2 appears in it.

My question: why does ethereum yellow paper doesn't have anything about it, even they have add new opcode in 0xf5? Is it because they forget to add it?


texts: Calling parent method with multiple inheritance

texts:
I have the following contract definition:

contract MyToken is StandardToken, Ownable {
  ...
  function transfer(address _to, uint256 _value) public returns (bool){
    require(...);

    // would like to call StandardToken's transfer function here
  }
}

I've tried doing:

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

but that didn't work:

  TypeError: Referenced declaration is neither modifier nor base class.


texts: Can a mined block have an odd number of transactions? If so, how does the Merkle root in that case?

texts: Merkle Tree pairs transactions and hashes them and the process continues till we get to the root. But how would this pairing process work if the number of transactions were odd?


texts: If I'm expecting ether and provide the wrong address, what happens?

texts: When expecting to receive ether from someone, is the ether lost if i provided a wrong address? Or can the transaction then not compute?


texts: {'message': 'Nonce too low', 'code': -32000} when sending transaction on geth JSON-RPC

texts:
I am trying to send a transaction using Go Ethereum 1.4.18-stable JSON-RPC and I am getting the following error:

     {'message': 'Nonce too low', 'code': -32000}

This is a single transaction on dedicated node on Ethereum testnet. My question is that what could be the cause for this issue

Have internal file structures of node damaged (it has lost track of nonce
Is node simply out of sync


texts:
After mining the hash value for the new block, How many nodes can confirm the correctness of the hash value by miner?
In one of blockchain paper, all other nodes must mutually confirm the correctness of the hash value. I think that it is impossible to all other nodes can participate in confirming the correctness.


texts: Option to give passphrase via web interface

texts:
I am trying to run the sample web3.js code from here

https://github.com/ethereum/web3.js/blob/master/example/event_inc.html

I am running the geth node on testnet. However, when I try to create the contract, I am prompted for my account passphrase in the geth console.

Is there any option to provide the passphrase via the web interface to authenticate the user?


texts: Correlation between network difficulty and total hash rate

texts:
I am expecting a linear relationship between difficulty and hash rate. If I generate a scatter plot between the two variables I can see a linear relationship, but also values that are not on the line (in red frame of figure). I tried to correlate this with protocol changes, but this was not successful. Why are this values of the line?

The data is borrowed from https://etherscan.io/charts
The information about the forks I have found here: http://list.wiki/Ethereum_Forks

You can find the code to generate the plot in https://gist.github.com/Slebi/1e1e614dcccc7e04424da5126c80c0a6


texts: How can ethereum be used to send messages between connected machines?

texts:
I want to know how I can send messages between accounts and contracts.

The idea is that I have three Raspberry Pi devices. Each one is connected to an object (the first to a temperature sensor, the second to a LED and the third one to an LCD).

I want to create an autonomous system in which these objects can communicate through the Ethereum network.

How can I use Ethereum to send messages between connected machines?


texts: Can the unitsOneEthCanBuy value be changed after Token creation?

texts:
How can I change the value of "unitsOneEthCanBuy" in the contract ?
 (As the Token is only created & ICO has n't happened)


texts: Buliding geth from source does not make Solidity available

texts:
I've made a fresh install of go-ethereum from source on Ubuntu and Fedora, launched it and expected to find Solidity available when doing eth.getCompilers(), but I get an empty list instead.

I have then installed Solidity explicitly, as described in the tutorial here, restarted geth, but that changed nothing. I installed the package to be available globally with npm -g and I can see the package being available if I try importing it from a console node session.

I am not using the c++ client, too, so I don't have the solc exectuable installed, but I seem to understand that it is not needed if I do the npm installation.

What am I missing? Thanks.


texts:
I'm doing a dry run of a mainnet to get the total gas cost/
Replacing 'Migrations'
 > Total cost:         0.000343902 ETH

Replacing 'EthText'
> Total cost:         0.001205478 ETH

Summary
=======
> Total deployments:   2
> Final cost:          0.00154938 ETH

That's 1549380 Gwei.
The Truffle docs set the default value of gasPrice to 100000000000 (100 Shannon).
So, is Shannon the unit Truffle is expecting for gasPrice?
Do I need to convert the 1549380 Gwei to Shannon?  Or is Gwei?
The docs are sort of confusing.


texts: sending ether Transaction failed when executing multiple transaction

texts:
I am sending ether to an array of addresses. I am getting the nonce value from eth_getTransactionCount. But problem is that the first transaction is successful but for the rest of the transactions are not because the value of nonce is same as of first.

below is the code

 function signTransaction($t, $v, $d = '0x', $mt1 = "latest", $addr = '0x') {
    global $user_details;

    if($addr == '0x') {
        $user_address = $user_details['address'];
    } else {
        $user_address = $addr;
    }

    $dt = [$user_address, $mt1];
    $nonce = infuraReq('eth_getTransactionCount', $dt, 'bchexdec');

    $dt = [
        'nonce' => $nonce,
        'from' => $user_address,
        'to' => $t,
        'amount' => $v,
        'data' => $d,
        'privkey' => privateKey()
    ];

    $rData = [
        'rawdata' => $dt,
        'signed' => web3Req('signtransaction', $dt, 'POST')
    ];
    return $rData;
}

How do I solve this issue? Note: I cannot keep on changing the gas value as number of addresses are very high.


texts:
I am developing a light wallet for a private network. I use ethereumjs-accounts for storing accounts locally and ethereum-tx for signing transactions. I have deployed custom token-contract. Here is my txParams object:
        nonce: nonce, //transaction count
        gasPrice: "0x0", //private network do not need gas
        gas: "0x0",
        from: account, //sender account
        to: contractParams.address,
        value: "0x0",
        data: this.contractInstance.sendFunds.getData(
            '0x07a204163f78bf9293c996f8c6d98a058a324b2d',
            '0xd9f0443219296744c91929fc0818b3e42d90b2eb',
            2,
            ''
        ) //calling functions to send tokens from 1 account to another

Than I sign the transaction and send it to the chain:
    let tx = new EthereumTx(txParams);

    tx.sign(privateKey);

    let serializedTx = '0x' + tx.serialize().toString('hex');

    this.web3.eth.sendRawTransaction(serializedTx, (err, hash) => {
        if(err) {
            console.info(err);
        }else{
            console.log('Transaction hash: ', hash);
        }
    });

After sending the transaction I receive tx hash but nothing more happens. I can get transaction by hash for 30-40 seconds after sending and then the transaction disappears, and if I try to get it after 40 seconds - I get null.
Any ideas what can cause this problem and how to debug it?
Transaction object from web3.eth.getTransaction();


texts:
This is the code I use to get all events from a certain contract.

Solidity:

event NewEvent(address indexed contractAddress, address newBOPAddress, address payer, uint commitThreshold, bool hasDefaultRelease, uint defaultTimeoutLength, string initialPayerString);

web3 code:

event = Factory.contractInstance.NewBOP({contractAddress:'0x384da3....'},{"fromBlock": 0, "toBlock": 'latest'});

event.get(function(err, res) {
  if(err){
    console.log(err.message);
  }
  else{
    console.log(res);
  }
});

If I specify a fromBlock that is relatively young, I get a fast response and everything works fine, if I use a block that is around 200,000 blocks in the past, I get this timeout error:

  Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.

I tried this on ropsten with different nodes (metamask, myetherapi, infura) but always have the same problem. I aquired a private node with quicknode.io, which doesn't solve the problem, for users that need to use public nodes. I know that I could use a newer "fromBlock", but I would like to use the events of my factory contract as historical data, so I can display it to the user. And I found a few sources supporting, that it is technically possible, especially with indexed arguments to filter on:

https://media.consensys.net/technical-introduction-to-events-and-logs-in-ethereum-a074d65dd61e (part 3)

How to access the event log by knowing the contract address (web3)? (uses different filter options)

My exact question is: Do I need a full private node in every case for the desired performance, or are there other reasons / ways to make the event filtering faster (to stop the timeout)?

Thanks for any answer!


texts: How do I get access to uPort from a mobile Browser

texts: I've developed a simple DApp that uses uPort and it works fine on Desktop - where I can login through uPort with the QR Code. On a mobile browser (Anrdoid Chrome) I'm auto directed to uPort where it asks me to "continue", then I'm redirected back to my app on mobile where the URL now has a hash of /access_token="{token-here}" But now uport.requestCredentials() doesn't return the uPort Profile. Am I supposed to manually grab the access token in the url and do something with it?


texts:
I have this simple contract

pragma solidity ^0.4.10;

contract test {

  int _multiplier;
  struct MyCustomData {
    bool exists;
    string Name1;
  }
  mapping(string => MyCustomData) myData;

  event Multiplied(int indexed a, address indexed sender, int result );

  function test(int multiplier) {
    _multiplier = multiplier;
  }

  function multiply(int a) returns (int r) {

    myData["a"] = MyCustomData(true, "aa1");

    r = a * _multiplier;
    Multiplied(a, msg.sender, r);
    return r;
  }
}

when I deploy and run the following code all looks good.

public async Task ContractTest()
{

  var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c";
  var password = "password";

  var abi = @"[{'constant':false,'inputs':[{'name':'a','type':'int256'}],...";

  var byteCode = "0x6060604052341...";

  var multiplier = 7;

  var web3 = new Web3();

  var unlockResult = await web3.Personal.UnlockAccount.SendRequestAsync(senderAddress, password, new HexBigInteger(120));
  Assert.IsTrue(unlockResult);

  var transactionHash = await web3.Eth.DeployContract.SendRequestAsync(abi, byteCode, senderAddress, new HexBigInteger(900000), multiplier);
  var receipt = await MineAndGetReceiptAsync(web3, transactionHash);

  var contractAddress = receipt.ContractAddress;

  var contract = web3.Eth.GetContract(abi, contractAddress);

  var multiplyFunction = contract.GetFunction("multiply");

  var multiplyEvent = contract.GetEvent("Multiplied");

  var filterAll = await multiplyEvent.CreateFilterAsync();
  var filter7 = await multiplyEvent.CreateFilterAsync(7);

  var gas = await multiplyFunction.EstimateGasAsync(69) ;

  transactionHash = await multiplyFunction.SendTransactionAsync(senderAddress, 7);
  transactionHash = await multiplyFunction.SendTransactionAsync(senderAddress, 8);

  receipt = await MineAndGetReceiptAsync(web3, transactionHash);

  var debuginfo = await web3.DebugGeth.TraceTransaction.SendRequestAsync(transactionHash,
        new TraceTransactionOptions { DisableMemory = true, DisableStorage = true, DisableStack = true });

  var log = await multiplyEvent.GetFilterChanges<MultipliedEvent>(filterAll);
  var log7 = await multiplyEvent.GetFilterChanges<MultipliedEvent>(filter7);

  Assert.AreEqual(2, log.Count);
  Assert.AreEqual(1, log7.Count);
  Assert.AreEqual(7, log7[0].Event.MultiplicationInput);
  Assert.AreEqual(49, log7[0].Event.Result);
}

public async Task<TransactionReceipt> MineAndGetReceiptAsync(Web3 web3, string transactionHash)

{

  var miningResult = await web3.Miner.Start.SendRequestAsync(200);
  Assert.IsTrue(miningResult);

  var receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash);

  while (receipt == null)
  {
    Thread.Sleep(1000);
    receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash);
  }

  miningResult = await web3.Miner.Stop.SendRequestAsync();
  Assert.IsTrue(miningResult);
  return receipt;
}

BUT when I try to change the struct to

struct MyCustomData {
    bool exists;
    string Name1;
    string Name2;
    string Name3;
    string Name4;
    string Name5;
}

the test fail: Message: Assert.AreEqual failed. Expected:<2>. Actual:<0>.

So looks like the method multiply is not executed. I'm guessing this is a problem with gas, but I tried to add gas to the transaction;transactionHash = await multiplyFunction.SendTransactionAsync(senderAddress, new HexBigInteger(200000), new HexBigInteger(120), 7);

but nothing changed.

Honestly I don't know what to do now. I think I tried everything...
Is Nethereum even close to be ready for production?

Friday 12:15 am
Any help would be much appreciated
Thanks


texts:
Can someone explain what might be going on with this wallet for example: https://etherscan.io/address/0x4dcCCF58C6573eB896250b0c9647A40C1673AF44
Look at the last 6 transactions. It's actually 3 coupled transactions where in each couple, the 1st the wallet receives some ether amount, and then in the 2nd it spends the entire amount on fees(???) for a self transaction.
What is that self transaction? and what could explain this behaviour? why spend all that ether on fees?


texts: Can I play with ETH mining on iMac 27 with AMD M395X (4GB)?

texts:
I have an idle iMax 27 with 2TB Fusion Drive and 4GB AMD 395X GPU. Last time the question was asked was July 2016, so I'll ask again for a current answer.  I am NOT expecting to make any money, but I do want to pretend I can.  My iMac 27 is sitting idle ever since I stopped running BOINC, so this will be just a similar hobby until I get bored.  I do have TG Pro running to watch my CPU and GPU temperatures, all about 100 degrees today sitting idle.

So, not being a programmer and not knowing anything about command lines, I am looking for a current GUI interfaced ETH and BTC miner.  I have the wallet address where I want to deposit any results, but nothing else.


texts: Does each transaction executed as atomic instruction inside the EVM?

texts:
There can be multiple transactions may executed inside a block. The states that are changed by those transactions may or may not be dependent to each other.

[Q] How should a winner miner execute those transaction such as synchronously or asynchronously?

For example, is each transaction executed inside the EVM should be a atomic instruction, where when a transaction is taking place, should all states (World-State) not interpreted by any other transaction?

Thank you for your valuable time and help.


texts: If I stored an encrypted variable in a smart contract, how long would it take to crack?

texts:
Just trying to get some information... Lets say I did this.

state = b'MySecretKey'

_state = bcrypt.hashpw(state, bcrypt.gensalt())

_state = _state.decode('utf-8')

And then stored that in the Smart Contract as a storage State during deployment.

string state;

First, how can I get the constructor variables from the dictionary that is returned from?:

trx_ = w3.eth.getTransaction(trx)

Second, how long would it take to crack the encrypted state variable?


texts: I am just wondering how do I get the MetaMask profile, on the right?


texts:
I installed truffle V3.1.1 and whether I try truffle init or truffle init webpack, I am unable to compile the example contracts.

sudo truffle compile
/usr/lib/node_modules/truffle/node_modules/truffle-compile/profiler.js:204
        dependency_path = source.resolve_dependency_path(import_path, dependency_path);
                                ^

TypeError: Cannot read property 'resolve_dependency_path' of undefined


texts: How do I calculate the (maximum) circulating supply for a given block height?

texts:
I would like to be able to calculate the circulating/max supply at any given point in time (for a specified block height).

I know that the current block reward is 3 ETH (soon to be reduced to 2 ETH).  When I multiply the current block height (6471790) by 3, I get a number (19415370) that is very short of what most block explorers report as the circulating/max supply (102,426,590).  Even if I factor in uncle rewards, I still don't come anywhere close.

I know that ETH had a pre-mine, and an ICO. Is it necessary to factor these numnbers into my calculation?

thanks!


texts: What is the behavior of solc with optimizer disabled?

texts:
When enabling the optimizer the documentation of solc tells you that you can choose between optimizing the gas cost at deployment or the gas cost at execution by setting the runs parameter.

But what is the default behavior when the optimizer is disabled? Will the compiled bytecode lead to high gas cost of deployment AND high gas cost fo execution, or can we assume that it leads by default to high gas cost of deployment but low for gas cost of execution?


texts: How do I set the time to be synchronized on Parity?

texts:
Under the Status Tab on Parity, I can see under Node Health that "Chain Synchronized" and "Connected Peers" are working fine.

However, under "Time Synchronized", I get the message:
"Unable to reach time API: NTP error: NTP server is not provided.. Make sure that your clock is synchronized."

Any idea how I can get the clock synchronized, and what it means now that it's not synchronized?

Thank you!


texts:
I'm new to Ethereum. I started learning like a few days ago, so this might be a very stupid question!

I started mining with my gaming pc. It has a hashrate of 25 MH/s. I started mining with a balance of 0 ether. I checked my balance after 50 minutes of mining and it said '10.00 ether' which is (at the time of writing this) as far I understand 2169.10 USD. This is a huge amount of money for 50 minutes of mining.

This seems waaay to good to be true so I'm pretty sure I'm not understanding something. Can someone explain how this is possible?

Maybe someone accidentally sent Ether to the wrong address?

From Ethereum wallet:


texts: Web3 sending TX times out after 280 seconds because network lag

texts:
When I submit a transaction via web3 and metamask, it will await 280 seconds before timing out and returning the transaction receipt.

How can I catch this error and handle with it so that my app can continue waiting for the transaction to be mined?

Is there a way to loop it with the tx hash that you can generate prior to it timing out?

EDIT: What is the best way to handle this, by using filter? By simply catching and running a filter for the 50+ blocks it can run max, doesn't seem like the best way. Also, will the Txhash remain the same if I generate it before I execute the transaction and the transaction is delayed for a day due to gas costs?


texts: How may I buy and register a Ethereum node for mining?

texts:
I would like to provide a Ethereum node in the State of Florida in the USA.
How many Ethereum nodes are already on-line in Florida?
How do I go about buying and registering a new Ethereum node?


texts: Insufficient funds in main account (etherbase)main account for gas

texts:
I'm using Ethereum/Mist 087.

I have 2000 eth in the main account. Trying to send 1800 from the main account to another ether account and Coinbase account. Each time we get the message:

  Insufficient funds in main account (etherbase) to pay for gas

I would have thought that 200 ether would be enough gas.

We are using the Ethereum wallet to "Send" and get that error. I have search the web and only see the code that has that error. Nothing on why.


texts: Check on `window.ethereum` fails with Metamask active

texts:
I have a web frontend which checks for the window.ethereum object as follow
if(window.ethereum) {
    console.log("Metamask available")
    ...
} else {
    console.log("Metamask not available")
}

Metamask is active. When loading the page, I see from the Chrome dev tool console that the "Metamask not available" message is print. If in the same console I manually write the exact same code, it evaluate as correct. In fact, I can see that evaluating window.ethereum shows the Proxy object

This happens only on one device (Mac with Chrome), the same code works correctly on another one (Linux Chrome).
What could possible cause the same if condition to return false when the page load but true when manually evaluated from the dev tool console?
Note: the JS code above is included in an iFrame, if it makes any difference


texts:
I need to store pdf hash in blockchain to prove my pdf existence.
I thought to use blockchain, but public blockchain required some fee ...
I don't really understand if ethereum could be my solution...
Can I use ethereum for store hash for free ? And if ethereum can be use to prove work ?


texts: Storing multiple values in one key mapping dynamically

texts:
I am making a blockchain project using solidity which requires storing various objectIDs corresponding to a personId.
The person can add and remove objects and we cannot hard-code the number of objects. I am not being able to use the correct data structure for the same.
I have looked for 2d arrays and nested mappings but am unable to figure out.


texts: Is it worth mining ether now & can anyone recommend software to mine on windows?

texts:
So I have recently woken up to the wonder that is Ethereum and have decided to look into mining it - I have a GeForce GTX 1070 and windows 10.

There is soo many options for mining Ether online it appears what is the best way to mine it effectively?

Thanks in advance of any advice :)


texts: Passing array in web3.js as a function parameter

texts:
I am trying to estimate gasLimit for function that transfers funds to multiple addresses:

const gasLimit = await multiTransferContract.methods
  .transferToMany(targetAddresses, amounts, tokenAddress)
  .estimateGas();

However I receive an error:

{\"code\":-32000,\"message\":\"gas required exceeds allowance or always failing transaction\"}"

Solidity function :

  modifier validOwner() {
    require(msg.sender == _owner);
    _;
  }

  function transferToMany(address[] memory receivers, uint[] memory amounts, address token)
    validOwner
    public
      {
    require(receivers.length == amounts.length);
    uint totalAmount = 0;

    for(uint i = 0; i < receivers.length; i++){
         totalAmount += amounts[i];
     }
     require(address(this).balance >= totalAmount);

    for(uint i = 0; i < receivers.length; i++) {
      if(token != 0x0000000000000000000000000000000000000000) {
        erc20iface =  ERC20(token);
        erc20iface.transfer(receivers[i], amounts[i]);
     } else {
        (bool result, ) = receivers[i].call.value(amounts[i])("");
        if(!result) revert();
     }
    }
  }

In remix it works fine. How to pass the array of addresses and amount with web3?
(['0x123',...] and ['0','1','2'] doesn't work)


texts: How can Hooked-Web3-Provider and Lightwallet work together?

texts:
Does anyone know some good working examples of the Eth-Lightwallet and the Hooked-Web3-Provider working together?

I was trying to get https://github.com/ConsenSys/eth-lightwallet/blob/master/example/example_web.html to work but it aborts with

Uncaught Reference Error: web3 is not defined

Update: looking for a Meteor implementation.


texts: Convert DAO tokens to ether in ethereum wallet

texts:
I have DAO tokens which I can see on THE DAO account balance page. I'm hoping someone can explain in a step by step procedure how to take my tokens, convert and change them into effect her and deposit them into my ethereum wallet.
Now I have tried to follow a YouTube video of this procedure but he went to fast and didn't bother to explain which address were to be pasted where. Perhaps to him it was self explanatory but to no techies like myself it was confusing. One wrong mistake and you can loose all your money.  If we want the masses to migrate to the crypto world they need to feel their many is safe.

Thank you


texts:
I'm trying to create a contract where I can save and then call a person's 'first name', 'last name' and 'age' within the truffle console.  I'm able to save using the addPerson method, but every time I call method getPeople I receive an empty array. Here is the contact.

pragma solidity ^0.4.4;

  contract People {

    Person[] public people;

    struct Person {
      bytes32 firstName;
      bytes32 lastName;
      uint age;

    }
    function addPerson(bytes32 _firstName, bytes32 _lastName, uint _age) returns (bool success) {

      Person memory newPerson;
      newPerson.firstName = _firstName;
      newPerson.lastName = _lastName;
      newPerson.age = _age;

      people.push(newPerson);
      return true;
    }
    function getPeople() constant returns (bytes32[], bytes32[],uint[]) {

      uint length = people.length;

      bytes32[] memory firstNames = new bytes32[](length);
      bytes32[] memory lastNames = new bytes32[](length);
      uint[] memory ages = new uint[](length);

      for(uint i=0; i < people.length; i++) {
        Person memory currentPerson;
        currentPerson = people[i];

        firstNames[i] = currentPerson.firstName;
        lastNames[i] = currentPerson.lastName;
        ages[i] = currentPerson.age;
      }
      return (firstNames, lastNames, ages);

    }

  }

It seems to be working. I was able to compile and migrate it using truffle compile and truffle migrate.

I'm running testrpc in the terminal. And it seems like my transactions are accurately being recorded.

I'm interacting with the contract via truffle console. When I enter in the command People.deployed().abi and People.deployed().address() I get a value.

I can enter info using the addPerson method:

People.deployed.addPerson('Darlene', 'Brown', 25)

I don't know why when I call getPeople I get back an empty array

truffle(default)> People.deployed().getPeople().then(console.log)
[ [], [], [] ]
undefined


texts:
I have created a "get_all" function that reads all variables in Solidity and a "set_all" function that writes all variables.

And I did a test in remix,
 1, "0", 123123, "hash", "map", "eul"
I gave this type of input to set_all and the value was normal.

But

contract.transact({"from": walletaddr}).set_all({1, "0", 123123,"hash", "gap", "eul"})

I've implemented this code.

Such an error occurs.

  Could not identify the intended function with name set_all, positional argument(s) of type (<class 'set'>,) and keyword argument(s) of type {}. Found 1 function(s) with the name set_all: ['set_all(uint256,string,uint256,string,string,string)'] Function invocation failed due to improper number of arguments.

Maybe I'm not good at formatting in multi factors. Is there a way to solve this?

-----this is my python code

from web3 import Web3, HTTPProvider
import json
rpc_url = "https://ropsten.infura.io/v3/e8d944bb989245b49298b16ecf198669"

w3 = Web3(HTTPProvider(rpc_url))

with open("abi.json") as f:
    info_json = json.load(f)
abi = info_json
contract = w3.eth.contract(address='0x5644cd8cED82c6d292b09204e51222d9E0b274ec', abi=abi)
contract.transact({"from": "0xD10c154eCE5256422Dea1C68613C96AFE74513C2"}).set_all({1, "0", 123123, "hash", "gap", "eul"})

------ this is my solidity code

  pragma solidity ^0.4.2;
  contract blockpaper {
      string ContractType;
      uint256 TimeStamp;
      uint256 PaperId;
      string GapSign;
      string EulSign;
      string FileHash;

      function set_all(uint256 newPaperId, string newContractType, uint256 newTimeStamp, string newFileHash, string newGapSign, string newEulSign) public returns(uint256, string, uint256, string, string, string) {
      PaperId = newPaperId;
      ContractType = newContractType;
      TimeStamp = newTimeStamp;
      FileHash = newFileHash;
      GapSign = newGapSign;
      EulSign = newEulSign;
      return (PaperId, ContractType, TimeStamp, FileHash, GapSign, EulSign);
      }


texts:
I have seen this question and answers but they do not answer my question.
Let say I want to create a smart contract that releases ether when a certain time reaches. How does the blockchain know that this time has reached and does the release of ether happen automatically or does it need an external trigger?


texts: How can I create or setup multiple accounts for Rinkeby in a Truffle environment?

texts:
I use ethereumjs-wallet along with truffle-wallet-provider to connect my Rinkeby account to Truffle:

var rinkebyPrivateKey = new Buffer(process.env["RINKEBY_PRIVATE_KEY"], "hex")
var rinkebyWallet = Wallet.fromPrivateKey(rinkebyPrivateKey);
var rinkebyProvider = new WalletProvider(rinkebyWallet, "https://rinkeby.infura.io/");

Since WalletProvider is used to create one single Rinkeby provider, I don't see how I could pass in more accounts' credentials. Can anyone point me to some resources for setting up these accounts so I can use them in my Truffle tests and/or console?


texts:
Currently, I am working on a project, I'll get Oracalize response bytes32 string as a hex string. How can I construct hex string back to bytes32 in solidity?

For eg:
 string value= "0x2a1acd26847576a128e3dba3aa984feafffdf81f7c7b23bdf51e7bec1c15944c"

I want byes32:
 bytes32 _value=0x2a1acd26847576a128e3dba3aa984feafffdf81f7c7b23bdf51e7bec1c15944c


texts: Am I mining to my correct wallet address?

texts:
I'm trying to start Ethereum, so I created my wallet first using metamask and I added to geth using private key with this command.
geth account import private_key.txt

After that I run the mining command using geth --mine, so my question is : am I really mining to my correct wallet ?


texts: How to fix "Fatal: Error starting protocol stack: listen udp :30303: bind: address already in use"?

texts:
I am referring this tutorial and miner.start(1) works fine and mining is started as expected like below.

INFO [09-05|15:41:26.486] Commit new mining work                   number=221 sealhash=1892af…f2ffcd uncles=0 txs=0 gas=0 fees=0 elapsed=243.187µs
INFO [09-05|15:41:26.706] Successfully sealed new block            number=221 sealhash=1892af…f2ffcd hash=10497a…b00914 elapsed=219.629ms
INFO [09-05|15:41:26.706]  block reached canonical chain          number=214 hash=b3cb32…9dbe53
INFO [09-05|15:41:26.706]  mined potential block                  number=221 hash=10497a…b00914
INFO [09-05|15:41:26.707] Commit new mining work                   number=222 sealhash=36083f…4c7697 uncles=0 txs=0 gas=0 fees=0 elapsed=202.361µs
INFO [09-05|15:41:32.083] Successfully sealed new block            number=222 sealhash=36083f…4c7697 hash=18607b…9362b7 elapsed=5.376s
INFO [09-05|15:41:32.083]  block reached canonical chain          number=215 hash=5ce9de…005985
INFO [09-05|15:41:32.083]  mined potential block                  number=222 hash=18607b…9362b7
INFO [09-05|15:41:32.084] Commit new mining work                   number=223 sealhash=90508f…09cb94 uncles=0 txs=0 gas=0 fees=0 elapsed=158.478µs

Now the author says to check balance after mining starts, so to do that i open a new geth window console says

  Fatal: Error starting protocol stack: listen udp :30303: bind: address
  already in use

which is obvious because of mining window which is running currently.

So my question is how can i check balance after starting miner?

Or should i wait for completion of mining?

If i should wait for mining completion then how much time it will take to complete?


texts: Unlock required for transaction from offline generated address?

texts:
When sending an ethereum transaction, applications like geth will lock and unlock the ether account being used with a password. But what if I generate a public and private key offline, do I still need to unlock (and first create) the account with geth before sending a transaction from that account with web3?

In short, is the lock and unlock password somehow included in the blockchain or is it only being used to encrypt the private key in the wallet key file?


texts: How will regular users be able to use dApps without having to install another browser like Mist?

texts:
Requiring users to install another browser like Mist, is too much of a barrier for any kind of mainstream adoption.

What are potential solutions and how close are they in actual practicality?


texts: If the hackers of the DAO converted the funds to bitcoin, would it have been possible to return the funds to the investors?

texts: My understanding of the DAO hack is that Ethereum was hard forked so that those who lost funds could have them retrieved. If the hacked funds were immediately converted to bitcoin, would this still have been possible?


texts: How excatly Bancor works (for non-economists)

texts:
I've read the following SE threads: 1, 2,3, the Bancor's white paper, Eyal Herzog Smart Token 101 post, and Scott Morris's post but I'm still having a hard time trying to understand how exactly Bancor Network works. I might be missing some important knowledge but I can't figure out what exactly I miss.

I got it that Bancor serves as the "CHANGE" of the Ethereum based Tokens (or ERC20's compatible Tokens). I also understand the general idea of Bancor which enables low-profile Tokens to be easily tradable ("liquid"). But there are many details missing in my understanding:

I'm not looking for a specific answer for each of the questions but rather for a detailed explanation/resource that could widen my understanding.

Technical:

Consider some Example Smart Token (EST) and its reserve token (RTO). When one creates the EST contract she sets the EST Total Supply, the amount of RTOs (reserve amount) which back the smart token and the Constant Reserve Ratio (CRR). That's actually means that she fixes the initial price EST, but this is just a number, how does one decides on that number? Based on what?
In the same context, fixing the "reserve amount" actually means that the smart token owns that amount of RTO? If yes then in what sense? Does the EST's smart token (which is a smart contract) maintains an ethereum address by which the owner of that token can make transfers?
When someone pays RTO to the smart token and receives EST in exchange, how does he do it? By actually transferring RTO to the contract's address?

Economical

What is the alternative to Bancor protocol? I.e. how could I exchange between two tokens if Bancor would not have existed?
What are the prerequisites to understand the price discovery methods that the Bancor protocol uses?
The white paper (and other sources) mentioned that there might be a gap in a price of some token when related to multiple other tokens. This is considered as an advantage since arbitrageurs can exploit it somehow. To me it is sounds like a flaw in the system, isn't it? Why?
Is the CRR a well known term in economics or it made up for the Bancor purposes? Why does it so important to maintain that constant ratio?


texts: How to deploy uniswap contract with open zeppelin?

texts:
I was following the quick start here which suggests to "Deploy the UniswapV2Factory" under the writing tests header. I'm using OpenZeppelin and have Ganache running but I wasn't able to deploy the contract. What am I doing wrong?
I'm running npx oz deploy node_modules/@uniswap/v2-core/build/Combined-Json.json and I get the error:
[2020-08-25T22:25:29.809Z@errors.js#call] <started> Error: Invalid contract 'node_modules/@uniswap/v2-core/build/Combined-Json.json'
    at throwIfInvalid (/Prototypes/ethereum-prototype/node_modules/@openzeppelin/cli/lib/register-command.js:166:15)
    at /Prototypes/ethereum-prototype/node_modules/@openzeppelin/cli/lib/register-command.js:122:17
    at Generator.next (<anonymous>)
    at fulfilled (/Prototypes/ethereum-prototype/node_modules/@openzeppelin/cli/lib/register-command.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)


texts: About key and address difference between Quorum and Ethereum blockchain

texts:
Quorum is a fork of Ethereum, what are the main difference of them about private key/public key/address generation and representation format?
In the link Quorum wiki, there is a public key like below:

{"payload": "foo", "from": "mypublickey", to: "ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="}

the public key above is different format from ethereum HEX public key.What's it and its encoding format?

Meanwhile, I also noticed in the link Quorum example, the block info printed is all the same with ethereum:

{
  blockHash: "0x4d6eb0d0f971b5e0394a49e36ba660c69e62a588323a873bb38610f7b9690b34",
  blockNumber: 1,
  from: "0xed9d02e382b34818e88b88a309c7fe71e65f419d",
  gas: 4700000,
  gasPrice: 0,
  hash: "0xe28912c5694a1b8c4944b2252d5af21724e9f9095daab47bac37b1db0340e0bf",
  input: "0x58c0c680ee0b55673e3127eb26e5e537c973cd97c70ec224ccca586cc4d31ae042d2c55704b881d26ca013f15ade30df2dd196da44368b4a7abfec4a2022ec6f",
  nonce: 0,
  r: "0x4952fd6cd1350c283e9abea95a2377ce24a4540abbbf46b2d7a542be6ed7cce5",
  s: "0x4596f7afe2bd23135fa373399790f2d981a9bb8b06144c91f339be1c31ec5aeb",
  to: null,
  transactionIndex: 0,
  v: "0x25",
  value: 0
}

How to understand the above info?
Thanks


texts: Call functions from another account by default in web3

texts:
In my truffle tests, I am trying to call a function from an account other than the default account, so not accounts[0] from the below result. web3.eth.defaultAccount doesn't seem to work.

web3.eth.getAccounts().then(accounts => {
  accounts[0] // Don't use this.
  web3.eth.defaultAccount = accounts[1].
  contractInstance.foo() // called from accounts[0]
})

I know I can use

contractinstance.foo({from: accounts[1]})

but I don't want to add this parameter every time, as most of the code will use accounts[1].

Is there a way to change the default account or am I missing something here? Thanks


texts:
I have created a cryptocurrency by following this link .I have deployed the contract in Mist. I am using transferFrom() function in Ethereum wallet to transfer currency from one account to other but getting intrinsic gas too low error(Execution failed. Consumed all provided gas). Although my primaryAccount(from which I am trying to transfer) contains sufficient ethers(more than 20,000 ethers).

function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
        if (balanceOf[_from]  allowance[_from][msg.sender]) throw;   // Check allowance
        balanceOf[_from] -= _value;                          // Subtract from the sender
        balanceOf[_to] += _value;                            // Add the same to the recipient
        allowance[_from][msg.sender] -= _value;
        reward=calculateReward(now);
        balanceOf[block.coinbase] += reward;
        Transfer(_from, _to, _value);
        return true;
    }

while other similar functions such as transfer() are working well.Can't understand why two functions behaving differently. I am  adding the image of error for refrence.


texts: How will Proof of Stake affect blockhash generation

texts: When (and if) Ethereum switches to proof of stake, how will the hash of blocks (most likely) be set?


texts: A single exception in Truffle test causes every other test cases to fail

texts:
I'm making test script for my contract and it looks likes

contract('...', async () => {
    let token = null;
    before('deploy', async () => {
        token = await MyContract.new(...);
    });

    it('should success', async() => { ... });
    it('should fail', async() => { ... });    // work as intended only until here
    it('should success', async() => { ... });
});

and executed with command truffle test ./test/test.js

Issue is that calls after second it(...), which contract call fails and invoke revert, never succeed and raise errors similar to

AssertionError: the tx doesn't have the correct nonce. account has nonce of: 37 tx has nonce of: 36

How do I make the test script work? looks like some kind of nonce increment gone wrong, but I'm not sure what I've done wrong.
I'm using Ganache GUI 2.0.1 for test network and truffle v5.0.9.

-- Edit --

as comment suggested, I check if I missed any await keyword,

my code is all like this,

it('should deny transfer with insufficient (zero) balance', async () => {
    const amount = web3.utils.toWei('1', 'ether');
    const promise = token.transfer.call(accounts[3], amount, { 'from': accounts[2] });
    await assert.isRejected(promise, 'revert', 'transfer transaction with insufficient (zero) balance must be denied');
});

I tried what Majd TL suggested also,

it('should deny transfer with insufficient (zero) balance', async () => {
    const amount = web3.utils.toWei('1', 'ether');
    const promise = token.transfer(accounts[3], amount, { 'from': accounts[2] });
    await truffleAssert.reverts(promise, 'revert', 'transfer transaction with insufficient (zero) balance must be denied');
});

but it does not resolve the problem. The workaround now is to call contract call that expected to fail with .call, like

const promise = token.nope.call(1, 2, 3, { 'from': accounts[0] });

but in case of really unexpected error, it is inevitable and should be a thing. I Also see this error when using multiple contract(...).


texts: Invalid implicit conversion when creating an array of struct inside a function

texts:
I'm new to solidity and I have a struct that takes an array of Traction[], I'm trying to create the array inside a function createItem but I'm getting an invalid implicit conversion.
I have added the entire contract incase if I'm doing something else wrong.
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.21 <0.7.0;
pragma experimental ABIEncoderV2;

contract SupplyChain {
    // Identify the role of an owner
    enum OwnerType {Any, Manufacturer, Ditributor, Retailer, Consumer}

    struct Owner {
        string id; // documentId of a mongo database
        string name;
        OwnerType ownerType;
    }

    // A trasaction is event in the supply chain
    // mostly a change of owner
    struct Transaction {
        string txid; // A generated hash of the transaction
        string previous;
        uint256 timestamp; // Unix timestamp
        bool allowAny; // Anyone can receive/consume the product
        address owner;
        address destination;
        OwnerType destinationType; // Mentions what should be the role of Owner
        string documentId; // documentId that's stored in a mongo database
    }

    struct Item {
        string name;
        uint256 price;
        Transaction[] transactions;
    }
    mapping(uint256 => Item) items;
    mapping(address => Owner) owners;

    function createOwner(
        address account,
        string memory documentId,
        string memory name,
        uint8 roleType
    ) public returns (bool) {
        Owner memory owner = Owner(documentId, name, getRoleType(roleType));
        owners[account] = owner;
        return true;
    }

    function getOwner(address account) public returns (Owner memory) {
        Owner memory owner = owners[account];
        return owner;
    }

    function getRoleType(uint256 roleType)private returns (OwnerType){
        if(roleType==0){
            return OwnerType.Any;
        }else if(roleType == 1){
            return OwnerType.Manufacturer;
        }else if(roleType == 2){
            return OwnerType.Ditributor;
        }else if(roleType == 3){
            return OwnerType.Retailer;
        }else if(roleType == 4){
            return OwnerType.Consumer;
        }
    }

    function createItem(
        string memory itemName,
        uint256 itemPrice,
        string memory txid,
        uint256 timestamp,
        bool allowAny,
        address ownerId,
        address destination,
        uint256 destinationType,
        string memory documentId
    ) public {
        // Get owner
        Owner memory owner = getOwner(ownerId);
        // Create inital transaction
        Transaction memory transaction = Transaction(
            txid,
            "", // no previous transaction
            timestamp,
            allowAny,
            ownerId,
            destination,
            getRoleType(destinationType),
            documentId
        );
        // ERROR HERE
        // Here I get an error
        // TypeError: Invalid type for argument in function call. Invalid implicit conversion from struct SupplyChain.Transaction memory[1] memory to struct SupplyChain.Transaction memory[] memory requested. Item memory item = Item(itemName, itemPrice, transactionArray);
        Transaction[1] memory transactionArray =  [transaction];
        Item memory item = Item(itemName, itemPrice, transactionArray);
        // If I change the size of the array to dynamic I get the same invalid conversion but on the assignment and not on function call

        uint256 itemId = 1;
        // Add item to the chain
        items[itemId] = item;
    }
}


texts: New miner warnings and errors, dropping nodes and peers

texts: Im new to mining.  I had several older blades sitting around not doing anything so I thought why not have them doing something.  Anyway these are all CPU based miners.  I understand its not effecient, but that's not why Im here.  I get a lot of what you see in the photo and I have no idea if that's something I'm doing wrong or something wrong with that particular state or block verification.  For the most part everything is "green", but it regurgitates these red and yellows enough to bring me here.  What are these and is the problem on my end?  I suppose that because I can't actually see whether or not this rig is doing its job and sticking rewards in the right place (I guess until it happens), I don't really know how affected I am by this either.


texts: Mist will not start: Give error on port 30303

texts:
I startup my private test node with:

geth --networkid 4224 --mine --datadir "~/ChainSkills/private" --ipcpath "~/Library/Ethereum/geth.ipc" --nodiscover --rpc --rpcport "8545" --port "30303" --rpccorsdomain "*" --nat "any" --rpcapi eth,web3,personal,net --unlock 0 --password ~/ChainSkills/private/password.sec

But when I start Mist I get the following error:

[ERROR] EthereumNode - Failed to start node { Error: Geth error: fatal: error starting protocol stack: listen tcp :30303: bind: address already in use

at Socket.proc.stdout.on.data (/Applications/Mist.app/Contents/Resources/app.asar/modules/ethereumNode.js:422:47)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20) tag: 'unableToBindPort' }


texts: Query for DeFi/ETH/BSC wallets, transactions, balances

texts:
I'm looking for a way to monitor wallet balances or otherwise somehow query the mainnet for ETH or BSC (or a DeFi contract on either network), but I feel like I "don't know what I don't know" and I can't seem to find the right combination of words to search for this. I'm using NodeJS right now, but can be flexible if need be.
Apologies for the vagueness and if this makes a poor question, but blockchain development is so alien to me - I don't know what libraries are out there or how I use them, and all I want to do is build an API around what seems should be simple functions. I'm looking at ethereumjs, ethereumex, and eth_contract... am I going down the wrong path? Is there a link to anything that can nudge me in the right direction to using these packages? There's precious little documentation and it's all very unapproachable.


texts: How to create you own ethereum sidechain?

texts: How can I create a geth-clique POA network as an Ethereum sidechain to mainnet or testnets. what is the simplest ways to do that? are there any frameworks that can be implemented easily


texts:
With Hyperledger composer deprecated and fabric-rest-api (https://github.com/hyperledger-archives/fabric-sdk-rest) archived, what is the future roadmap of REST API for Hyperledger fabric? What is recommended way  to expose rest APIs with Hyperledger Fabric 1.4.x?
The documentation (https://hyperledger-fabric.readthedocs.io/en/release-1.4/fabric-sdks.html) mentions that REST SDK will be provided in subsequent releases - but cannot find a roadmap.


texts:
I originally built a system that had a front end where users simply entered some details and a password which then generated them a wallet and emailed it to them. My aim was that the user could then choose whether to run their own node or use the web interface to send transactions(form with a file picker to select the wallet and a password field).

I'm unsure as to the best approach to take here, is it more secure to keep the wallet files server side, and just ask users to enter their wallet password to send transactions, or allow them to keep their own wallet and upload it to a temp folder each time they want to transact using the server's node?

It's a 'private' blockchain btw. With probably minimal chance of an attacker wanting to compromise the server.

I know ideally it would be best to provide a client UI and ask all users to use their own node so wallets and passwords could be kept away from the server but this is a greater technical requirement for the users than I would like.


texts: What is the tech stack behind the Prysm client?

texts:
What are Prysm's major components?  What databases did Prysm consider and decide on?

Are there elements in Prysm's architecture that are particularly differentiated from the other beacon chain clients?


texts: How do you balance inline assembly blocks?

texts:
Since Solidity 0.4.3, the compiler now shows warnings when a block is not balanced. For example:

Error: Inline assembly block is not balanced. It leaves 1 item(s) on the stack.

I've tried finding documentation that gives into what this entails, and why it happens, but haven't found anything useful. What happens here? How do you fix this?

This internal getCode/codeAt function gives the above error (for example).

function codeAt(address _addr) internal returns (bytes o_code) {
  assembly {
      // retrieve the size of the code, this needs assembly
      let size := extcodesize(_addr)
      // allocate output byte array - this could also be done without assembly
      // by using o_code = new bytes(size)
      o_code := mload(0x40)
      // new "memory end" including padding
      mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
      // store length in memory
      mstore(o_code, size)
      // actually retrieve the code, this needs assembly
      extcodecopy(_addr, add(o_code, 0x20), 0, size)
  }
}


texts: Can a potential bug in the ethereum VM be used to deploy a trojan on every node in the ethereum network?

texts:
This has been on the back of my mind for a long time but has resurfaced with the recent dos attacks.

The constructor of a smart contract is executed by all nodes at the time of contract deployment.

So, if the ethereum virtual machine had a bug that allowed for arbitrary code execution on the host node, it would be possible to deploy a virus/trojan instantly on the whole network by inserting a malicious contract on the blockchain.

It's very likely this has been thought through and discussed elsewhere but I cant find any information on it.

So, is an attack like that possible?
What are countermeasures?


texts: How many bootnodes should be used in a PoA Network?

texts:
I implemented a PoA network as per this example, and it states:

  If N sealers are defined in the genesis file, clique will only work if
  int(N/2+1) (source code) nodes are online. This means that if we
  define 5 sealers in the genesis file, we will need a minimum of 3
  nodes to be mining (sealing) for the blockchain to work. If we define
  4 sealers we’ll also need at least 3 mining nodes.

I am wanting test how many bootnodes are needed. I had assumed we should keep the number of bootnodes to a minimum. But should there be one bootnode per server (ie instance in the cloud)?


texts: Efficiently swapping elements in Solidity arrays

texts:
Given an array of length 10,000 how computationally expensive would it be to swap elements within the array (e.g. by performing a swap of elements at randomly generated indices i and j) 10,000 times?
In general, what is the process by which these gas consumption estimates are made? Would this be feasible?


texts: Pending Transactions in Parity Demo-PoA when using user account

texts:
I am using etherchain-light which works really nice together with Parity PoA and the demo tutorial for Parity PoA private chains.
I experienced two weird issue, in general everything works perfect with the two signer accounts, I can deploy contracts even with browser-solidity, call them, transfer ether, etc.
However, if I use the user account (0x004ec07d2329997267Ec62b4166639513386F32E):

when I deploy a contract (using browser-solidity) with a library, the signer accounts (eg. 0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e) has to accept two trx, and it's working. If a change the account to the "user" account 0x004ec07d2329997267Ec62b4166639513386F32E, only one trx has to be accepted, but browser-solidity does not return, the contracts are never deployed.

After some time, even transfer of Ether from user account does not work any more. I can accept the trx, but then it goes to pending trxs, which get never "mined". I can see a lot of pending transactions in etherchain-light, which obviously never get confirmed. Something is strange here, it worked at the beginning and stopped suddenly, queueing all trx from the user account in pending transactions.

So, in short: there seems to be a difference between signer accounts and user accounts which I do not grasp. But I would like user accounts to have the same privileges as the signer account.


texts: How do I get the number of total NFTs issued by an address?

texts:
For example Ethereum Name Service (ENS):
https://etherscan.io/token/0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85
I am looking for an API that returns the total number of NFTs created. I'm using Etherscan and Ethplorer API (getTokenInfo), but some addresses like CryptoKitties address return the right number of NFTs created, while some addresses like Ethereum Name Service return nothing.
Can you help me?
Thank you


texts:
i try to create a map with (address => bool) with web3js. I want to know if the address is a contract owner.
So, i have to call "owners" function in my solidity contract.
As you can see below :

let allAccountInfo = new Map();
let localAccount = web3.eth.accounts;

    for(account in localAccount){

        MyContract.owners(localAccount[account],function(error,result){

            if(error){
                console.log(error);
            }
            else {
                allAccountInfo.set(account,result);
            }

        });

    }
    console.log(allAccountInfo);

Because MyContract.Function return a promise, this code don't work. I have to wait the promises end before loop... with "await" ?

 let allAccountInfo = new Map();
 let localAccount = web3.eth.accounts;

     for(account in localAccount){
            result = await MyContract.owners(localAccount[account])
            allAccountInfo.set(account,result);
     }
  console.log(allAccountInfo);

But when i do this, i get this error :

  Error: The MetaMask Web3 object does not support synchronous methods
  like eth_call without a callback parameter.

Do you know a solution ?
Thanks,


texts:
In Solidity, how can I convert the sender address to a string?

The comments in
How to convert an address to bytes in Solidity? did not provide a working solution


texts: TX fails in private blockchain when trying to access an ERC20 contract from another contract

texts:
I have an ERC20 contract and I am trying to access it from another contract, which is a Faucet. In the Faucet I have a function to query an account's balance, and another one to transfer some tokens to an account.

When I test everything in Ganache or Ropsten, it works normally. When I test this in a private local Geth network, this happens:

I am able to deploy both contracts.
I am able to transfer some tokens from the ERC20 to the Faucet.
When I try to query the balance of an account by sending a transaction to the Faucet I get: "Error: Returned values aren't valid, did it run Out of Gas?"
When I try to do a transfer by calling the Faucet, the transaction fails (it is mined, I get a transaction hash, but it fails and consumes all the gas).

What could I be missing? This doesn't seem like a problem in the contracts.

This is the Faucet's code:

pragma solidity 0.5.0;

import "./Token/ERC20Basic.sol";
import "./Token/SafeERC20.sol";

contract Faucet {
    event AccountFunded(address account);

    address public tokenAddress;

    constructor(address _tokenAddress) public payable {
        tokenAddress = _tokenAddress;
    }

    function () external payable {}

    function testBalance(address account) public view returns (uint) {
        return ERC20Basic(tokenAddress).balanceOf(account);
    }

    function transfer(address account) public {
        SafeERC20.safeTransfer(ERC20Basic(tokenAddress), account, 10);
        emit AccountFunded(account);
    }
}

I am deploying and calling the contracts with Truffle. I tried different gas limits for the private geth network. This is the genesis file:

{
  "config": {
        "chainId": 1337,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x100",
  "extraData"  : "",
  "gasLimit"   : "0x700000000",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

Thanks!


texts: why are Transactions paid in Gas and not just Ether directly

texts: All the explanations I heard for the Gas usage, could imho also be dealt with in Ether directly. What is it that Gas does that couldn't be done with Ether directly?


texts: How does file coin cope with forks? What if I ask to delete my file in some block, the node deletes it, and then the block is canceled.


texts: I accidentally transferred Ether to a smart chain contract wallet, I have tried contacting but its support say there is nothing they can do.  please is there any advise on how to get a reversal need help urgently. its a lot to lose.


texts: mload gives different results for result uint8 and bytes1

texts:
In remix.ethereum.org, converting from bytes to bytes1 works but from bytes to uint8 does not. Since both bytes1 and uint8 are represented as binary the assembly should be able to convert between both. Why does bytes to uint8 fail?

This returns 0, should return 255

function c() returns(uint8) {

uint8 input;
bytes memory b = hex"FF";

assembly {
     input := mload(add(b, 32))
}
return input;
}

This works, returns 0xFF

function c() returns(bytes1) {

bytes1 input;
bytes memory b = hex"FF";

assembly {
     input := mload(add(b, 32))
}
return input;
}


texts: Is this a safely design for a lottery smart contract?

texts:
I'm design a lottery smart contract. The lottery is like this:

the lottery will be drawed everyday;
24 hours of one day is split to active period(23 hours), freeze period(30 mins), and draw period(30 mins);
users can bet and apply for reward only in active period;

the contract use the latest 6 blockhash, and current block's timpstamp as seed to generate random, because no-one can bet in freeze period and draw period, no-one can bet a set of number base on a known blockhash.

Is it a safely design for a lottery smart contract?

still more. i plan to using the latest 6 blockhash to generate the randomness, like this:
keccak256(block.blockhash(block.blocknumber-1), block.blockhash(block.blocknumber-6),block.blocktimpstamp);

it will consume more gas. but, is it safe?


texts: Is there a benchmarking tool to make some tests on the 7nodes quorum-example running on vagrant?

texts:
I set my quorum network using 7nodes quorum-example running on vagrant.
Now, I need a testing tool to evaluate my implementation (TPS, latency, ...).
I tried some tools but every time I have problems:

https://github.com/jpmorganchase/cakeshop/tree/v0.10.0-pre.1 (cannot
support the raft consensus)
https://github.com/persistentsystems/gauge (could not connect to the
    vagrant VM)
https://github.com/blk-io/blk-explorer-free (it run
very well, but it  is blockchain explorer only, I need benchmarking
tool)

need any helpful information


texts: How do I cancel an Etherscan transaction?

texts:
I did a transfer with Eth, the transaction shows completed, but I didn't received the coin in my wallet. How do I revert the transaction with its hash value?
Thank you.


texts: I verified the source code but I emailed Etherscan to update my token logo and web site information and they denied me. They said I don't have a white paper and a visible team members with profile pictures. I literally seen dozens of  tokens that have no official team members or white papers show up on their search with logos and token information. I responded to them saying I don't need to be verified just update my logo and token information and make it come up in search. Having a white paper and team pictures and profiles isn't even a requirement when submitting token information. I don't know what to do now anyone can steal my source code and copy my entire project and make fake profiles and get approved. Since they won't respond to my appeal is there a way to remove the source code from Etherscan? Anyone know what I can do?


texts: New Ganache (1.1.0-beta.0) Causes Invalid JSON RPC response

texts:
Hey I'm running a test where I expect a transaction to throw. Instead of successfully returning a receipt with a status of 0, or throwing a revert error, it throws this invalid JSON RPC response error.

Example:

try {
    // some generic transaction with a contract that should fail via revert or require.
    await promise;
} catch (error) {
    const revertEvent = error.message.search('revert') >= 0;
    assert(revertEvent, 'expected revert');
}

and I get the stacktrace:

Error: Invalid JSON RPC response: {"id":202,"jsonrpc":"2.0"}
at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41483:16)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:330353:36
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326008:9
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:329052:7)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176427:18)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176717:12)
at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176872:12)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176832:24)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1047:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickDomainCallback (internal/process/next_tick.js:198:9)


texts: Is there a standard for modelling smart contracts such as ERM for databases?

texts: I want to document my Dapp including the "data structure" (i.e. the relationship between different contracts). Is there a good way of modelling smart contracts that anyone has used successfully?


texts:
I would like to get a snapshot of EVM state on a certain block and then execute smart contract call actions against this state.

Do Go Ethereum, Parity or any of other Ethereum clients provide functionality that could help here?

Maintaing the historical state and expose it over JSON-RPC APIs

... or ...

Allow to fast forward the chain from a genesis block to a certain block and then stop syncing, so that the state is frozen to a historical block


texts: I want to use the ecSign-function in the ethereumjs-util-library. But that needs a private key. So how and where do i get my private key for my wallet?


texts: Contract to contract interaction using Mist

texts:
In the following the example of interaction between two contracts based on the example: Basic example of interaction between 2 contracts?

contract C1 {
    function f1() returns(uint) {
        return(10);
    }
}

contract C2 {
    function f2(address addrC1) returns(uint) {
        C1 c1 = C1(addrC1);
        return c1.f1();
    }
}

Although I have been able to successfully do this form of interaction on the online compiler and at the console prompt, I don't see a way to do the same using the Mist wallet. I tried deploying C1 first and was able to get the contract address and ABI. Now, when i tried to deploy just the contract C2, I get an error during compilation saying:

  source not found, file not compiled initially

Even after adding the instruction:

import "C1"

I get the error:

  source not found, file not compiled initially.

Any suggestions as to how this can be done on Mist? I tried importing the contract as well, but that is similar to adding an existing contract to interact with, and have not been able to make progress after.


texts: Truffle mingration: Error: authentication needed: password or unlock

texts:
I deploying contract using Truffle and got an error Error: authentication needed: password or unlock. I already checked related questons and found only ugly hacks like "unlock desired account directly on node using web3.personal.unlockAccount". But I do not want to connect to my node each time (I have 3 test networks in my truffle.js) when I want to deploy new version.

My question is: is there any way to specify password in truffle infrastructure to unlocks account specified in field from under the network item? password or pass does not works.


texts: Is there a mistake in this passage about the requirements on the block header nonce?

texts: It says that PoW evaluates to an array with the first item being the mix-hash, and the second item being a pseudo-random number. However, from equation 49, it would seem it is the second item, m, which is equal to the mix-hash, and the first item, n, which is the pseudo-random number. Is there something I'm missing here?


texts: Skip Parity interactive password for signer

texts: Is there a way to skip password/confirm at every transaction in parity? This would be really useful to work with dev chain and make multiple test quickly.


texts: How to connect an Android App user to ethereum network?

texts:
I'm working on developing a decentralized application which requires every user of the Android app to have separate account containing his ether balance information and other user-specific information.

I read about the concept of light-clients and full-nodes but came to know the official Ethereum light-client is still under development.

Then I stumbled on these articles about using ethereum in Android and Iphone. So they kind of suggested of creating a Full-Ethereum node and make your app interact with this node using JSON-RPC protocol. So I came up with the following architecture:

Android App (Contains user's private key and data) ----> Ethereum Full-node server (Set up using available clients for ethereum (in python)) -----> Ethereum Virtual Machine.

I've some questions as follows:

Is the above architecture safe? (What happens if server is compromised or the server is biased)
Do I need to create a Full-node Ethereum client corresponding to every Android app user.
What type of user's data will the Full-node server need to process a transaction on its behalf?

Last one is slightly out of context and might be very vague, Given a JSON-RPC library like [web3j][3] and a full-node client like [pyethapp][4] running on a different device, How would I make the web3j interact with pyethapp


texts: web3j - Java - Resolve ENS Name to Contract Address

texts:
I am trying to Resolve my ENS Name to the corresponding Contract Address. But so far I get the error
org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract

I am using web3j version 4.5.11 which should support ENS Names.
So far I found out that the ENS Name ethereum.eth is being resolved but other ENS Name throw an error.
My guess is that the Public Resolver from web3j is wrong or out-dated.
I use the Public Resolver: 0x42D63ae25990889E35F215bC95884039Ba354115
Here is my code:
Web3j web3j = getWeb3J();

    Credentials credentials = getCredentials();
    EnsResolver ensResolver = new EnsResolver(web3j);

    String contractAddress = ensResolver.resolve(ensName);


texts: Help me to understand SafeMoon rOwned and tOwned pool

texts:
Looking at SafeMoon.sol contract here https://github.com/safemoonprotocol/Safemoon.sol/blob/main/Safemoon.sol. There are 2 ownership maps rOwned and tOwned depends on if the wallet address is excluded or not. It seems to need to maintain certain ratio between the 2 for transfer and liquidity.
tOwned is out of 1E24 total supply of SafeMoon Token.
rOwned is out of the remainder of uint256Max - 1E24.
Does it mean the token’s owner (dev) owns all of remainder? Why do they need to maintain these 2 different maps? Thanks