texts: Error encoding arguments: Error: invalid number value (arg="", coderType="int128", value=9223372036854776000, version=4.0.44)

texts:
I'm new to Solidity and I'm having some troubles with type issues. I'm trying to execute the following functions:
function sigmoidSingle(int128 x) public pure returns(int128)
{
    //The sigmoid function is f(x) = 1 / (1 + e^(-x))
    x =  ONE + ABDKMath64x64.exp(-x);
    int128 y = ABDKMath64x64.div(ONE,x);
    return y;

}

//Sigmoid activation function to process a np array
function sigmoid(int128[] memory x) public pure returns(int128[] memory)
{
    uint xSize = x.length;
    int128[] memory y_Preds = new int128[](xSize);

    for(uint8 i = 0; i < xSize; i++ )
    {
         y_Preds[i] =  sigmoidSingle(x[i]);
    }

    return y_Preds;
}

where the input array x of the sigmoid function is an array of 64.64 fixed point format numbers. I am converting the numbers with Python taking advantage of the following function:
def toFixedPoint64(x):
    x = x * (2**64)
    y = round(x + 0.5)
    return y

Now, assume that i want to convert the following array of floating point numbers:
[0.52,0.49,-0.20,0.57]

The resulting array would be:
[9592306918328967168, 9038904596117680128, -3689348814741910528, 10514644122014443520]

When i give in input this array to sigmoid function, i'm getting the following error:

Error encoding arguments: Error: invalid number value (arg="", coderType="int128", value=9592306918328967000, version=4.0.44)

I don't get why I am having this issue, indeed with an int128 i should be able to represent higher values of this one. Also i don't get why the number is cut to 9592306918328967000.
Consider that if I give in input the number 9592306918328967168 to the sigmoidSingle function i don't get any problem, on the contrary it returns the correct result.
Now, I suspect that the problem may arise because of the array, but since I'm not a Solidity expert I don't know what to think.
Is there anyone who can help me understand the situation?
UPDATE:
It is a problem of the VM simulator. Giving the number surrounded by quotation marks should work. Ex: "9592306918328967168" is the correct way to give in input this int128 to Remix GUI.


texts:
I have a binance smart chain token, and it was all working fine. I was able to call the contract to excluded from fee and other transactions fine initially when we launched. Since i have burnt lots of the tokens and i wish to exclude them from rewards, when i try to make any calls now I get the error in metamask- "Exception is thrown in contract code".
Contract is here, anyone able to point me in the right direction please?
https://bscscan.com/token/0x9e993671976a5ac51bbfb3db9e34eac8d518fe82


texts:
In the following article (Link to the article: https://medium.com/nearprotocol/unsolved-problems-in-blockchain-sharding-2327d6517f43), the challenges of zk-SNARKs are mentioned as
follows:

  The challenges of zk-SNARKs, besides performance, are:

  Dependency on less-researched and less-time-tested cryptographic primitives;
  “Toxic waste” — zk-SNARKs depend on a trusted setup in which a group of people performs some computation and then discards the intermediate
  values of that computation. If all the participants of the procedure
  collude and keep the intermediate values, fake proofs can be created;
  Extra complexity introduced into the system design;
  zk-SNARKs only work for a subset of possible computations, so a protocol with a Turing-complete smart contract language wouldn’t be
  able to use SNARKs to prove the validity of the chain.”

The questions are:

Why is NOT a protocol with a Turing-complete smart contract language able to use SNARKs to prove the validity of the chain?
What does it mean: " zk-SNARKs only work for a subset of possible computations "


texts: UnimplementedFeatureError: Nested dynamic arrays not implemented here - bytes[]

texts:
I created a solidity file which store all details in blockchain(ganachi-desktop application). Details was mapped with 'id' which is an alphanumeric number (eg: US644563496).Now I need to display all 'ID' from blockchain. But during compilation I'm getting error 'UnimplementedFeatureError: Nested dynamic arrays not implemented here.'

pragma solidity ^0.4.4;

contract Register{

 struct Details{
    bytes id;
    string name;
    string age;
   string country;
 }
 mapping (bytes => Details) DetailsTable;

bytes[] uid;

 function saveBondToBC(bytes id,string name,string age,string country) payable returns(bool success){

DetailsTable[id].id = id;
DetailsTable[id].name = name;
DetailsTable[id].age = age;
DetailsTable[id].country = country;
return true;

}

function insertID(bytes id) payable returns(bool success){

uid.push(id);
return true;

}

function getAllID() public returns(bytes[]){

    return uid;

}

}

When I removed function getAllID(),it compiled and 'id' was push into array. How to fetch all data from byte[] uid?


texts: Good Day. 8 days ago I received an alleged payment in eth for rinkeby, a network that I do not know. I told the buyer until I have them in another wallet I would not send them. well 8 days ago and I don't know how rinkeby works or is it a Faucett, I think they wanted to scam me. who can clarify this matter for me. thank you.


texts: Require not working on geth private node

texts:
I have created this contract to manage a votation:

pragma solidity ^0.5.7;

contract Votacion{
mapping(uint => address[]) private votosCandidatos;
uint[] listaCandidatos;
bool abierta;

address private creador=msg.sender;

constructor(uint[] memory candidatosIds) public{
    listaCandidatos = candidatosIds;
    abierta = false;
    for (uint i = 0; i < candidatosIds.length; i++)
    {
        votosCandidatos[candidatosIds[i]];
    }
}

function ind(address[] memory v, address e) public pure returns (bool){
    bool found = false;

    for(uint i = 0; i < v.length && !found; i++)
    {
        found = v[i] == e;
    }

    return found;
}

function votar(uint candidato) public{
    bool ya_votado = false;

    for (uint i = 0; i < listaCandidatos.length && !ya_votado; i++)
    {
        ya_votado = ind(votosCandidatos[listaCandidatos[i]],msg.sender);
    }

    require(!ya_votado,"Ya ha ejercido su derecho a voto");
    //assert(!ya_votado);
    require(abierta,"La votación no es accesible en este momento");
    //assert(abierta);
    votosCandidatos[candidato].push(msg.sender);
}

function abrir() public{
    require(msg.sender == creador,"Permiso denegado");
    abierta = true;
}

function cerrar() public{
    require(msg.sender == creador,"Permiso denegado");
    abierta = false;
}

function revisar_voto() public view returns (uint)
{
    require(!abierta,"La votación no ha terminado aun");
    bool ya_votado = false;
    uint res;

    for (uint i = 0; i < listaCandidatos.length && !ya_votado; i++)
    {
        ya_votado = ind(votosCandidatos[listaCandidatos[i]],msg.sender);
        res = i;
    }

    return res;
}

function resultados() public view returns (uint[] memory){
    require(!abierta,"La votación no ha terminado aun");

    uint[] memory resul = new uint[](listaCandidatos.length);

    for (uint i = 0; i < listaCandidatos.length; i++)
    {
        resul[i] = votosCandidatos[listaCandidatos[i]].length;
    }

    return resul;
}
}

The thing is that I control if the votation has started with the flag abierta. So if I try votar and abierta=false, it would throw an exception, but nothing happens. I have tried this on remix and works perfectly, but when I try to use on my python script it doesn't work.

Here is the script:

import json
from web3 import Web3, IPCProvider
import os
import sys

w3=None

if __name__ == "__main__":
    w3 = Web3(IPCProvider("./testNet/geth.ipc"))

    argumentos=sys.argv
    direccion_contrato=argumentos[1]
    votante=argumentos[2]
    voto=argumentos[3]

    truffleFile = json.load(open('./build/contracts/Votacion.json'))
    abi = truffleFile['abi']
    bytecode = truffleFile['bytecode']
    contrato= w3.eth.contract(bytecode=bytecode, abi=abi,address=direccion_contrato)

    fichero=''
    ficheros = os.listdir("./testNet/keystore")
    cuenta=votante.replace("0x",'').lower()
    for fs in ficheros:
        print(fs,cuenta)
        if cuenta in fs:
            fichero=fs

    with open("./testNet/keystore/"+fichero) as keyfile:
        encrypted_key = keyfile.read()
        private_key = w3.eth.account.decrypt(encrypted_key, 'space treat blame exhibit tissue book decide fury exhaust hazard library effort')

    tx=contrato.functions.votar(int(voto)).buildTransaction({'from': votante,'gas':'0xa551','nonce':w3.eth.getTransactionCount(votante) + 1})
    signed_tx = w3.eth.account.signTransaction(tx, private_key.hex())
    try:
        hash= w3.eth.sendRawTransaction(signed_tx.rawTransaction)
        print("1")
    except Exception as e:
        print("0")

What should I do?


texts: Unlock contract deploy address in Truffle testing using TestRPC?

texts:
I'm trying to test a function in a contract that sends ether from itself to another contract address. However in my Truffle tests I keep getting Uncaught Error: Error: could not unlock signer account.  I have tried web3.personal.unlockAccount, however that doesn't appear to be supported in TestRPC?

Running TestRPC with -u flags doesn't help either because the contract address isn't in the list of accounts.

I thought it might be possible by using --fork but since Truffle does a fresh deploy on every test I can't get the deploy address to run -u <address> with --fork :(.

How can I either unlock this account so that I can test the functionality with Truffle, or workaround this to test that function?


texts:
We have a smart contract deployed on main net and some of the recent transactions have started failing. Any idea how we can start debugging the contract?

Contract address: 0x81EAF1fF62BB8ccaa5314287B14e75E04E21b8F2

Most recent three transactions that have failed
0x7ea699902c6a4be61d0037baaabbb8be5269cb2956c2fe617e88b82304aba615
0x1e29f225021bc9f9c886bdcb1a5a69af98ae5b7821773c40f0ad23a82975c8e5
0xbe4853a7d079ef35e88bdb3c5e2f44ced4263d13ced64563143514400a342b1b


texts: Casper versus Proof of Stake on Other Blockchains

texts:
I get the impression that work on Ethereum's proof of stake protocol Casper is a tough project.

What makes it so that bringing proof of stake to Ethereum is more difficult compared to all the other proof of stake cryptocurrencies that are already out there?


texts: Unable to get the Ethereum accounts (eth_accounts) using the JSON RPC

texts:
I launched an Ethereum installation with the Amazon Blockchain Templates using the simplest installation, the docker-local with a private network (not connected to the public Ethereum network).

Everything seems to work correctly. I can see the Ethereum Network Status website and the Ethereum Block Explorer website.

The JSON RPC (:8545) seems to work OK too:

# This works:
curl -d '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":67}' -H "Content-Type: application/json" -X POST http://127.0.0.1:8545
{"jsonrpc":"2.0","id":67,"result":true}

# This works too:
bash-4.2# curl -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x0ADfCCa4B2a1132F82488546AcA086D7E24EA324", "latest"],"id":1}' -H "Content-Type: application/json" -X POST http://127.0.0.1:8545
{"jsonrpc":"2.0","id":1,"result":"0xcc19df002cd1b40000"}

But when I try to list all the accounts, I get an empty array, when there should be a list of 3 accounts:

bash-4.2# curl -d '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" -X POST http://127.0.0.1:8545
{"jsonrpc":"2.0","id":1,"result":[]}

Does anyone know what can be happening? I tried this solution with no luck, as the daemon is running and I'm not able to change the geth status, and it seems (I'm not sure) I'm not a launching it on a testnet (no --testnet parameter)

The geth running inside the container seems to be well configured to serve all the JSON RPC calls:

/opt/ethereum-go/bin/geth --nodiscover --networkid 1234 --rpc --rpcapi web3,net,eth --rpcaddr 0.0.0.0 --rpcvhosts * --rpccorsdomain * --ws --wsapi web3,net,eth --wsaddr 0.0.0.0 --wsport 8546 --wsorigins bin --mine --minerthreads 1 --etherbase 0x0ADfCCa4B2a1132F82488546AcA086D7E24EA324 --targetgaslimit 8000000 --gasprice 0

Can someone give me a hand, please?


texts:
I have setup an application with jhisper gateway with one microservice in REST linked to Web3j. Idea is when you store an object in the database, you notarize it in a private ethereum blockchain.

So, I have a REST Post service to create the object in database, then he call a smartcontract to notarize it in the blockchain.
Everything is working for One object at a time but if I make a loop without wait method, it will create in the blockchain only the first one. Like it didn't call it several time...

when I look to the log of the miner (txpool.status)

txpool.status
{
  pending: 1,
  queued: 0
}

I have never more than 1 in pending, such as he did 'nt see the 100 other...

        List<Long> thingIds = new ArrayList<Long>();
    for(int i=0; i<10;i++) {
        ApiClient apiClient = new ApiClient();
        HttpBasicAuth authentication = (HttpBasicAuth)apiClient.getAuthentications().get("basic");
        authentication.setBasePath("http://localhost:8080/");
        authentication.setCredentials("admin","admin");
        Date d = new Date();
        String a= ""+d.getTime();

        ThingResourceApi agentResourceApi = new ThingResourceApi(apiClient);
        thing = new Thing();
        thing.setName("Paris"+(new Date().getTime()));
        thing.setCollectorAddress("0x3baeb8019a9cc9c488aa9355dc522e023a3b406d");

        thing = agentResourceApi.createThingUsingPOST(thing);
        thingIds.add(thing.getId());
    }

if i add the following snipped at the end of the loop, it works

try {
        TimeUnit.SECONDS.sleep(100);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

I am sorry if it is a little confusing, hope you will have an interest to give me idea to solve it...

Francois


texts: geth --fast sync extremely slow when run under systemd

texts:
I have dedicated an intel atom laptop with 2GB of memory and a 300+GB SSD as my ethereum node.  I am running geth as systemd daemon.  Now it's been running 3+ days day and night, with the command:

geth --fast --cache=1024 --jitvm 2

But alas, I open ethereum wallet and it says I have only 1% of the blockchain donwloaded.. (I am behind a 10Mbps connection to the internet)

Using

geth attach

and then

eth.syncing

gives

  {
    currentBlock: 178336,
    highestBlock: 3405682,
    knownStates: 1069106,
    pulledStates: 1000195,
    startingBlock: 105918
  }

This is madness..! Or do I need a supercomputer, attached to a nuclear reactor just to download the blockchain?  Now it seems that it will take two months in total ..

EDIT (the next day)

Good evening.  Today we're at

  {
    currentBlock: 258502,
    highestBlock: 3411279,
    knownStates: 58508,
    pulledStates: 21838,
    startingBlock: 256974
  }

Looking at the number of peers, it seems there are 24

admin.peers.length
24

Thanks for the suggestion, but the number of peers does not seem to be the issue.. how could I check if NAT traversal is an issue..?  I have configured my router to forward everything to my home server.. (no firewalls, NATs, nothing)

EDIT after a few days

Still going strong

  {
    currentBlock: 887422,
    highestBlock: 2283547,
    knownStates: 2144,
    pulledStates: 126,
    startingBlock: 887418
  }

This Ethereum thing is so great.

EDIT (after a few more days)

  eth.syncing
  {
    currentBlock: 908606,
    highestBlock: 1211334,
    knownStates: 70444,
    pulledStates: 7563,
    startingBlock: 906796
  }

I'm using at the moment

geth --fast --cache=512 --nat=none

Memory usage:

               total       used        free      shared  buff/cache   available
Mem:           1,9G        1,4G         69M         20M        505M        380M
Swap:          2,0G         99M        1,9G

.. so not gone completely swappy either.

It's also weird that the highest block should be, according to "ethstats.net" 3 million+.  It's correct in the first "eth.syncing" I've written here, but in the last update its only one million+ ???

Don't know if it's a bug in the pre-packacked .deb distro (lots of people seem to have problems with them..) or what.

This'll be enough ethereum for me at the moment ..not quite plug'n'play yet

EDIT:

So, I downloaded go-ethereum from github, golang from google, etc. Now I have geth compiled from source.

I am running with

geth --cache=512 --nat=none

Still no success.  It started quite well.. after 3-hours or so, I got

  {
    currentBlock: 967477,
    highestBlock: 3551915,
    knownStates: 6218249,
    pulledStates: 6218249,
    startingBlock: 0
  }

.. but after it's been running for 24h+ (I have 9 peers at the moment):

  eth.syncing
  {
    currentBlock: 989279,
    highestBlock: 3558249,
    knownStates: 149529,
    pulledStates: 127316,
    startingBlock: 973578
  }

I'm am starting to be convinced that this is a russian Ponzi-scheme (as someone suggested..) .. ! :-o


texts: what is use of question mark '?' in solidity

texts: In solidity I came across a code uint256 q = p % 2 != 0 ? a : b; what does it mean ?


texts: How to get the running instance of a Contract

texts:
I have a contract with name AuxContract and imported it in my Dapp.sol.

In my Dapp.sol I have a variable of type AuxContractwhich I want to initialize with a running instance of an AuxContractcontract which I have its address.
How can I do this?


texts: How can I implement rational operations in Solidity?

texts:
First, I know that fixed point integers are coming...but I really need to know how to accomplish a simple operation who return a rational number.

For example, get 2% of 350 is easy implementing: 350/50 because the result is an integer = 7. However, 2% of 340 is not easy...the result is 6,8...so how can I get 0.8?

I´ve tried several ways...but I can't do it. Is there any library or smt related to math applied to division?


texts: go-ethereum keccak256 multi value byte slice does not match solidity keccak256

texts:
I have a smart contract with the following function:

function testHash(
    address _sender,
    uint8 _method,
    uint256 _number,
    uint256 _amount)
    public
    returns (bytes32)
{
return keccak256(abi.encodePacked(_sender, _number, _method, _amount));
}

Which when given the following values 0xa1d9e8788414eA9827f9639c4bd81bA8f3A29758, 0, 0, 0  produces the following hash 0x65a0fc07391cb16f60c589836a72bdeaf2ab8bcb16c819126abba4408e069bcb

I have the following golang code

func GenerateSignedPaymentMessage(ethAddress common.Address, paymentMethod uint8, paymentNumber, chargeAmountInWei *big.Int) []byte {
//keccak256(abi.encodePacked(msg.sender, _paymentNumber, _paymentMethod, _chargeAmountInWei))

addressBytes := ethAddress.Bytes()
// we need to cast to []byte in order to generate a keccak hash
methodBytes := make([]byte, 1)
methodBytes[0] = byte(paymentMethod)
numberBytes := paymentNumber.Bytes()
amountBytes := chargeAmountInWei.Bytes()
// generate the hash
hash := crypto.Keccak256(addressBytes, numberBytes, methodBytes, amountBytes)
return hash

}

Which when I call like so

address := common.HexToAddress("0xa1d9e8788414eA9827f9639c4bd81bA8f3A29758")
method := uint8(0)
number := big.NewInt(0)
amount := big.NewInt(0)
hash := GenerateSignedPaymentMessage(address, method, number, amount)
fmt.Println(hash.String())

which gives the following output 0x7fc96d5f44e3e792633fcc981adf2bd0f644f0c167132eca5659b8a72d95bf07 which does not match the hash given by the solidity code. I'm unsure what to do here so any advice would be great!

EDIT:

As pointed out by smarx, I tried the following function

func TestHash(t *testing.T) {
address := common.HexToAddress("0xa1d9e8788414eA9827f9639c4bd81bA8f3A29758")
bn := make([]byte, 32)
ba := make([]byte, 32)
bm := make([]byte, 32)
bn[31] = 0
ba[31] = 0
bm[31] = 0
hash := crypto.Keccak256Hash(address.Bytes(), bn, ba, bm)
fmt.Println(hash.String())
}

Which produces the following hash 0xfc60222910c18ebcfd5610479223663effa903325f3db1db39a4d5fa37ba33a2


texts:
First, I'm brand new to the Ethereum platform, and I'm simply trying to learn how the platform works at the moment, so I do apologise if any of the following is considered stupid questions. Now, here goes anyways

Is there any way of centrally funding a contract? So, if you have a smart contract, it can fund transactions of a certain type of token. So, for example, if I got a token I want to be free to move around, between wallets, the idea would be that the transaction fees where funded centrally.
Is it possible to mine transactions for a particular class of token? So, say, if I had a token, and I set the gas extremely low to keep costs down, could I then set up miners only mining that type of token?


texts: Ropsten Block Height is different than Block Height on local GETH instance

texts:
I am running a GETH instance on my machine

geth --testnet --syncmode "fast" --ipcpath /home/ubuntu/.ethereum/geth.ipc --rpc --rpcapi db,eth,net,web3,personal --cache=2048 --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "db,eth,net,web3,personal" --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303,enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303" --verbosity=6 --port "30303" --networkid 3

The Block height on Ropsten currently is Block 3454032

When I call eth.syncing from my console I get

currentBlock: 2848357,
  highestBlock: 3093429,
  knownStates: 6039183,
  pulledStates: 6039183,
  startingBlock: 2847921

highestBlock on mine reads lower than what Ropsten is displaying. Is the going to be a problem when the sync is completed at 3093429 and Ropsten is at 3454032?

Am I about to find out after 2 days of syncing it was all for nothing?


texts: What is the network layer in which RLPx is used for peering in Ethereum

texts:
We had a question from our client as such they need to know in which Network layer is the RLPx protocol being used for the peering process

I have got to know that peering process happens using RLPx protocol, which is a TCP based protocol, but the question is like in which network layer(out of 7 layers in TCP) is the RLPx protocol used?

Regards,
Manoj


texts:
I have geth 1.5.8 and Mist 0.8.9. Geth is running Homestead with default parameters. IPC is in the default location.

 $ geth version
Geth
Version: 1.5.8-stable
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.7.5
OS: linux
GOPATH=/home/user/.go
GOROOT=/usr/lib/go
 $ mist --version
[2017-02-11 17:06:00.857] [INFO] main - 0.8.9
 $ ls -lsha $HOME/.ethereum/geth.ipc
0 srw------- 1 user users 0 Feb 11 17:03 /home/user/.ethereum/geth.ipc

However, my mist wallet does not connect to geth. Even when I teach it about the path to the geth binary it starts to download a new node.

 $ mist --gethpath /usr/bin/geth
[2017-02-11 17:08:30.103] [INFO] main - Running in production mode: true
[2017-02-11 17:08:30.163] [INFO] main - Starting in Mist mode
[2017-02-11 17:08:30.190] [INFO] Db - Loading db: /home/user/.config/Mist/mist.lokidb
[2017-02-11 17:08:30.197] [INFO] Windows - Creating commonly-used windows
[2017-02-11 17:08:30.197] [INFO] Windows - Create secondary window: loading, owner: notset
[2017-02-11 17:08:30.216] [INFO] updateChecker - Check for update...
[2017-02-11 17:08:31.590] [INFO] Windows - Create primary window: main, owner: notset
[2017-02-11 17:08:31.602] [INFO] Windows - Create primary window: splash, owner: notset
[2017-02-11 17:08:31.823] [INFO] ipcCommunicator - Backend language set to:  en-US
[2017-02-11 17:08:32.364] [INFO] (ui: splashscreen) - Web3 already initialized, re-using provider.
[2017-02-11 17:08:32.439] [INFO] ClientBinaryManager - Initializing...
[2017-02-11 17:08:32.439] [INFO] ClientBinaryManager - Resolving path to Eth client binary ...
[2017-02-11 17:08:32.439] [INFO] ClientBinaryManager - Eth client binary path: /usr/share/mist/nodes/eth/linux-x64/eth
[2017-02-11 17:08:32.440] [INFO] ClientBinaryManager - Checking for new client binaries config from: https://raw.githubusercontent.com/ethereum/mist/master/clientBinaries.json
[2017-02-11 17:08:32.673] [INFO] updateChecker - App is up-to-date.
[2017-02-11 17:08:32.831] [INFO] ClientBinaryManager - No "skippedNodeVersion.json" found.
[2017-02-11 17:08:32.833] [INFO] ClientBinaryManager - Initializing...
[2017-02-11 17:08:32.834] [INFO] ClientBinaryManager - Resolving platform...
[2017-02-11 17:08:32.835] [INFO] ClientBinaryManager - Calculating possible clients...
[2017-02-11 17:08:32.839] [INFO] ClientBinaryManager - 1 possible clients.
[2017-02-11 17:08:32.839] [INFO] ClientBinaryManager - Verifying status of all 1 possible clients...
[2017-02-11 17:08:32.841] [INFO] ClientBinaryManager - Verify Geth status ...
[2017-02-11 17:08:32.859] [ERROR] ClientBinaryManager - Unable to resolve Geth executable: geth
[2017-02-11 17:08:32.864] [INFO] ClientBinaryManager - Download binary for Geth ...
[2017-02-11 17:08:32.867] [INFO] ClientBinaryManager - Downloading package from https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.5.8-f58fb322.tar.gz to /home/user/.config/Mist/binaries/Geth/archive.tar ...
^C[2017-02-11 17:08:36.336] [INFO] main - Defer quitting until sockets and node are shut down
[2017-02-11 17:08:36.336] [INFO] Sockets - Destroy all sockets
[2017-02-11 17:08:36.338] [INFO] Sockets/3 - Disconnecting...
[2017-02-11 17:08:36.340] [INFO] Sockets/node-ipc - Disconnecting...
[2017-02-11 17:08:36.343] [ERROR] main - Error shutting down sockets
^C

This is really annoying. Why is Mist checking the binary path anyways? Didn't the browser connect directly to the IPC in earlier releases?

Parity has a --no-download option, is there anything similar for Mist?


texts: In proof of stake, is there a difference between being offline and deciding to leave entirely?

texts: I'm struggling to understand the proof of stake concept.  As I understand it, in order to participate in validation and its rewards, you must ante up some ether (I was told a minimum of 32).  You are then punished if you act badly.  I'm told this would include being offline for periods of time.  Does that mean that if you decide you no longer want to participate in validation, you lose whatever your initial ante was?  I guess I'm asking if there's a scenario where you can get your initial deposit back.


texts:
NOTICE: The below implementation works. It assumes that the calling addresse has approved both the spender and the contract to carry the transaction. Because they were not approved it was not working.

I am using this smart contract which is supposed to accept ERC20Tokens and it would allow me to send them to a different address. For instance, the smart contract allows users to send their erc20tokens which will be forwarded to the provided address.

I tried different ERC20Tokens that I created however the smart contract always returns a transaction failed event. When I call the transferTokens() function it fails the transaction. The smart contract:

pragma solidity ^0.4.24;
import "http://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";

contract SendableERC20{

 struct Transfer {
    address contract_;
    address to_;
    uint amount_;
    bool failed_;
 }
 mapping(address => uint[]) public transactionIndexesToSender;

 Transfer[] public transactions;
 address public owner;
 address invalidTo_;
 mapping(string => address) tokens;
 IERC20 public IERC20Interface;
 event TransferSuccessful(address indexed from_, address indexed to_, uint256 amount_);

 event TransferFailed(address indexed from_, address indexed to_, uint256 amount_);

 constructor() public {
    owner = msg.sender;
 }
 function addNewToken(string symbol_, address address_) public onlyOwner returns(bool){
    tokens[symbol_] = address_;

    return true;
 }

 function removeToken(string symbol_) public onlyOwner returns(bool){
    require(tokens[symbol_] != 0x0);

    delete(tokens[symbol_]);

    return true;
 }
 function returnSymbol(string symbol_)public view returns(address){
    return(tokens[symbol_]);
 }
 function transferTokens(string symbol_, address to_, uint256 amount_) public {
    require(tokens[symbol_]!= 0x0);
    require(amount_ > 0);

    address contract_ = tokens[symbol_];
    address from_ = msg.sender;

    IERC20Interface = IERC20(contract_);

    uint256 transactionId = transactions.push(
        Transfer({
            contract_: contract_,
            to_: to_,
            amount_: amount_,
            failed_: true
        }));

    transactionIndexesToSender[from_].push(transactionId -1);

    if(amount_ > IERC20Interface.allowance(from_, address(this))){
        emit TransferFailed(from_, to_, amount_);
        revert();
    }

    IERC20Interface.transferFrom(from_, to_, amount_);

    transactions[transactionId -1].failed_ = false;

    emit TransferSuccessful(from_, to_, amount_);
 }
 modifier onlyOwner(){
    require(msg.sender == owner);
    _;
 }

}

Must mention information:

I tried to accomplish it on Rinkeby using this token implementation (not mine but I retain it a great implementation since it uses SafeMath).

In the main smart contract which allows users to transfer their ERC20 tokens, I considered mapping tokens as bytes32 rather than string, however for the purpose of testing I implemented it as string in the smart contract provided.

I invite you to try the smart contract accessing this link on Remix which uses the same compiler as I used. Deploy both the contract and the token using Metamask on Rinkeby network. Make sure you give allowance to your address if you use the token that I provided. Then try to use SendableERC20 contract to send tokens from your Metamask wallet to another address and you will see that it will fail. The event "TransferFailed" will always be called for no reason.

I start believing that it's a logic error that I can't find.


texts: How to deploy ethereum smart contract with parameters using web3 1.2.6?

texts:
I am trying to deploy smart contract using web3 1.2.6 , my smart contract accepts 2 argument in constructor : id , name. I dont know what i am doing wrong , but both approaches are not working. Error (Approach 1 - You must provide the json interface of the contract when instantiating a contract object || myContract.new.getData is not a function)  Error (Approach 2 - The method eth_sendTransaction not found or does not exist.)

Approach - 1

var priKey = Buffer.from(config.private_key_sender.slice(2), 'hex');

    var myContract = new web3.eth.Contract(abi.data);
    var contractData = myContract.new.getData(
        'id12345',
        'John Shelby'
        {
            data: bytecode.data,
        });

    web3.eth.getTransactionCount(config.send_add, (err, txCount) => {
        if (txCount) {
            var txObject = {
                nonce: web3.utils.toHex(txCount),
                gasLimit: web3.utils.toHex('1000000'),
                gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
                data: contractData
            };
        } else if (err && err.message) {
            next(err.message, null);
        }

        // sign the transaction
        const tx = new Tx(txObject);
        tx.sign(priKey);

        // serialize the transaction
        const serializeTransaction = tx.serialize();
        const raw = '0x' + serializeTransaction.toString('hex')

        web3.eth.sendSignedTransaction(raw, (err, txHash) => {
            if (txHash) {
                console.log("transaction hash : ", txHash)
                next(null, txHash);
            }
            else if (err && err.message) {
                next(err.message, null);
            }
            else {
                next('Unable to sendRawTransaction', null);
            }
        });
    })

Approach - 2

exports.deployContract = async (next) => {
    var priKey = Buffer.from(config.private_key_sender.slice(2), 'hex');
    const sourceCode = fs.readFileSync('/home/puneet/puneet/projects/EstateBlocks/estateBlocks/contract/17april_1.sol', 'utf8').toString();
    const compiledCode = compiler.compile(sourceCode, 1).contracts[':EstateBlock']
    const interface = JSON.parse(compiledCode.interface);
    const bytecode = compiledCode.bytecode;
    function deploy_contract(){
        const myContract = new web3.eth.Contract(interface);
        myContract.deploy({data:bytecode,arguments:['id12345' , 'John Shelby']}).send({
            from: config.send_add,
            gas: web3.utils.toHex('1000000'),
            gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei'))
        },(err,res) => {
            if(err){
                console.log(err);
            }
            if(res){
                console.log(res);
            }
        })

    }
    deploy_contract()
}


texts: mist.exe , Ethereum-Wallet.exe not a Win32 valid application

texts:
I can't install any kind of official wallet on my computer.
When i try to run the exe from the downloaded content all i get is this error not a valid Win32 application.
I can not run on my Windows XP SP 3 32-bit computer.
I have chose to download the proper version for my computer :
Mist-win32-0-8-0.zip
or
Ethereum-Wallet-win32-0-8-0.zip
but nothing works.
Also if i try to run geth.exe i get an error about a msvcrt.dll :

"The procedure entry point fopen_s could not be located in the dynamic link library msvcrt.dll"

How long should i wait until a proper 32bit version will be released ?

All i want is a secure official wallet for ETH to make transactions specially to receive ETH from faucets or mining on a cloud mining and to sell it on a an exchange later.
Thanks.


texts: any ethereum web wallet without running local node

texts:
any php script for eth web wallet without ruining a  local node on my server? So I can integrate the web wallet into my site without running local node on my server.
By the way, how big the size of the eth local node will be and how much bandwidth required?
possible to put the local node on one server and the web wallet on another server? need some setting for rpc call?
Thanks


texts: oraclize price for random value too high (rinkeby)?

texts:
Currently, when I call

oraclize_getPrice("random", 400000);

I get back

8000000000000000

on rinkeby. That'd be over 2$ USD if on the mainnet and also looks oddly round.
Why is this so high?


texts:
I have following code of my smart contract, it has simple problem:

  browser/Referrals.sol:100:35: TypeError:  Type function (uint256) pure
  returns (address[] memory) is not implicitly convertible to expected
  type address[] storage ref.
          ReferralsOf[msg.sender] = new address[];

Can you explain how can I solve this problem.

library SafeMath
{
    function add(uint a, uint b) internal pure returns (uint c)
    {
        c = a + b;
        require(c >= a);
    }
    function sub(uint a, uint b) internal pure returns (uint c)
    {
        require(b <= a);
        c = a - b;
    }
    function mul(uint a, uint b) internal pure returns (uint c)
    {
        c = a * b;
        require(a == 0 || c / a == b);
    }
    function div(uint a, uint b) internal pure returns (uint c)
    {
        require(b > 0);
        c = a / b;
    }
}

contract Owned {
    address public owner;
    address public newOwner;

    event OwnershipTransferred(address indexed _from, address indexed _to);

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

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

    function transferOwnership(address _newOwner) public onlyOwner {
        newOwner = _newOwner;
    }
    function acceptOwnership() public {
        require(msg.sender == newOwner);
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
        newOwner = address(0);
    }
}

contract ReferraledToken is Owned
{
    using SafeMath for uint;
    string public symbol;
    string public  name;
    uint8 public decimals;
    uint _totalSupply;
    uint64 current = 100000;
    mapping(address => uint) balances;
    mapping(address => address) ReferralOf;
    mapping(address => address[]) ReferralsOf;
    mapping(address => uint64) ReferralLink;
    mapping(uint64 => address) LinkOf;
    mapping(address => bool) registeredUser;

    constructor() public {
        symbol = "LETO";
        name = "IT project";
        decimals = 5;
        _totalSupply = 1000000 * (10 ** uint(decimals));
        balances[owner] = _totalSupply;
    }

    function totalSupply() public view returns (uint)
    {
        return balances[owner];
    }
    function balanceOf(address tokenOwner) public view returns (uint balance)
    {
        return balances[tokenOwner];
    }
    function transfer(address to, uint tokens) public returns (bool success) {
        balances[msg.sender] = balances[msg.sender].sub(tokens);
        balances[to] = balances[to].add(tokens);
        return true;
    }
    function sendPurchaseToken(address to) payable public returns (bool)
    {
        balances[owner] = balances[owner].sub(uint(decimals) * msg.value / 10);
        balances[to] = balances[to].add(uint(decimals) * msg.value / 10);
        return true;
    }
    function registerUser(uint64 _code) public
    {
        require(registeredUser[msg.sender] == false);
        ReferralOf[msg.sender] = LinkOf[_code];
        ReferralsOf[LinkOf[_code]].push(msg.sender);
        ReferralLink[msg.sender] = current;
        LinkOf[ReferralLink[msg.sender]] = msg.sender;
        ReferralsOf[msg.sender] = new address[];
        current += 1;
    }
    function lengthOfPath(address _start, uint _counter) public returns (uint)
    {
        if (ReferralOf[_start] != owner)
        {
            return lengthOfPath(ReferralOf[_start], _counter + 1);
        }
        else
        {
            return _counter;
        }
    }

}


texts: Adding nodes in private network of docker containers hosted in different VMs

texts:
I am trying to create a non-local private network with go-ethereum running on docker containers hosted in different Virtual Machines. I am having a hard time trying to make the nodes recognize each other. I wonder which is the best strategy to add peers now that bootnode is not working properly (Open Issue #3703). I have followed many aspects of the Vertigobr project.

Knowing that --nodiscover should be enabled to avoid connecting with nodes external to the private network, these are my questions:

Is --nat extip:<VM_EXT_IP> the most convenient nat configuration?
Is only one node (a main one) in possession of the static-nodes.json file and it automatically links itself to the nodes in the file?
According to "Connecting to the network" in the Ethereum's documentation admin.addPeer("enodeURL") only adds nodes temporarily. Does that mean that I have to keep track of my list of nodes in a database, for example, regenerate the static-nodes.json when a new node is created, and restart my "main" node to reload this file? Is there an easier way?


texts:
I am currently playing around with Solidity and dynamic arrays. I have the following code:

contract Test{
    int256[] public test;

    function setTest(int256 b) public{
        test.push(b);
    }

    function setTest2(uint256 a, int256 b) public {
        test[a] = b;
    }
}

I executed the code in remix. When I call setTest(1) and call the getter test(0), the output is 1. If I do the same with setTest2(0, 1) and call the getter afterwards, the value does not seem to be saved. I don't understand why. Could someone explain what is going on here?

Thanks in advance.

I realized that my question is not really clear and I will ask the question here and this time more clear. Thanks for the other answers already.

I call the function setTest2(0, 1) and call the getter afterwards, remix shows me that the value at position 0 is 0 and not 1.
When I call the setTest(2) function and call the getter afterwards, the value 2 is at position 0 of the array and not at position 1. This means that the value of the first call has not been saved. Why?


texts: Better Platform to store data out of ethereum blockchain

texts:
What can be the better alternative for someone who is willing to store data off-chain?
What smart-contract suppose to do is just sign a transaction and perform, while every piece of information needs to be saved off-chain. IPFS is one of the popular distributed storage systems but is there any other platform that Dapps usually pick for storage?


texts: Dapp not conecting (through web3) when called from browser which dont have node running on it

texts:
trying to connect dapp through browser,when doing the same through the browser on machine which has running geth node is getting connect through  public ip (eg :http175.xxx.xxx.xx:xxxxlogin) but the same when trying to connect through different browser specifically different machine it is throwing error in console

  Error: CONNECTION ERROR: Couldn't connect to node
  http://192.xxx.x.xx:8484

geth command :-geth --rpccorsdomain "*" --rpc --rpcport "8484"  --rpcaddr "192.xxx.x.xx" --datadir="xxxx" --port "30302" --networkid 65535 --rpcapi="db,eth,net,web3,personal,web3"  --nodiscover console

web3 code

var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://192.xxxx.x.xx:8484'));
web3.eth.defaultAccount = "0x6f3ae17a20d3367d649f8774a42a15xxxxxxxxxx";

192.xxx.x.xx:8484 is ip of the node

waiting for suggestions ..


texts: Have there been any systems in use that are similar to Vlad Zamfir's consensus-by-bet?

texts: Do prediction markets use a similar betting game where early bets give high rewards, and late bets give lower rewards?


texts: What are differences between Ethereum and EOS?

texts:
EOS (is currently under development) is an open source smart contract platform like Ethereum.

=> What are the main differences between Ethereum and EOS such as:

How EOS is different than Ethereum that it brings block time to 0.5 seconds? How is this possible since Ethereum's average block time is around ~12 seconds? Please see following question related to Ethereum average block time in detail.

Vitalik Buterin mentioned that:

  Hence, a 3-second target block time (and 5s actual block time) may be
  quite viable. As usual, we’ll be more conservative at first and not
  take things that far, but a block time of 12s does nevertheless seem
  to be very much achievable.

What are the things that EOS can do that Ethereum cannot?
Ethereum vs EOS: Technical Differences.
Ethereum vs EOS: Scalability.


texts: How to connect to Ethereum node (geth) via IPC from outside of docker container

texts:
I'm using docker-compose to run ethereum node with Docker:

  # ethereum node
  ethereum:
    container_name: ethereum-node
    image: ethereum/client-go:v1.8.10
    ports:
      - "8545:8545"
      - "8546:8546"
      - "30303:30303"
      - "30303:30303/udp"
    volumes:
      - ./ethereum-data/.ethereum:/root/.ethereum
      - ./ethereum-data/keystore:/root/.ethereum/testnet/keystore
      - ./ethereum-data/.ethash:/root/.ethash
    restart: always
    command: -verbosity=4 --fast --cache=512 --testnet

After docker-compose up i can see in the log:

  INFO [07-03|11:40:19] IPC endpoint opened                      url=/root/.ethereum/testnet/geth.ipc

and i'm able to connect to it from the container with

docker exec -ti ethereum-node geth attach ipc:/root/.ethereum/testnet/geth.ipc

Though i've mounted volumes and i can see geth.ipc:

$ls ./ethereum-data/.ethereum/testnet/
.        ..       geth     geth.ipc keystore

i can't connect to from host:

  $geth attach ./ethereum-data/.ethereum/testnet/geth.ipc
  Fatal: Unable to attach to remote geth: dial unix ./ethereum-data/.ethereum/testnet/geth.ipc: connect: connection refused

How can i do it?
I'd prefer to use IPC (though i've succeed to connect over HTTP RPC on 8545).


texts:
I created an Ethereum node (geth) and this automatically created an Ethereum account. Is this account an Ethereum wallet? I then created 2 other accounts using personal.newAccount() command. Are these accounts or wallets?

Thank you


texts: isDerivedKeyCorrect is not recognized as a function

texts:
I call lightwallet in my routes : the keystore is created whenever the user logs in (/login). Then, in another route (/newItem) I have to sign a transaction calling lightwallet.signing.signTx(keyStore, keyStorePw, data, address).

When this function is called I get this error message :
TypeError: keystore.isDerivedKeyCorrect is not a function.

Note that I use :
node v8.2.1
npm v5.2.0
eth-lightwallet v2.5.6
Linux 4.4.0-34-generic #53-Ubuntu


texts: Error returning a uint256 value stored in array

texts:
contract Student
{
uint256 index=0;
function Students(bytes32 name, uint256 adNo) returns (uint256 vid)
{
index++;
Name[index]=name;
AdmissionNo[index]=adNo;
vid=index;
}
mapping(uint256 => bytes32) public Name;
mapping(uint256 => uint256) public AdmissionNo;
}

the return value for vid is like 0xca297a8080be23ace753b20084fd853533af205c16bbfef7aa466208aa0341d5 when printing in html

<!doctype>

Students

Store:
    <input type='text' id='name'>
    <input type='number' id='adNo'>
    <button onclick='set()'>Save</button>

Query:
    <input type='number' id='index'>
    <input value='get' type='button' id='query' onclick='get()' />

when clicking save button it should save and return index of the student


texts:
i set up a quorum network following this tuotorial:

Quorum

Problem is after ran this command geth attach ipc:qdata/dd1/geth.ipc when i tried to run my dapp on top of this network.It was showing me an error message: problem facing your acccount....

"http://127.0.0.1:22000 not allow cross origin..."

I know how to run  --rpccorsdomain on etheruem. But in this case i cannot able to do that


texts: My ethereum mist walled didn't receive my ether

texts: I have sent 10 ETH to my Mist wallet a week ago.. the wallet is synched, there is still 0 ETH balance on it... I am worried now, what should I do? Is my money lost? What is going on, please help.. thank you


texts: Why are underscores used in front of parameters, instead of contract member variables?

texts:
In Solidity, for example, why:

function Greeter(string _greeting) public
{
   greeting = _greeting;
}

instead of:

function Greeter(string greeting) public
{
   _greeting = greeting;
}

The latter appears to be more consistent with other conventions, which borrow from Hungarian notation:

  The notation is sometimes extended in C++ to include the scope of a
  variable, optionally separated by an underscore.[2][3] This extension
  is often also used without the Hungarian type-specification:

g_nWheels : member of a global namespace, integer
m_nWheels : member of a structure/class, integer
m_wheels, _wheels : member of a structure/class
s_wheels : static member of a class
c_wheels : static member of a function


texts:
I'm a newbie at ethereum development (which I'm very enthusiastic about) and I'm trying very hard to create my first smart contract.

It's a test contract to bet on horses race.

I'm currently facing an issue that I failed to solve yet.

1) I can't find to way to log the event triggered to debug my code

2) When I initialize my Race struct, the horsesRunningTheRace doesn't seem to be properly set. It tried several ways but no success so far.

Here is my code so far (I simplified and translated it to focus at the issues):

My contract :

contract HorseRacesBet {

    struct Race {
        uint raceId;
        uint stakesSum;
        bool isOver;
        bool areBetsForbidden;
        uint32[] horsesRunningTheRace;
    }

    address public owner = msg.sender;

    uint courseIDGenerator = 0;
    mapping (uint => Race) races;

    modifier ownerOnly()
    {
        if (msg.sender != owner)
            throw;
        _
    }

    event InitRace(uint32[] horsesRunningTheRaceParam);

    function initRace(uint32[] horsesRunningTheRaceParam) ownerOnly returns(uint) {
        InitRace(horsesRunningTheRaceParam);
        races[courseIDGenerator].raceId= courseIDGenerator;
        races[courseIDGenerator].stakesSum=100;
        races[courseIDGenerator].isOver=false;
        races[courseIDGenerator].areBetsForbidden=false;
        for(uint x= 0; x< horsesRunningTheRaceParam.length; x++ ){
           races[courseIDGenerator].horsesRunningTheRace.push(horsesRunningTheRaceParam[x]);
        }
        courseIDGenerator++ ;
        return races[courseIDGenerator].raceId;
    }

    event GetRaceInfos(uint raceId);

    function getRaceInfos(uint raceIdParam) public returns(uint, uint, bool, uint32[], bool){
       GetRaceInfos(raceIdParam);
       return (races[raceIdParam].raceId, races[raceIdParam].stakesSum, races[raceIdParam].isOver, races[raceIdParam].horsesRunningTheRace , races[raceIdParam].areBetsForbidden);
    }
}

The Javascript Mocha test file :

contract('HorseRacesBet', function(accounts) {

    it("should keep a Race struct in the storage on initRace call", function() {
        var horseBetContract = HorseRacesBet.deployed();
        var horsesRunningTheRace = [10, 20, 30];

        horseBetContract.allEvents(function(error, result) {
            // This will catch all Transfer events, regardless of how they originated.
            console.log('event log');
            if (error == null) {
                console.log(result.args);
            }
        });

        horseBetContract.initRace.call(horsesRunningTheRace).then(function(raceId) {
            assert.equal(raceId.valueOf(), 0, "L'id de la course should be 0'");

            horseBetContract.getRaceInfos.call(raceId).then(function(raceDatas){
                assert.equal(raceDatas[0], 0, "The raceId returned should be 0");
                assert.equal(raceDatas[1].valueOf(), 0, "The sum of all bets should be 0.");
                assert.equal(raceDatas[2], false, "The race shouldn't be over");
                for(var i = 0 ; i< raceDatas[3].length; i++){
                    console.log(raceDatas[3][i].valueOf());
                }
                assert.equal(raceDatas[3], horsesRunningTheRace, "The horses running the race should be the one we initialized the race with.");
                assert.equal(raceDatas[4], false, "The bets shouldn't be closed on the race.");
            });
        });
    });
});

And the output of the test:

  /usr/local/lib/node_modules/truffle/lib/test.js:322
            throw reason;
            ^
      AssertionError: The horses running the race should be the one we initialized the race with.: expected [] to equal [ 10, 20, 30 ]
      at /Users/user/Documents/formation/nigthclazz-ethereum/truffle-project/horse-bet/test/horseRacesBet.js:24:16
      at process._tickDomainCallback (internal/process/next_tick.js:129:7)

Can anyone point me to what I'm obviously missing here?


texts:
Let's say I want to create a token, but I don't want this token to be exchanged too freely, in order to avoid too much of speculation (real estate for example). People willing to sell the asset will have to say how many tokens they want to sell and at what limit they are willing to sell (for example, they want to sell, but no less than 1.10$ per token). Buyers will have to buy by saying how much token they want and specifying the limit to buy (for example they don't want to buy for more than 1.20$ per token). They will also see a recommended price, that corresponds to the real estate asset behind the token.

Every month, we process the buy and sell orders, and the price of execution will be the price that maximizes the number of token exchanged.

Can I enforce this mechanism into an ERC20 token? If so, how to do?
if I do so, then, I need to develop my own exchange answering to these requirements?
If an existing exchange would like to list such a token, my guess is that it would be possible, but will need some custom development to support it. Am I correct?

Thanks for your help!


texts:
How is ethereum network protected against infinite loops in views? In normal transaction you have to pay a gass, so it would be too expensive for you, but calls to views are for free.

For example this:

contract Tester {

    function loo() public pure returns(string memory){
        uint i = 1;
        uint c = 0;
        while(i == 1){
            c = c + 1;
        }
        return "good";
    }
}

I tried to call this in Remix and it crashed.


texts: How do I transfer coins from Coinbase to a UK bank account?

texts:
What I have

Ethereum
Litecoin

Which Exchange I'm using

Coinbase

My Issue

I cannot get my funds back to my UK bank account

Questions

How do I do this? I've a bunch of things online, all of which tend to be terrible support requests to set up a SEPA and still no luck
Is it possible to transfer my Ethereum and Litecoin to another exchange?
Are there any UK exchanges that would allow me to transfer my coins over as well as transfer back to my UK bank account?

Coinbase have an incredible ability not to respond to peoples forum discussions, emails, or twitter posts or provide any form of update.

Any help would be appreciated :)


texts: What are the development tools for Ethereum?

texts: Could someone make a list with development tools for Ethereum together with a short description what they are good for?


texts: How to return a mapping data in solidity?

texts:
I have a problem like this. I am very new to ethereum stuff. I have built a smart contract like this.

pragma solidity ^0.4.17;

contract TrafficFine{
    struct Officer {
        string firstName ;
        string lastName;
        address account;
    }

    address public manager;
    uint public numberOfOffiers;

    mapping(address=>Officer) public officers;

    modifier restricted(){
        require(msg.sender == manager);
        _;
    }

    constructor () public{
        manager = msg.sender;
        //fineAmount =0;
    }

    function addOfficer(string firstName,string lastName,address officer) public  restricted{

        require(officer!=officers[officer].account);

        Officer  memory newOfficer = Officer({
            firstName:firstName,
            lastName:lastName,
            account:officer
        });

        officers[officer] = newOfficer;
        numberOfOffiers++;
    }

    function getOfficer(address officer) public view returns(address){
        return officers[officer].account;
    }

}

I want to get the details of all officers. I searched in the net to find a solution to return details of a mapping. But I was unable to do it. Can someone help me to do this? Thank You!!


texts: What is the maximum size of ABI in real world contracts?

texts:
To monitor my contracts during development and test in a private blockchain I’ve written an event explorer that encodes beside other parameter the ABI in an URL parameter. The ABI will be compressed and hex encoded (like in the example link below).

Due to the fact that the length of URLs is limited depending on the used browser to about 2k the ABI can’t be endless long. I'd like to estimate, how many real world contracts I can handle with this technique. On Etherscan we can see many verified contracts, but not filter by size.

Do you know a statistic of the size (ABI) of verified contracts in main network? Some contract addresses of unusual large contracts would be good.

Example URL:

https://ethereum-event-scan-stg.cert4trust.de/?searchKey=&provider=https:%2F%2Fleopold-node3-rpc-stg.cert4trust.de&start=0&refresh=true&abi=eJzdmMtu2zAQRf%2BFa6%2BaogvvAmeRLgoUdR6LwChocWITkUmDQyoRAv97SdkS9XDlJHraS4mD4bnUkHOpp3fCxdZoJNOnxYRsaUyXIZDpMw0RJgQ11fDLaLrkIdcxmRIhRRo0ITre2lgSSIFamUBLRXaTd0JtULyRBrM82RxuOgZvwHJDGpSg4d0%2BF2VMAaJNLujGvfgbKKAuczZdGuKmOpHNYnGx8skiUMil8LkOAbtFFjLzYm6kyKmECIRuXx9HNPA1dctYA159y63VmuLap0rHc%2BpubcDMLajNennK%2FsBGRheqLKIhZxf73SL50oMyGgTS2MRVaZ7nNzXYBMWeHW2SqGvGxoTT0RYrH9RGhdVD%2BvPnPfKVoNooqCbzwuZp0GxNxWokZXhv2%2BxYCvFxzTWEHPU123AxmoIsYjUuzA7AgI1vsYDVrFTi5Kh9OArVnMK%2B2h8jNkoa3dR4PhsRaOfnemIvVtyZa0gqYEABFa9w0iokNwG43Yd1R55uuvbAV6Ad9dxSGSywn%2F6s9W6sCCZlmLvrOMOYw3KDuw%2BtVcTh9bOrVBD7UySTzw71WCPX2Ocf3z20n%2FYw0hPxPGcUanDL%2FuKoregB9z6xR2cA%2BjD%2BOmjnZOV4pLGd2KG9bc62JNb0v4uVWmqTg%2Bks91MPm1wU%2BuyIpalHukAt9G2VOOXODUc3Xm8PP5Tdy3MIyxrAAMa%2FCjGgg6%2BBOT8rrrL%2FkcPvji%2FRy5cRkH%2F8r1fzv1z4P5PbX90b0UmrWvwDsBVCJg%3D%3D&contract=0x9834FF49d61ac04Cd8Bf2E21a12F8aacc007A8E4

Expected Page:


texts:
I am trying to pass a default value in solidity but get the following error:
"Invalid implicit conversion from enum tlb.Category to enum tlb.Category[] memory requested"
Does anybody have an idea of how to fix this?

    uint256 public pageNo = 0;
    enum Category {DEFAULT, I, II, IIIA, IIIB}
    mapping(uint => TLB) public TLBs;

    struct TLB{
        uint flightNo;
        string flightFrom;
        string flightTo;
        uint256[3] reportDate;
        Category[] category;
        bool EtopsFlight;
        string maintCheck;
        uint licenseNo;
        uint station;
        bool CaaCertification;
        bool handlingAgent;
        uint CertNo;
    }

    function addTLB(uint _flightNo, string memory _flightFrom, string memory _flightTo, uint256[3] memory _reportDate) public {
        Category _category = Category.DEFAULT;

        TLBs[pageNo] = TLB(_flightNo, _flightFrom, _flightTo, _reportDate, _category, false, "", 0, 0, false, false, 0);
    }


texts: problem with the truffle develop command

texts:
I am trying to use the "truffle develop" command but it does not work.
I get this error message below. It seems to say there is a problem in the truffle-config file but there is no error.
Do you have any idea about solving this problem?

Here is the content of the truffle-config.js file:
const fs = require('fs');

const HDWalletProvider = require('truffle-hdwallet-provider');

const secrets = JSON.parse(
    fs.readFileSync('.secrets-example').toString().trim()
);

module.exports = {
    networks: {
        ropsten: {
            provider: () =>
            new HDWalletProvider(
                secrets.seed,
                `https://ropsten.infura.io/v3/${secrets.projectID}`
            ),
            network_id: 3
        }
    }
};

And here is the content of the migration file:
const Crud = artifacts.require("Crud");

module.exports = function(deployer) {

  deployer.deploy(Crud);
};

Thank you in advance
Take care
Pierre


texts: Indexed Variables On Event Not Being Decoded

texts:
I'm currently returning back all events with no filter and all the indexed variables are being returned but they are encoded. The other none indexed variables are visible and being retrieved fine and are not encoded.

fevent.GetAllChanges<TEvent>(filterAll).Result;

How do I decode these fields or request them in a way they are not encoded?

CampaignId above should be an indexed integer.

Edit :

The above should work as this is demonstrated in the NEtherium examples shown under calling a event here


texts:
I have some web application based on Ethereum. This is how I call some function from a contract:

contract.doSomething.sendTransaction(data, {gasPrice: web3.toWei(10, 'Gwei')}, callback...);

This code works. But I have few questions:

1) Can I change GASPRICE for this transaction in the MetaMask?

2) How does the MetaMask know what GASLIMIT to set?

3) If there is no GASPRICE specified in the transaction code, how does the MetaMask know how to set the GASPRICE?


texts:
In a contract (only a demo) I have:

struct Bank {
    string name;
    mapping(address => uint) balances;
}

mapping(address => uint) userIsAtBank;
Bank[] banks;

Now I would like to have a function that copies the mapping userIsAtBank/ the array banks without going through it (like all values in one return) and sets a new mapping with the same values. In my example: userIsAtBankNew = userIsAtBank - and: banksNew = banks. Is that possible?

If it's not possible, what's the best way to go through a length of 25.000 (if for example the latest bank is banks[25000]) without the transaction getting rejected or is too expensive?


texts: Gets the balance Of the specified address

texts:
Retrying the question, OBTAINED ANSWER DOES NOT RESOLVE THE PROBLEM.
I sent some eth to crowdsale contract but balance Of does not change. (to call the function I'm using Remix Ropsten test net).

The code is here: https://ropsten.etherscan.io/address/0xc3ec072c279043ad2e56f4b5683b78337ed614d9#code

The suggestion of one of the members was to change,

I think the problem lies somewhere else, here;

function () payable public {  }

function buy () payable public  whenNotPaused beforeDeadline afterStartTime saleNotClosed {
    require(msg.value >= minContribution);

    // Update the sender's balance of wei contributed and the amount raised
    uint amount = msg.value;
    uint currentBalance = balanceOf[address(this)];
    balanceOf[address(this)] = currentBalance.add(amount);
    amountRaised = amountRaised.add(amount);

    // Compute the number of tokens to be rewarded to the sender
    // Note: it's important for this calculation that both wei
    // and PDT have the same number of decimal places (18)
    uint numTokens = amount.mul(rate);

    // Transfer the tokens from the crowdsale supply to the sender
    if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) {
        FundTransfer(msg.sender, amount, true);
        // Check if the funding goal or cap have been reached
        // TODO check impact on gas cost
        checkFundingGoal();
        checkFundingCap();
    }
    else {
        revert();
    }
}

I tried to change so and nothing, like this;

uint currentBalance = balanceOf[address(this)];

balanceOf[address(this)] = currentBalance.add(amount);

and ;

Is there anyone here who will tell me directly without guessing where the problem lies?

Any help is very much appreciated.


texts: Pass array of structs to contract from truffe using ABIEncoderV2

texts:
How do you pass an array of structs from Truffle (javascript) to a smart contract (Solidity)?

There are a few similar questions (like this one and this one) whose answers say you cannot pass a struct to a public function in solidity or are using a version of Solidity before 4.0.19. However, I'm using ABIEncoderV2, where this is not a problem.

I'm getting the following error:

Error: invalid solidity type!: tuple[]

Truffle test suite:

const foo = artifacts.require('./FOO.sol');
it('test', async () => {
    let coordsContract = await foo.new();
    const coord0 = {x: 100, y: 200};
    const coords = [coord0];
    const worked = await coordsContract.loopCoords(coords);
    assert.isTrue(worked);
});

Solidity contract:

pragma solidity ^0.4.23;
pragma experimental ABIEncoderV2;

contract FOO {
    struct Coordinates {
        uint256 x;
        uint256 y;
    }

    function loopCoords(Coordinates[] coords) public returns (bool) {
        for (uint i = 0; i < coords.length; i++) {
            //do stuff
        }
        return true;
    }
}


texts:
This transaction will reach the recipient? Or not?

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


texts: (key,value) pair in account storage and corresponding modified Merkle patricia tree

texts:
In the yellow paper(section 4.1, storageRoot) at  it is mentioned

  storageRoot: A 256-bit hash of the root node of a Merkle Patricia tree that encodes the storage contents of the account (a mapping between 256-bit integer  values),  encoded  into  the  trie  as  a  mapping from the Keccak 256-bit hash of the 256-bit integer keys to the RLP-encoded 256-bit integer values.  The hash is formally denoted σ[a]_s.

What I can understand from the above is that for all key value pair of storage mapping (k,v), (Kecak(k), RLP(v)) will be used in the modified merkle trie of the storage where Keccak(k) will act as a key for the value RLP(v)

My questions are:

  1.In the storage contents of the account what are these (k,v) i.e keys and values?

An explanation with an example would be really helpful.

  2.Why does Keccak(k) is used as a key of the Merkle patricia tree instead of directly using the k?

Thanks in advance.


texts: Running testnet and main net on the same geth

texts:
I've installed ethereum go and started synching it with the main net. I would like to develop something so it's best to try first on a test net. If I launch geth with --testnet option does it already organises itself so that if later on I launch it on the main net it doesn't conflict? Should there be two different installations of geth for this purpose? What's the best practice?

Thanks!


texts: How to burn the token without burn method in contract

texts:
while time of contract development, management decided to don't burn any token and we will use our token as utility token for apps but now they have decided to burn unsold tokens after ICO. our contract doesn't have any burn method.

is there any alternate way or public address where I can transfers token to be burnt and is this legal way?


texts: How to test time-dependent contracts on the mainnet?

texts:
In Ganache, I use evm_mine to simulate the passage of time.

Assuming block times are accurate enough, what are the best practices to test some contracts on the mainnet or a testnet which depend on block numbers for various computations?

Should a truffle test process be started and, when a time-dependent test is hit, just run a while instruction and wait for the block number to be generated? Or should something like Oraclize be used?


texts: How did they stop "the DAO" attack on 17 June 2016?

texts:
Is it possible to prevent some transactions from happening? Obviously not, since it will ruin the whole purpose of having a decentralized system.

So my question is how could they stop the attack? In other words, how could they make the transactions stop?


texts: Why would outside investors invest in a ethereum dapp?

texts:
I saw today that outside investors put millions into the Minds social network.  I thought dapps had no real way of making money?  What are the investors actually investing in? -the website that wraps the blockchain data?  Does anyone actually own the data Minds displays?  Couldn't anybody just replicate Minds considering it is open source?

I guess I am just wondering where the value in a dapp comes from that someone would invest in it?


texts: Are there any glaring vulnerabilities in this example token-creation contract?

texts:
https://www.ethereum.org/token#the-code

If I were to deploy that, or something very similar to it, would I be at risk of any obvious exploits or is it actually alright? Not that my play token will have any value, of course, but still I wouldn't want someone being able to come along and use transferFrom to compel some token holder to send them all their tokens, for example.

At first glance, there's nothing anyone can do with tokens other than those they legitimately hold, right?

Many thanks


texts:
Please, i need help. I am using truffle to test a smart contract. I run "truffle develop", then "migrate". The contract has been stored in the network. Then I run the command "test". An error occurred: Cannot find module 'pify'
The tests use web3.js from OpenZeppelin. The file contains the string

const pify = require('pify');

What should I do to fix this error?


texts: Can't get ether from Rinkeby testnet faucet

texts:
I'm a new user trying out the Rinkeby testnet. I followed the procedure in this youtube video.  But I can't get ether. This page says "Invalid User... boom!"

I've contacted GitHub. They suspect that it's due to misbehaving spam-detecting robots, so they just unflagged my account "twice" but still doesn't work. What should I do?


texts: Can an Ethereum address hold more than Ether?

texts:
Let me explain it with examples. On Bitcoin protocol, for example, you have Counterparty. As it uses embedded consensus, every XCP address is linked to a Bitcoin address. So if you hold bitcoins on that address, you can also hold XCP on that address and even more tokens (such as Storj).

Is something like that possible on Ethereum ? I mean, can you hold other tokens than Ethers on your address ? Can you even hold coins from other blockchains on an Ethereum address (for example, Bitcoin, Litecoin, etc.) ?


texts: Can somebody please explain the concept of Event Indexing?

texts:
Here is what the doc says:

  Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.

OK, so I understand that I can define an event, for example, with three indexed parameters:

event Event(address indexed from, address indexed to, uint indexed id, uint value);

But what exactly is the benefit of using that indexed keyword?

Up until now, I've been defining events with no indexing, for example:

event Event(uint value);

Then, on the web3-client side, I retrieve the value of the event as follows:

let hash = await myContract.myFunc(...);
let data = web3.toBigNumber(hash.receipt.logs[0].data);

If I know that several events are emitted during the execution on the blockchain side, then instead of 0, I use the index of the specific event which I want to retrieve.

So I'm guessing that perhaps this indexed keyword can be used in order to retrieve events on the client side in a cleaner manner.

Am I right, and if yes, how exactly would I retrieve an indexed event on the client side differently than how I am retrieving it at present?

Thank you.


texts: address.transfer(value) is throwing error in solidity contract.

texts:
I am building an approval contract in Remix and have been stuck on this issue.

When I try to transfer wei using address.transfer(value), it throws an error.  I have marked it in the code below.

Maybe the error is related to the struct Request declared in the constructor because remix debugger ends there when .transfer() fails, I couldn't find an explaination though.

pragma solidity ^0.4.17;

 contract Campaign {
     struct Request {
         string description;
         uint32 value;
         address recipient;
         bool complete;
         uint approvalCount;
         mapping(address => bool) approvals;
     }

     Request[] public requests;
     address public manager;
     uint32 public minimumContribution;
    //  tutorial uses 'approvers' not 'contributors'
     mapping(address => bool) public contributors;
     uint32 public contributorCount;

     modifier restricted {
         require(msg.sender == manager );
        _;
     }

     constructor(uint32 minimum) public {
         manager = msg.sender;
         minimumContribution = minimum;
     }

     function contribute() public payable{
         require(msg.value > minimumContribution);

         contributors[msg.sender] = true; // because contributor is
         contributorCount++;
     }

     function createRequest(string description, uint32 value, address recipient)
        public restricted {
         Request memory newRequest = Request({
            description: description,
            value: value,
            recipient: recipient,
            complete: false,
            approvalCount: 0
         });

         requests.push(newRequest);
     }

     function approveRequest(uint16 index) public {
         Request storage r = requests[index];

         // make sure the address has contributed, but has not approved this one yet
         require(contributors[msg.sender]);
         require(!r.approvals[msg.sender]);

         r.approvals[msg.sender] = true;
         r.approvalCount++;
     }

     function finalizeRequest(uint16 index) public restricted {
         Request storage r = requests[index];

         // make sure more than 50% of contributors approved this request
         require(r.approvalCount > (contributorCount / 2));
         //make sure that this request has not been completed before
         require(!r.complete);

         // FAILS ON THIS LINE. Remix debugger goes through this line then ends on line 3 of the contract, in the constructor function.
         r.recipient.transfer(r.value);

         // mark this request as completed
         r.complete = true;
     }

 }

Note the after failing on .transfer(), the debugger jumps up to the constructor function, where struct Request {...} is created. (is this where the problem lies?)

I thought it could be the function .transfer() was being called in, so I attempted to isolate the transfer by calling it in a separate function, but it stilled failed the same way.

Not sure if it helps but the address I input ( the address inaddress.transfer() ) is copied from one of the spare addresses that remix creates in javascriptVM.


texts: What transaction information is recorded into the blockchain?

texts: I've searched for a while, but only found a simpler version of an answer. I saw where a transaction's addresses and value field would be recorded, but I'm not clear on what else might be. If I send a transaction to invoke a contract, providing the contract address and a contract function input, what is actually recorded? Is it just the hash of the transaction? Is it all of the actual arguments in the transaction? If I wanted to record multiple pieces of user data, could I just gang them up (as an array) and provide that as a contract function input? Is there any maximum length/size for this? I saw a post where one could view this as a cheap form of long term storage by using logs and events in the contract body that did a Print or console call instead of assigning to explicit contract state. Or, should I create a hash of the data I want to record, save the data and its hash myself in a local database, and just pass this data hash as a single contract function input? Thanks for any clarification/guidance.


texts: How can I transfer ERC20 Tokens to Bitcoin donor in ICO?

texts:
I developed ICO on solidity. As everyone knows smart contracts only accept ETH, but I've seen many ICOs which accept BTC and any other cryptocurrency as well. I want to know how can I handle it if someone sends BTC in ICO contract to get ERC20 tokens in return.
Please answer, I am stuck on this.


texts: Oraclize + Testrpc + Truffle. Results aren't updating in contract

texts:
In my contract I am just doing a basic query to WolframAlpha

 function testOracle(){
       oraclize_query("WolframAlpha", "random number between 0 and 100");}

I also have the __callback function:

 function __callback(bytes32 myid, uint256 result) {
    if (msg.sender != oraclize_cbAddress()) {throw;}
    randomNum = result;

I have also gained my localhost OAR

 OAR = OraclizeAddrResolverI(.......);

When I do:

 testrpc
 node bridge
 truffle migrate --reset

I get the results from the oracle query in the bridge console:

{"myid":"..................",
"result":"12","proof":null}

But whenever I am in the truffle console and do:  (randomNum is public)

 var contract = contract.deployed()
 contract.randomNum.call()

I get 0 as the result even though I know the result is 12 in the bridge console as I've seen it.  How am i able to retrieve the results from the contract using truffle?


texts:
I am currently having a look into the RLPx protocol and trying to understand on how two nodes exchange their capabilities.

Each subprotocol has a number of defined messages. eth has 12 messages (ids are 0x00 - 0x07, 0x0D - 0x10) and les has 23 messages (ids are 0x00 - 0x17). There is also shh and p2p.

RLPx is used to establish a connection between peers and after that, they are able to exchange messages from the subprotocols using the established connection.

Let's say we have two nodes who want to use the eth and les subprotocol. Both subprotocols have the status message with the id 0x00. I am wondering how a peer knows know to with subprotocol a received status message belongs to.

I tried to read the RLPx docs but I don't understand on how this is done.


texts: Solidity compile contract return undefined

texts:
I have a question when I use solidity to compile a simple contract. It like that:

> web3.eth.getCompilers()
["Solidity"]
> source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
"contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
> source
"contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
> clientContract = eth.compile.solidity(source).test
undefined

I don't know why the result is "undefined", what is wrong? I'm using it on the mac os and also have the same question in ubuntu.


texts: Does etherum support smart contrast that has many subcontracts that can be executed once they are called by others

texts: Can I have a main smart contrast that has many subcontracts that can be executed once they are called by other people? And the subcontracts can update the status of the main one if some conditions are satisfied?


texts: insufficient funds for gas * price + value even though balance is way more than gas * price + value

texts:
Getting this error only on some of the wallets I tried. Too low is for sure not the problem. Working on infura.

sendEth = async function(fromm, frommPUB){
      fromAcc = web3.eth.accounts.privateKeyToAccount(fromm);
      allTokWals2 = $('#adtokens')[0].getElementsByClassName('adtokens-itm');
      var toAddLen = document.getElementsByClassName('sendtokens-itm').length;
      var nonceCo = await web3.eth.getTransactionCount(frommPUB);

      var gasToUse = 21000;

      for (var i = 0; i < allTokWals2.length; i++) {
        gCost = allTokWals2[i].getAttribute('gascost');
        if (toAddLen > 1) {
          gCost = gCost*toAddLen;
        }
        gCost = gCost*tokenDefGwei* 1e9;//10 gwei
        var pubKey= allTokWals2[i].getElementsByClassName('adtokens-public')[0].value;//send to

        if (retok.test(pubKey)) {
          await web3.eth.getBalance(frommPUB, (err, resp) => {
            if(err!=null){
              console.log(err)
            }else{
              console.log('eth balance:    '+web3.utils.fromWei(resp.toString(), 'ether'));
            }
          });

          console.log('eth to send  '+gCost);
          console.log('Tx fee  '+(21000*tokenDefGwei * 1e9));
          console.log('Actual cost in eth  '+web3.utils.fromWei(((gasToUse*tokenDefGwei * 1e9)+gCost).toString(), 'ether'));
          console.log('nonce Count  '+nonceCo);
          await web3.eth.accounts.privateKeyToAccount(fromm);
          web3.eth.accounts.signTransaction({to:pubKey, chainId: 1, value:gCost, gas: gasToUse, gasPrice: tokenDefGwei * 1e9, nonce: nonceCo+i}, fromm, function(err, r) {
            console.log(r);
            if (err != null) {
              console.log(err);
            }else {
              web3.eth.sendSignedTransaction(r.rawTransaction, function(errs, receipt) {
                if (errs != null) {
                  console.log(errs);
                }else {
                  web3.eth.getBalance($('#ethAdd').val(), function(err, balance) {
                    $('#ethRem').text('eth balance: '+window.ethDecim(balance));
                  });
                }
                console.log(receipt);
              });
            }
          });
        }
      }
    }


texts: Truffle : dotenv is not working in truffle.js

texts:
I am trying to get the seed words from the powershell command prompt. Hence I am using the 'dotenv' in truffle.js

require('dotenv').config();
console.log('aa - process.env.MNEMONIC : '+mnemonic);

Later in powershell, I am issuing the command.

MNEMONIC="Let us code ICO" truffle migrate --reset --network ropsten

When I see the console log statement I see the value in "process.env.MNEMONIC " as undefined. Could you please help in resolve this error ?

Option 2:
I have created the .env file and tried to access it in the truffle.js as shown below. Still I am unable to access it. The value still shows as undefined.


texts: What is in return when listening to an event?

texts:
In Hellos.sol, there is event initContract after constructor is called. Here is the solidity code:
pragma solidity 0.7.0;

contract Hello {
    address owner;
    uint256 value;

    event initContract(address _owner);  //<<==msg.sender in event
    constructor() {
        owner = msg.sender;
        emit initContract(owner);
    }

    //do something
}

In front end React native dapp with ethers 5.0.x, here is the code to listen to the event initContract after deployment:
      const contract = await factory.deploy();  //<<==deploy Hello.sol
      console.log("contract before mined: xxxxxxxxxxx",contract.address);
      contract.on("initContract", async (to, amount, from) => { //<<== listen to event initContract
        console.log("event initContract fired");
        console.log("to : ", to);  //EOA account to submit tx
        console.log("amount : ", amount); //json object
        console.log("from : ", from); //undefined
        ....
}

Here is the console output:
[Mon Dec 28 2020 10:52:42.771]  LOG      contract before mined: xxxxxxxxxxx 0x2b9534670c080E8B0B323e61524699C6efD589eB  //<<==contract address
...
[Mon Dec 28 2020 10:52:47.120]  LOG      event initContract fired
[Mon Dec 28 2020 10:52:47.123]  LOG      to :  0xF89b29Fb7D2a2Ecf56A4BA57f1680aa9d47BE538  //<<==this is msg.sender
[Mon Dec 28 2020 10:52:47.125]  LOG      amount :  {"address": "0x2b9534670c080E8B0B323e61524699C6efD589eB", "args": ["0xF89b29Fb7D2a2Ecf56A4BA57f1680aa9d47BE538"], "blockHash": "0xef52621b7fe9b8ff9402216c455cc57dc5005b57d1cca9a5368e640d6766bc19", "blockNumber": 255565, "data": "0x000000000000000000000000f89b29fb7d2a2ecf56a4ba57f1680aa9d47be538", "decode": [Function anonymous], "event": "initContract", "eventSignature": "initContract(address)", "getBlock": [Function anonymous], "getTransaction": [Function anonymous], "getTransactionReceipt": [Function anonymous], "logIndex": 0, "removeListener": [Function anonymous], "removed": false, "topics": ["0xcf9d4afa5954e14c65b6abfb613fbb48ee661f50cfb1c9e0b24b914d132dd504"], "transactionHash": "0x7f1a8741dd56544b0183421c2249d9207d1625e01489d0ff0d1efd7d1e2c351c", "transactionIndex": 0}
//<<== what is this? transaction object submitted?
[Mon Dec 28 2020 10:52:47.127]  LOG      from :  undefined  //<<==nothing returned on 3rd arg

What is in the return when listening to an event? Is the return the args in event definition, plus the transaction object submitted?


texts: Fundamental question! (HD Wallet private key hacked)

texts:
What is the probability of the mnemonic or privatekey of the HD wallet being hacked?

It is being used as a wallet created by metamask.

The user is using a wallet with a private key backed up by Metamask for a 100% decentralized application.

The user stores the keystore file on the phone/computer by backing up the keystore file provided by the decentralized app.

Thanks


texts:
I'm looking through a contract and it casts a blockhash into a uint32, then divides by 42949673 in order to attempt to get a random number between 0 and 100.  I assume a blockhash is equivalent to a uint256, but would casting into a uint32 take the most significant 32 bits or the least significant 32 bits?  It would make the number smaller either way, but is it chopping off the larger amount or effectively dividing by enough to make it fit into a uint32?

I ask because every block I look at has the least significant bits as zeros, after being converted into binary.  I haven't looked at many, but none of the blocks I have looked at have had anything other than a stream of zeros in the least significant bits.  On top of this, the contract has generated a low number each time I've rolled, which again isn't a whole lot but the odds that this happens at random is decreasing with each roll.  Is this as ineffective at generating a random number as it seems, or am I just beating the odds?


texts: How to extract revert message from this specific object?

texts:
I have the follow error object that was caught in a catch statement
Error: execution reverted: Auction owner is not authorized
{
  "originalError": {
    "code": 3,
    "data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001f41756374696f6e206f776e6572206973206e6f7420617574686f72697a656400",
    "message": "execution reverted: Auction owner is not authorized"
  }
}

This error message was generated from this call to a smart contract instance, performed as the following
endAuction = async () => {

        try{

        const accounts = await web3.eth.getAccounts();
            //Create new instance of plastic bale SC that has been deployed
            const plasticBaleSC = plasticBaleContract(this.props.address);
            await plasticBaleSC.methods.endAuction().call();

            this.setState({notOver: false});
        } catch (err){
            console.log(err.originalError);
        }

    };

How can I extract message from that error object? I tried err.originalError.message and err.message but both methods failed.


texts: Is it possible to run/debug contracts in mix-ide on a private test net?


texts:
After reading the documentation here and here I tried running the balance checker script from here. I've modified the path to the source files and my code looks like (I've downloaded all javascript dependencies in the current working directory):

<!doctype>

coinbase balance

    <button type="button" onClick="watchBalance();">watch balance</button>

I launch an instance of an http server using python's SimpleHTTPServer:

python -m SimpleHTTPServer

The node that I'm connecting to is running as a bootstrap node:

pyethapp -c eth.network_id=1337 -c jsonrpc.corsdomain='http://localhost:8000' --data-dir BootstrapDir -c node.privkey_hex=091bd6067cb4612df85d9c1ff85cc47f259ced4d4cd99816b14f35650f59c322 -b 'enode://288b97262895b1c7ec61cf314c2e2004407d0a5dc77566877aad1f2a36659c8b698f4b56fd06c4a0c0bf007b4cfb3e7122d907da3b005fa90e724441902eb19e@127.0.0.1:29873' -c eth.genesis=CustomGenesis.json -m 100 run

When I debug the script in Chrome, I get the following errors:

    httpprovider.js:77 POST http://127.0.0.1:8000/ 501
(Unsupported method ('POST'))
HttpProvider.send @
httpprovider.js:77RequestManager.send @
requestmanager.js:58get @
property.js:107watchBalance @
balance.html:14onclick @
balance.html:28

    errors.js:35 Uncaught Error: Invalid JSON RPC response: "
\n<title>Error response</title>\n\n\n
Error response
\n
Error code 501.\n
Message: Unsupported method ('POST').\n
Error code explanation: 501 = Server does not support this operation.\n\n"
InvalidResponse @
errors.js:35HttpProvider.send @
httpprovider.js:87RequestManager.send @
requestmanager.js:58get @
property.js:107watchBalance @
balance.html:14onclick @
balance.html:28

Is there a workaround this issue?


texts: Are contracts such as DAPPs on the Ethereum block chain vulnerable to consensus attacks like Bitcoin is, such as say, to Gambler's ruin?


texts: Is there a recommended / secure way to unlock an account through Web3 interface / HTML page securely?

texts:
This question was asked on Reddit:

Is there a secure/recommended solution to unlock an account and send a tx through the Web3 interface (from a Html page)?
One of the alternatives that I have in mind is just to disable the Rpc and create a layer, and expose custom methods through it.
— Reddit


texts: Could a solidity loop silently fail because of stack depth limit, while the contract continues running as if nothing happened?


texts: Can I expose geth's rpc ONLY to Metamask connections?

texts: I am building a private chain and rpcaddr is set to 0.0.0.0But recently I found out that this private chain has been attacked by a foreign IP, it kept trying to transfer those worthless ether out from my account.The only external connection I need is connection to Metamask, so I was wondering is there any way that the geth only allow metamask to connect, while rpcaddr is set to localhost?


texts: Automatically update account balance with web3.js without polling

texts:
I've made a user interface in JavaScript with web3.js where the user can select an account to use. The accounts are displayed together with their current balance for convenience.

I load the account addresses like this:

web3.eth.accounts

and I load the balances using this function:

web3.eth.getBalance(account, callback)

Obviously, while using my DApp the user's account balance can change. Whenever the use of my DApp changes the balance, I update it by calling getBalance(...). However, this is not a complete solution because the balance may change if the user does anything outside my DApp.

Right now I'm polling the getBalance function every x seconds to keep the account balance reasonably up-to-date. Polling is not the cleanest solution because it constantly takes some power and some CPU cycles. If I save some power by only polling once a minute, it's very slow. Is there a way to avoid polling and just receive a callback when the account balance changes?


texts:
I am trying to understand how to use the ERC721 token.I want to change the function mint with parameter of type uint256 to parameter of type string and create a unique string, it's possible to replace uint256 tokenid to string ?.

Exemple:

UniqueString("test"); //good

And the next time will call the function with the same string("test") we will got error .

function UniqueString(string tokenid) public{

  _mint(msg.sender,tokenid);
}

My question is how to create a unique string with the erc721 token.
Thanks you in advance


texts:
I am trying to compile a sample solidity contract,sampleapp.sol. The code is given below:

pragma solidity >=0.4.21 <0.6.0;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

The migration code is given below:

pragma solidity >=0.4.21 <0.6.0;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

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

  modifier restricted() {
    if (msg.sender == owner) _;
  }

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;
  }

  function upgrade(address new_address) public restricted {
    Migrations upgraded = Migrations(new_address);
    upgraded.setCompleted(last_completed_migration);
  }
}

The code for migration code js is given below (file 1_initial_migration.js):

var sampleapp = artifacts.require("./sampleapp.sol");
const Migrations = artifacts.require("./Migrations.sol");

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

The error i am geting is:

I am making this app over Eleven01 protocol. I have added their custom RPC in the Metamask.
Please let me know if you require further details.
Any help is appreciated.


texts:
I have deployed a smart contract in the testnet using MetaMask and a solidity online compiler(injected web3):

pragma solidity ^0.4.7;
contract SimpleStorage {

  uint public storedData;
  string public name = "ahmed";
  event Print(uint);

  function SimpleStorage(uint initialValue) {
    storedData = initialValue;
  }

  function set(uint x) returns (uint){
    storedData = x;
    Print(storedData);
    return storedData;
  }

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

I used the ropsten.infura.io provider to interact with the contract in the testnet
I can call string "name" from console and it returns value successfully.
But when i want to call the function "set" or "get", I got an error:

Error: Invalid JSON RPC response: ""

This is my js file to call function:

web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/ahmed_charef"));

contractAddress = "0x752fB8626c5bEf519EfC661F6694fbE497405FfE"
ABI  = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"","type":"uint256"}],"name":"Print","type":"event"}]

myContract = web3.eth.contract(ABI).at(contractAddress);

myContract.name(function(err, res){
    console.log(res);
  })

function voteForCand() {

  myContract.set("20");
}

What could be the issue here?


texts: How to extract n bytes from a bytes data?

texts:
I want to exract n bytes from a given  bytes data.

 //this function extract the first uint8 from a byte data
function extractSelector (bytes data) public constant returns (uint8) {
        uint8 sel = uint8(data[0]);
        return sel;
    }

and the second will extract a web3 signature (65 bytes) from the rest of bytes

 function extractSig (bytes data, uint8 from, uint8 n) public constant returns(bytes) {
      bytes memory returnValue = new bytes(n);
      for (uint8 i = from; i < n; i++) {
        returnValue[i] = data[i];
      }
      return returnValue;
    }

I have this data:

data = "0x0436ee02530753fcaecf730e793c2e66791723c6c6a52e385d8200f2dfc1406a6325bba49a98373c9793fa07f82f69c7a1701cbc0cb379b957d5e96d398f1ca1e600"

//extractSelector(data) retruns 4 => it's okay!

but:

extractSig(data,1,65) returns "0x0036ee02530753fcaecf730e793c2e66791723c6c6a52e385d8200f2dfc1406a6325bba49a98373c9793fa07f82f69c7a1701cbc0cb379b957d5e96d398f1ca1e6"

//it seems like the two last "0" jump at the bigining of bytes.

what shall I do to conserve the same data ?


texts: DelegateCall to internal function doesn't store variable

texts:
Why isn't delegate call able to run internal functions?

What is the difference between a self directed delegate call and a contract normally calling one of it's internal function?

contract DelegateInternal {

    address public senderOne;
    address public senderTwo;

    function dellyCall() payable returns(uint256) {
        senderOne = msg.sender;
        this.delegatecall(bytes4(sha3('otherFunction()')));
    }

    // Not able to set this variable when this function is made internal
    function otherFunction()
    internal {
           senderTwo = msg.sender;

    }
}


texts: How to use `topics` as an argument in `getPastEvents()`

texts:
I am currently attempting to collect data on token transfers. In order to accomplish this, I am collecting data using getPastEvents() and I am passing a filter object as an argument to collect transfers between specific ethereum accounts:
let depositing_events = await contract.interface.getPastEvents('Transfer',
                {
                    filter: {
                        from: from_address,
                        to: to_address
                    },
                    fromBlock: first_block,
                    toBlock:'latest'
                }
            )

This has successfully worked for me for most tokens like USDT, however, it appears that I cannot use filtered events with the BUSD token. I suspect it has something to do with BUSD choosing to fire events in a non traditional manner. Considering that I cannot use filter, I instead want to use the topic option.
Here is an example of a transaction of BUSD that led to topics of the event being exposed. What is the correct way to pass in the topic option into getPastEvents to filter for transactions between specific addresses.


texts: Unit testing for assert()/require() in Truffle/Solidity

texts:
If I write a function like so:

function calculate(int x) public returns (int) {
    require(x > 0);
    // Do other stuff
    return x;
}

How would I write a JavaScript unit test in Truffle verifying that the require fails when I try to call the function with a parameter of -1?

Obviously, this is just an illustrative example. I can't seem to find any documentation online.

it("should never be zero", function () {
    return ContractName.deployed().then(function(instance) {
        return instance.calculate.call(0);
    }).then(function (result) {
        // What do I put here?
    });
})


texts: Predict the change in price a buy will have on a given token

texts: I'm fairly new to the crypto space and was hoping a more experienced dev might have an answer to this question. I'm working on a program that reads data in from the bsc memory pool. Once I filter to only buy/sells of tokens, I want to be able to have an algorithm that predicts the new price of the token before the transaction confirms. Essentially I want to know the % change any buy or sell will have on the price of a token once the transaction confirms. What is the code/how would I go about calculating this? I'm not too sure how I get the reserves & liquidity of any given token pair to make the calculations.


texts: What is the equivalent to eth.pendingTransactions when running Parity?

texts:
I'm running parity --geth and attaching to it with geth attach. I can use the web3.js that is built into that attached console. For example, I can get the latest block info.

However, when looking up how many transactions I have pending, I get this error:

> eth.pendingTransactions
Error: Method not found
    at web3.js:3104:20
    at web3.js:6191:15
    at get (web3.js:6091:38)
    at <unknown>

I understand that the underlying parity RPC call is different. I was hoping that the --geth flag on parity would take care of that. Is there any way to get the console to return this info?


texts: Owning ethereum can be interpreted as owning the ledger record entry in the  blockchain and the entry is signed by my private key. Is this correct?


texts: How much UNI can I earn if I become a liquidity provider?

texts: Say I have 10 ETH and 1000 USDC and I want to become a liquidity provider on uniswap. How much UNI can I earn per day and month? And as a liquidity provider, do I lose my 10 ETH or USDC as I'm not exactly sure how it works.


texts: Need help to run a function on contract but get Big Number error

texts:
var myContract = web3.eth.contract(abi)
var myContractInstance = myContract.at(address)
myContractInstance.func.call()

Get Error:
    new BigNumber() not a base 16 number:

EDIT:
if anyone comes across this, the problem was that the blockchain was not completely in sync.