texts: Get ETH Wallet address list (holder list) given a smart contract address (erc20)

texts:
I would like to fetch the list of all ETH wallet addresses by an API(?), given a smart contract address (erc20 token address).
Similar feature that we see on etherscan.io under the erc20 Holder list. Any docs/resource would be appreciated. Thanks


texts: Not able to add 'replayPastTransactionsFlowable' transaction logs result into an collection List object using Web3j java?

texts:
I'm trying to create an api where i have to provide transaction logs in json objects but im unable to add result of replayPastTransactionsFlowable
 into an collection object

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

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

    return transactions;
}

}
Im using following two dep

    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>core</artifactId>
        <version>4.5.5</version>
    </dependency>

    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>contracts</artifactId>
        <version>4.5.5</version>
    </dependency>


texts: Truffle not working after install using npm

texts:
I just tried to install truffle using npm. I followed the documentation and did
npm -g install truffle
However, after that, when I try to do anything (such as just run truffle or truffle --version), I get the error
/home/jonathan/.npm-global/lib/node_modules/truffle/build/625.bundled.js:95862
  } catch {
          ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.__webpack_require__.f.require (/home/jonathan/.npm-global/lib/node_modules/truffle/build/cli.bundled.js:613:28)

my npm version is 6.14.8, nodejs version 8.10.0. running which truffle gives
/home/jonathan/.npm-global/bin/truffle

I am at a complete loss, does anyone know how to fix this? Im also quite the beginner when using npm, only use it for ethereum related things.


texts: Sending token with contract interaction in Remix

texts:
I'm aware of using the value field in Remix to include ETH with my function call transaction but is there a way to send another token with my transaction, for example, LINK?
Additionally I would like to require there's a certain amount of LINK sent, similar to require(msg.value == X) for ETH. I already have the token interface imported and initialized but am unsure where to go from there and don't know how to send the token in Remix to test it anyway.
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.6/interfaces/LinkTokenInterface.sol";
LinkTokenInterface internal LINK;
//in constructor (kovan LINK token)
LINK = LinkTokenInterface(0xa36085F69e2889c224210F603D836748e7dC0088);


texts:
New to Ethereum.  Started working with a simple sample contract.  It's working correctly except for the fact that I simply cannot seem to increase its balance.  Any thoughts?

contract Faucet {
    address owner;
    uint256 sendAmount;

    function Faucet() {
        owner = msg.sender;
        sendAmount = 1000000000000000000;
    }

    function getBalance() returns (uint) {
         return this.balance;
    }

    function getWei() returns (bool) {
        return msg.sender.send(sendAmount);
    }

    function sendWei(address toWhom) returns (bool) {
        return toWhom.send(sendAmount);
    }

    function getSendAmount() returns (uint256) {
        return sendAmount;
    }

    function killMe() returns (bool) {
        if (msg.sender == owner) {
            suicide(owner);
            return true;
        }
    }
}

Then, using Geth :

eth.getBalance(faucetAddress)
1000000000000000000

Next...

eth.sendTransaction({from:eth.coinbase, to:faucetAddress, amount:1000000000000000000})

Block is mined, then:

eth.getBalance(faucetAddress)
1000000000000000000

No increase.

Here's my transaction receipt.  Many thanks in advance.

{
 blockHash: "0x6dacad47ad5f6a4e8dbb38a70bbe77b1d2ef019df396642c0490afc7e5ad2c8c",
 blockNumber: 1526,
 contractAddress: null,
 cumulativeGasUsed: 90000,
 from: "0x245d5fef6bf170a0fc6b464f033bff2aea020dbd",
 gasUsed: 90000,
 logs: [],
 root: "9da791d719134c34bdad70c6cfcc424a1daa1a1573a6319f475a61b7d2728b80",
 to: "0xeff6f295823648420cd1e6707caf99340c2343d0",
 transactionHash: "0xbc6c596afe9e05eb496d85472ade592fbb179fd7b4e0a619cba84bd8930da35b",
 transactionIndex: 0
}


texts: Mist error: "unable to connect to socket:timeout"

texts: In mist wallet i am getting an error of unable to connect to socket and couldn't compile source code.Do help me where i am doing the mistake.


texts: How to test contract interaction with mainnet contract via Truffle

texts:
I'm writing a contract via Truffle and my understanding is that running truffle test will run my tests in a clean-room environment. E.g. a fresh deployment blockchain run on my local machine

How can I run tests on how my contract interacts with contracts that are on the ethereum mainnet? E.g. lets say that users interacting with my contract need to send specific tokens, e.g. WETH, that I haven't written.

I have a full parity node synced on my machine. Is there a way to test my contract functions and how they interact with the current state of external contracts on the ethereum mainnet?

Thanks!


texts: I bought ethereum from the presale. I have a presale wallet and I do not know the password.  Is there a way I can find out the address?


texts:
I'm trying to test a payable function from Truffle my function looks like so:

function recordOrder(bytes32 orderNumber) payable returns(bool success) {
    if(msg.value==0)
    {
        return false;
    }

    if(!orderStructs[orderNumber].exists) {
        orderStructs[orderNumber].sender = msg.sender;
        orderStructs[orderNumber].amountReceived = msg.value;
        orderStructs[orderNumber].exists = true;
    }
    else {
        orderStructs[orderNumber].amountReceived += msg.value;
    }

    LogOrder(msg.sender, orderNumber, msg.value);
    withdrawFee(msg.value, orderNumber);
    return true;
}

I'm trying to figure out how to send payments to a function but I'm confused on how.  If I call the function like so:

var facilitator;
OrdersFacilitator.deployed().then(x => facilitator = x);

var orderNumber = '33075588-8408-484b-8a53-e9c7f61bcb12';
facilitator.recordOrder.call(orderNumber);

I get a return value of false which make sense considering I don't think I've specified an amount to send.  However when I call the function directly:

facilitator.recordOrder(orderNumber);

I'm returned some json with a reciept:

{ tx: '0x5e38d5bb4f933a58e56620e8b0ae9ae0acb191b92ce0fef2f8fe784c9d40ef2c',
  receipt:
   { transactionHash: '0x5e38d5bb4f933a58e56620e8b0ae9ae0acb191b92ce0fef2f8fe784c9d40ef2c',
     transactionIndex: 0,
     blockHash: '0x038a57ce4a73efc59d57403d652119d3114602311756251be74e75cbe4d06e39',
     blockNumber: 5,
     gasUsed: 24150,
     cumulativeGasUsed: 24150,
     contractAddress: null,
     logs: [],
     status: 1 },
  logs: [] }

Which I have no idea what is going on here, because I never specified an amount, and I'm calling from the truffle console, So I don't even know how gas when I'm not connected to an account (that I know of).

How can I send value to my payable function from truffle?


texts: What is the length of an signed transaction ? ( to be sent by method eth_sendRawTransaction )

texts:
I have spent days on signing a raw transaction, but all are failed.
Now I want to know, what is the length of a raw transaction? and can you give me an real example of a signed transaction?
For example,
I want to do this quite simple transaction:
send 0.00xx ETH from address 1 to address 2, with no comment

my parameters are:
{
  nonce: '0x44e',
  gasPrice: '0x29e8d60800',
  gasLimit: '0x59d8',
  to: '0x3Ae7a18407B17037B2ECC4901c1b77Db98367cDA',
  value: '0x37b4e07e14000',
  data: '0x'
}

and the result of signing with private key is : （using a lib named  @ethereumjs/tx）
0xf86d82044e8529e8d608008259d8943ae7a18407b17037b2ecc4901c1b77db98367cda87037b4e07e140008025a096815bf332f590506df079b666cc198816d690a7d251fe8aa8c8c70c82752c7ba03afe5ffc239c9d4c4f36850f4413afc97eed68f70839559d466c3924ec340059

It's length is 224. is it correct ?
thanks a lot!


texts: Solidity: extract data from signed message?

texts:
In an effort to reduce gas costs for users, I'm looking for a way to delegate certain transactions to a contract owner so that the owner makes a transactions that would have been otherwise sent by the user.  So instead of sending a transaction directly to the blockchain, the user could sign a message in MetaMask and send the message as an authorization to the server, which would then send a transaction to the blockchain, assuming other conditions are met.

However, to provide maximum assurance to users that only authorized transactions are processed/sent by the contract owner, I'd like to be able to unpack the signed message within the contract so that the following are verified:

1) The user's address

2) The transactions data

At a high level, the solidity function would look something like this.

function processDelegatedTransaction(
    address userAddress,
    bytes32 msgHash,
    uint8 v,
    bytes32 r,
    bytes32 s,
    uint16 param1,
    uint16 param2
) public requireOwner {

    require(userAddress == ecrecover(msgHash, v, r, s));

    // Do something else to verify that param1 and param2 are packed in msgHash
}

The require statement should take care of #1 above, but #2 is the issue.

The message signing process could encode multiple parameters into a single uint, which would be included in the hash and then, if I'm able to unpack the hash, decode them similarly to the method described here:

https://medium.com/@novablitz/storing-structs-is-costing-you-gas-774da988895e

So the only sticking point is being able to extract the params from the hash or recreate the hash from the params.  Is this possible?


texts: How much does it cost to use a contract?

texts: Still new to ethereum and would like to know the price for a contract.


texts: events and relationships between smart contracts and oracle smart contracts

texts: How to subscribe a web3j client node to a smart Oracle contract event? Do I need the Oracle contract address?


texts:
I just want to ask, does Contract Wallet need an approval/allowance? as far as i know, Contract Wallets are executed by Wallet owner (Owner account) and the gas fees are paid by this owner account.

And, is there any site (sources) to know how about contract wallet creation and the use fees? as i learned, Contract Wallet charges more fees compared to standard wallet.

Thank in advance,


texts: Ethereum-based permissioned blockchain implementations

texts:
I am new to Ethereum. Trying to find what all permissioned blockchains are available at the moment which are among the most popular ones.

I am just trying to avoid spending unnecessary time to explore all kind of permissioned blockchains and try focusing on one which is really popular to provide realistic solutions. If you could share some nice links where I can start my study will be of great help.


texts: "Skipping non-existent input file" error using solc docker on Windows

texts:
I'm trying to setup a local build environment for Solidity on Windows (10).

One of the options recommended in the Solidity docs is docker.

Superficially, the docker image runs fine:

C:\work\eth>docker run ethereum/solc:stable --version
solc, the solidity compiler commandline interface
Version: 0.4.11+commit.68ef5810.Linux.g++

But, it's not managing to access any files

C:\work\eth>docker run ethereum/solc:stable Coin.sol
Skipping non-existent input file ""Coin.sol""

C:\work\eth>dir Coin.sol

 Directory of C:\work\eth

05/22/2017  02:55 PM               873 Coin.sol
               1 File(s)            873 bytes
               0 Dir(s)  263,229,722,624 bytes free

Is this a docker issue? An issue with the solc image? How should I proceed?


texts:
Environment
Android Studio
Infura – Rinkeby test network
Web3J
Metamask
Rinkeby.etherscan.io
I am trying to build an Android app to read and write smart contract by following the medium article:
Communicating with an Ethereum Smart Contract via Android
https://medium.com/interfacing-with-a-blockchain/communicating-with-an-ethereum-smart-contract-via-android-24ee0dd2c115
Github: https://github.com/EbenezerGH/Greeter-Android-App.git
The app is perfectly working if the author’s credential is used as follows:
val credentials = Credentials.create("f9319fe162c31947c0ca8fd649a536b7ca311b5f210afdc48b62fd7d18ce53e4")
val contractAddress = "0x8394cDf176A4A52DA5889f7a99c4f7AD2BF59088"
val url = https://rinkeby.infura.io/v3/01eb8f7b5e514832af8e827c23784d23

But when I used my credentials, it is giving the following error:
java.util.concurrent.ExecutionException: org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: okhttp3.internal.http.RealResponseBody
My credentials are:
 val credentials = Credentials.create("914e0d54701284133143769df155e9c13d16a4ae82696457444c58d7442760d5")
val contractAddress = "0x33B27EC0BE04B7ab4069F3b46Daa2d83516B4007"
val url = "https://rinkeby.infura.io/v3/ff788aca525342818fa643b0e2e99040"

To create the credentials:
Goto metamask.io:
Menu->Account Details->Export->Password
metamask private key: 914e0d54701284133143769df155e9c13d16a4ae82696457444c58d7442760d5
Updated Experiment2:
In the second experiment,
I have commented out my rinkeby infura URL and used author's rinkeby URL.
This time both reading and writing through smart contract worked well.

     val credentials = Credentials.create("914e0d54701284133143769df155e9c13d16a4ae82696457444c58d7442760d5")
        val contractAddress = "0x33B27EC0BE04B7ab4069F3b46Daa2d83516B4007"
//        val url = "https://rinkeby.infura.io/v3/ff788aca525342818fa643b0e2e99040"

val url = "https://rinkeby.infura.io/v3/01eb8f7b5e514832af8e827c23784d23"

I am creating rinkeby infura test network as follows:
Goto: https://infura.io/dashboard/ethereum
Enter project name: digitran
Obtain the following:
project id: ff788aca525342818fa643b0e2e99040
https://rinkeby.infura.io/v3/ff788aca525342818fa643b0e2e99040
wss://rinkeby.infura.io/ws/v3/ff788aca525342818fa643b0e2e99040
Questions

Is this the right way to create rinkeby infura test network?
Why reading the contract is working fine, but writing contract is not working?
What is the meaning of the error “Invalid response received: okhttp3.internal.http.RealResponseBody”?
How to remove this error?
What settings are required in rinkeby infura test network?

The following figure shows the error in Android Studio


texts:
I have a factory contract that I need to be able to deploy with some ETH. I'm getting an error TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address.

I tried instantiating the contract address as payable but not having any luck.

Where am I going wrong?

Factory contract

function createContract() public payable {
   NewContract myNewContract = new NewContract();
   address newContractAddress = address(newContract);
   newContractAddress.transfer(msg.value);
}

The following also doesn't work:

function createContract() public payable {
   NewContract myNewContract = new NewContract();
   address payable newContractAddress = address(newContract);
   newContractAddress.transfer(msg.value);
}

Constructed contract

constructor() public payable {
   ...
}


texts:
I am a bit confused about the transfer of documents done via blockchain.

Let me paint the picture:

Using a supply chain management blockchain as an example. In a supply chain, there are many participants e.g. exporter, customs, importer, delivery, certification body, banks etc.

Lets say the exporter requires a licence. So it applies for a licence to a certification body and receives a licence. That transaction can be recorded as a 'block' and added to the blockchain.

What I am confused about is what data would that 'block' contain? Would it contain the actual document of the licence? If not, can you configure a 'block' so that it contains a link to a database so that if the exporter wants to view is licence, he is able to? Furthermore, would everyone be able to see that 'link'.

I understand that a blockchain is simply a ledger of all the transaction taken place. What I am confused is what sort of data the 'block' contains.

Thank you guys


texts: Address Not Getting Stored Correctly in State Variable?

texts:
I am trying to write a contract where the originator of the contract will offer a reward that can only be claimed by a different address that she or he specifies.  To do that, I am trying to create state variable of type 'address' that stores the address of the person who is allowed to claim the reward, which I am calling the 'ambassador'.

See the code below:

pragma solidity ^0.4.19;
contract AmbassadorTask {
    address private owner; // Address of business offering rewards for a task
    uint taskReward; // How much ether ambassadors get every time they complete a task
    address ambassador; // Represents person allowed to complete task and claim rewards

    //Constructor
    function AmbassadorTask (address _ambassador) public payable {
            require (msg.value > 0); // No point creating tasks with no rewards
            owner = msg.sender;  // Set creator to be the owner of this contract
            taskReward = msg.value;
            ambassador = _ambassador;
    }

    function getAmbassador() public view returns (address _ambassador) {
        return ambassador;
    }
}

The code compiles correctly in Remix, but when I test it at run time using the JavaScriptVM, the 'ambassador' address that is stored in the contract is not the same address that I pass as input in the constructor.

For example, I pass 0x14723a09acff6d2a60dcdf7aa4aff308fddc160c as input, when calling the constructor.  If I immediately call getAmbassador(), I get the following output: 0xa4aff308fddc160c000000000000000000000000, instead of the value I entered to create the contract.  I also noticed that it is just the last 16 hex digits from the address I passed, followed by trailing zeros.

In contrast, I am not having the same issue storing msg.sender to the owner state variable when I call the constructor.

Why is this happening?  I am storing the address values incorrectly?  Is this a data conversion issue?

Thanks in advanced for your help!


texts: I want to develop a Python based client that can make use of the Ethereum network, a possible way to do it is using ethjsonrpc module, but is there any detailed documents about ethjsonrpc?


texts:
I would like to explore the storage data of a contract. I have geth fully synched and I interact with it over RPC. There is the function "eth.getStorageAt(addr, index, block)" provided, but you need to pass an index to it. Unfortunately this index doesn't seem to be an incrementing integer as I thought. I tried accessing the storage of the DAO as an example, and you can view the storage of it here: https://live.ether.camp/account/0xbb9bc244d798123fde783fcc1c72d3bb8c189413 (be sure to turn "Smart mode" off). As you can see, the first few indices of the storage are the numbers 0-22 with some missing in between, but then it changes to hashes. Now, if you're running a node, you need to be able to iterate over the full storage, and thus you need to be able to calculate these indices. How would I do that?

tl;dr: I want to iterate over the whole storage of a contract, how would I do that?


texts: remix: The method debug_traceTransaction does not exist/is not available

texts:
I have followed this answer.

  So, you just need to add the --rpcapi "eth,net,web3,debug" command
  line option.

The way I run my geth:

geth --datadir /home/user/POA/private --rpcaddr 127.0.0.1 --rpc --rpcport
8545 --rpccorsdomain="*" --networkid 32224 --rpcapi eth,net,web3,personal,debug
--port 3000

But on remix or remix-alpha when I try to debug the function call I have face with the following error: The method debug_traceTransaction does not exist/is not available.

[Q] How could I fix this error? What might be the reason of this?


texts: Is there the opposite function for evm_increaseTime?

texts:
I'm using the following function in my JS tests (with truffle) to move forward in time to test time dependent functions:

const timeTravel = function (time) {
  return new Promise((resolve, reject) => {
    web3.currentProvider.sendAsync({
      jsonrpc: "2.0",
      method: "evm_increaseTime",
      params: [time], // 86400 is num seconds in day
      id: new Date().getTime()
    }, (err, result) => {
      if(err){ return reject(err) }
      return resolve(result)
    });
  })
}

So then, I can do a test like this:

it("should not allow to buy tokens if crowdsale has finished", async function () {

    await timeTravel(100000) // Move forward in time so the crowdsale has finished
    await mineBlock() // workaround for https://github.com/ethereumjs/testrpc/issues/336

    try {
      await crowdsale.buyTokens(accounts[1],{from:accounts[1],value:1 * 10 ** 18});
    } catch (e) {
      return true;
    }
    throw new Error("I should never see this!")

  });

The problem is that this "time traveling to the future" is not transitory, meaning that testrpc will continue to be in a future block unless I stop testrpc and start it again.

I'd like to run a test in the future and then go back to continue running the automated test in the current block.

Supplying a negative number will obviously not go back to a previous block and there is no such thing as evm_decreaseTime.


texts: Automated tests with brownie - how to handle "base fee exceeds gas limit"

texts:
I have wrote this very basic test scenario with brownie:
import pytest

def test_set_get_18(tcontrat1,accounts):
    tcontrat1.set(18, {'from': accounts[0],'gas_limit':100})
    assert tcontrat1.get() == 18

As you can see, i set a gas limit.
The transaction will fail, this is normal. I want to check in my test it will fail.
Here is what i've tried:
import pytest
import brownie

def test_set_get_18(tcontrat1,accounts):
    with brownie.reverts():
      tcontrat1.set(18, {'from': accounts[0],'gas_limit':100})

It does not work, the test scenario fails with the message:

ValueError: base fee exceeds gas limit

I have also tried this:
def test_set_get_18(tcontrat1,accounts):
    with brownie.reverts("base fee exceeds gas limit"):
      tcontrat1.set(18, {'from': accounts[0],'gas_limit':100})

The error is not handled or catched by brownie. How should i do ?
I want to test that this transaction should fail because of gas limit.
Thanks for your help.


texts: How to send an array of structs from web3js to solidity contract?

texts:
I am getting an error when passing (javascript array of objects) from web3js,
To solidity function that takes (array of structs) as a parameter.

could you help me?

below is the code and the error

// web3js code

let slctedItems = [{name:'item1', qty:2},{name:'item2', qty:3}];

contract.methods.calcItems(slctedItems).call((err, total) => {

      // code

    })

//solidity code

 struct Item{

        string name;
        uint qty;

    }

function calcItems(Item[] memory _items) public view returns(uint){

        //code
       // return uint
    }

// the error i got
Uncaught TypeError: Cannot read property 'forEach' of undefined
    at r (web3.min.js:1)
    at web3.min.js:1
    at Array.map (<anonymous>)
    at i.encodeParameters (web3.min.js:1)
    at web3.min.js:1
    at Array.map (<anonymous>)
    at Object.o._encodeMethodABI (web3.min.js:1)
    at Object.o._processExecuteArguments (web3.min.js:1)
    at Object.o._executeMethod (web3.min.js:1)
    at calc_loads (main.js:97)

online example of the issue and the code I wrote. in the link below:
https://malaak-habashy.github.io/

I've found an issue on web3js github.
see the link below:
https://github.com/ethereum/web3.js/issues/3538


texts: Is it possible to make a token that is unique to a pair of addresses?

texts:
As we know, each ERC721 token is unique in the sense that each of them is assigned to an address. I wonder if it is possible to go further and make tokens that is unique to a pair of addresses? i.e. the token can be seen as uniquely belonging to the relationship of two addresses.
This will be useful as it opens up scenarios where relations between people, or between transactions, can themselves be tokenized.


texts: eth.balance() shows random alphanumeric content

texts:
const HttpProvider = require('ethjs-provider-http');
const Eth = require('ethjs-query');
const eth = new Eth(new HttpProvider('https://rinkeby.infura.io/'));

eth.getBalance("0x39af04b02299c88b76d30a6d1db1b98368dafa26",
        function(err, res){
            console.log(res,err);
        });

This ( " 38d7ea4c68000 " ) is what it returns , but i have  0.001 ether in that address


texts: Can STRATO be utilized as an Ethereum client?

texts:
Consensys announced yesterday that BlockApps STRATO is available for Microsoft Azure.

Joseph Lubin says,

  It is also a better Ethereum public mainnet node for
  various kinds of decentralized apps that want to write to the RESTful API instead of connecting to a node via RPC.

Does it mean STRATO offers another client implementation for Ethereum? What language is it written in? Is it even open source?


texts: "Cannot import url", "File outside of allowed directories" using --standard-json

texts:
I'm trying to understand how to use solidity's JSON input-output API. Here's my json file;

{
  "language": "Solidity",
  "sources": {
    "StandardToken.sol": {
      "urls": [
        "file:///home/myuser/myproject/contracts/vendor/StandardToken.sol"
      ]
    }
  }
}

My best guess as to the "correct" command is;

cat input.json | solc --allow-paths /home/myuser/myproject/contracts --standard-json

I've tried lots of different relative paths, ending with or without a trailing slash, running the command in different directories, etc. But no matter what combination I try, I get back a json object with this error message;

  "Cannot import url
  (\"file:///home/myuser/myproject/contracts/vendor/StandardToken.sol\"):
  File import callback not supported"

I was getting this on solc version 0.4.24, but I upgraded to 0.5.1+commit.c8a2cb62.Linux.g++ and get the same issue.

Strangely, I get a similar message with solcjs;

$ cat input.json | solcjs --standard-json
Cannot import url (\"file:///home/myuser/myproject/contracts/vendor/StandardToken.sol\"): File import callback not supported

There seem to be a lot of github issues mentioning these error messages, but I can't make use of any of them.


texts: How does contract know where the fund (or the amount of Ether) is by executing "suicide"?

texts:
It's said if we run:

suicide(address recipient);

At the end of the contract, the recipient will receive the amount of Ether owned by the contract.

Question 1: How does the contract (and this function) know where the amount of Ether is?

Question 2: In the 1st example here, they have no "suicide", then how the funding is released to the recipient (or beneficiary)?

"payable" enables a function (and contract) to receive Ether, and it can keep track of the amount it receive  by using an array, e.g.

mapping (address => uint) balances;

Question 3: How does the contract claim the money it receives?


texts:
Use the mist wallet 0.3.9.

The ETH from a pool is sent to a wallet address. How can I send the ETH from wallet to account?

When I try to send from the wallet address to an exchange address, I saw only execute contract from account address to a wallet address. What does that mean? How can i sent ETH from a contract wallet to another account?


texts: Transactions between ERC-20 Token and DEX on Etherscan

texts:
Below is a screenshot of transactions at an address I take to be the ERC-20 token SAND (Sandbox). Is this right? that the link  below the image is the singular address where this ERC-20 token issues from?

https://etherscan.io/token/0x3845badade8e6dff049820680d1f14bd3903a5d0?a=0x3dd49f67e9d5bc4c5e6634b3f70bfd9dc1b6bd74
What exactly are the ins and outs in the middle column? Does an IN from the Uniswap decentralized exchange (DEX) mean that someone on the Uniswap exchange has bought SAND tokens from liquidity providers there? If so, why are there no OUTs to Uniswap, given that a trade consists of a buy and sell? And why does the Etherscan address of Uniswap V2 SAND 24 not match the mainnet Uniswap address? Is the former actually the DEX liquidity pool smart contract and not the exchange itself? Rregarding the actual OUTS that do appear: who are they to, if not an exchange?


texts: How can I send array of structs as arguments?

texts:
I want to send to my contract an array of currency and its price so it will store it:

pragma solidity ^0.4.24;

contract ExchangeContract {
    enum CurrencyType { USD, TWOKEY, BTC, ETH, DAI, USDT, TUSD, EUR, JPY, GBP}

    mapping(uint256 => CurrencyPrice) public priceByCurrencyType;

    struct Price{
        uint price;
        uint decimals;
    }

    struct CurrencyPrice{
        uint currencyInt;
        Price price;
    }

    function updatePrices(CurrencyPrice[] memory _array) public {
        for(i=0; i<_array.length; i++){
            priceByCurrencyType[_array[0][0]]=_array[0][1];
        }
    }
}

as I saw in the answer here - Passing in an array of complex structs
its suggest to send one at a time and not worry about multiple calls.

So went back to my question, it does not have to be a struct - is there a way to send a bulk of data, structures parse it in the function so it will fit into one call.


texts: Transferring ether from test account to contract in Remix

texts:
I have a contract successfully deployed and working well in the Javascript VM on Remix.

contract BlipCoinIco is PausableToken {
  *snip*

  function() isIcoOpen payable {
      totalRaised = totalRaised.add(msg.value);

      uint256 tokenAmount = calculateTokenAmount(msg.value);
      balances[fundsWallet] = balances[fundsWallet].sub(tokenAmount);
      balances[msg.sender] = balances[msg.sender].add(tokenAmount);
      Transfer(fundsWallet, msg.sender, tokenAmount);

      // immediately transfer ether to fundsWallet
      fundsWallet.transfer(msg.value);
  }

  function calculateTokenAmount(uint256 weiAmount) constant returns(uint256) {
      // standard rate: 1 ETH : 50 ESP
      uint256 tokenAmount = weiAmount.mul(50);
      if (now <= startTimestamp + 7 days) {
          // +50% bonus during first week
          return tokenAmount.mul(150).div(100);
      } else {
          return tokenAmount;
      }
  }

  *snip*
}

The Javascript VM provides a couple of test accounts with preloaded Ether:

The contract owner and fund's wallet belongs to the first test account.

How can I send ether to the first test account, from the second test account, so that it hits the contract's isIcoOpen payable function?

I've tried using the send and transfer functions, but I can't get it to work.


texts: Creating buttons for executing smart contract functions,How to work with smart contract instance in App.js

texts:
This is my App.js file which is related to a smart contract. I would like to know how is it possible to get access to the contract and create a button for executing a contract function which needs an input for specifying the function parameters which is an integer! The function is payable and amount can be specified by a user in input field.
Thanks in advance
=============================================
import React, { Component } from "react";
import SimpleStorageContract from "./contracts/SimpleStorage.json";
import getWeb3 from "./getWeb3";

import "./App.css";

class App extends Component {
  state = { storageValue: 0, web3: null, accounts: null, contract: null };

  componentDidMount = async () => {
    try {
      // Get network provider and web3 instance.
      const web3 = await getWeb3();

      // Use web3 to get the user's accounts.
      const accounts = await web3.eth.getAccounts();

      // Get the contract instance.
      const networkId = await web3.eth.net.getId();
      const deployedNetwork = SimpleStorageContract.networks[networkId];
      const instance = new web3.eth.Contract(
        SimpleStorageContract.abi,
        deployedNetwork && deployedNetwork.address,
      );

      // Set web3, accounts, and contract to the state, and then proceed with an
      // example of interacting with the contract's methods.
      this.setState({ web3, accounts, contract: instance }, this.runExample);
    } catch (error) {
      // Catch any errors for any of the above operations.
      alert(
        `Failed to load web3, accounts, or contract. Check console for details.`,
      );
      console.error(error);
    }
  };
  render() {
    if (!this.state.web3) {
      return
Loading Web3, accounts, and contract...
;
    }
    return (

Hi

    );
  }
}

export default App;


texts:
I am using Ethereum Wallet Version 0.8.9 on Ubuntu 16.04. I added Golem token to Wallet about week ago and now I get following error messages on logs:

[ERROR] (ui: browser) - Logs of Token Golem Network Token couldn't be received {}

Is this something that I should address or just ignore? Everything seems to work as it should. Error is added to log every second, so I don't want to keep my wallet open so that log size wont grow too big.


texts: How to handle ether deposits like exchanges do?

texts:
One of the core philosophies of Ethereum is decentralization. However, there are still many valid use cases to provide centralized wallet services, exchanges being one of the most well known examples.

There seems to be very little information available how to technically implement deposits for such scenarios.

What is the latest recommendation for the number of tx confirmations with the Homestead release? ¹
Are there any libraries or services that provide sample implementations? ²
What is the rough pseudo code implementation to handle this yourself?
Any other considerations? ³

1) 5 confirmations mentioned here What number of confirmations is considered secure in Ethereum? and 12 here How should I handle blockchain forks in my DApp?, but how relevant these are still with the Homestead release?

2) reflux-tx is mentioned here How should I handle blockchain forks in my DApp?

3) I've seen Vitalik recommending running two nodes to reduce the risks.


texts: Retrieve and store data into a local database using smart contract

texts:
For my information oraclize can be use to retrieve data from several data source but what if i need to get from a local database such as oracle,sql, etc. Is there any way of doing it?

PS: I am developing a private ethereum BC with smart contract using solidity & truffle


texts: What's the concept behind ethereum transactions that allows them not to require change addresses? What's the underlying difference compared to - for example - bitcoin?


texts: How to structure a contract for future upgrades

texts:
Imagine I have a contract I have implemented and deployed like this:

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract GameItem is ERC721 {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("GameItem", "ITM") public {
    }

    function awardItem(address player, string memory tokenURI) public returns (uint256) {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(player, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }
}

After deploying the contract and people using for sometime, I feel the need to implement an auction system for these tokens...

How would I structure my solidity code to enable these upgrades without losing original data?


texts: What are some examples from Bitcoin or other chains of hard forks similar to the DAO-refund fork?

texts:
The changes made to the chain by the hard-fork was a one-time balance modification to several accounts. As of block 1920000, the difference between the state tries of the two forks was in the balance of a half-dozen accounts.

Have other blockhains (other than Ethereum) done similar state-modifying forks, or is Ethereum the first to test a similar balance-modification fork ? What are some examples one could compare the DAO-rescue fork with ?


texts: Issues connecting to the Etherscan Ropsten API via web3.py

texts:
I am developing a simple application that transfers tokens between users. The token in an ERC20 standard token.

I am really new to the web3 and ethereum development world and I am confused by quite a few things. It would be nice I someone could show where my mistake is.

The contract for the token in deployed on the ropsten testnet and I wanted to call balanceOf() and transfer() functions. However, calling the balanceOf() function in form .call().balanceOf() gives an error:

File "/home/blah/blah/transactions.py", line 26, in <module>
    CONTRACT.call().balanceOf("0x70d704ab702097427Bba427492c86493e8B7597b") File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 772, in call_contract_function
    return_data = contract.web3.eth.call(call_transaction)   File "/usr/local/lib/python3.5/dist-packages/web3/eth.py", line 266, in call
    formatted_transaction = formatters.input_transaction_formatter(self, transaction)   File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 71, in inner
    return fn(*text_args, **text_kwargs)   File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 85, in inner
    return force_obj_to_text(fn(*args, **kwargs))   File "/usr/local/lib/python3.5/dist-packages/web3/formatters.py", line 125, in input_transaction_formatter
    'from': eth.coinbase,   File "/usr/local/lib/python3.5/dist-packages/eth_utils/string.py", line 85, in inner
    return force_obj_to_text(fn(*args, **kwargs))   File "/usr/local/lib/python3.5/dist-packages/web3/eth.py", line 70, in coinbase
    return self.web3._requestManager.request_blocking("eth_coinbase", [])   File "/usr/local/lib/python3.5/dist-packages/web3/providers/manager.py", line 30, in request_blocking
    response = json.loads(force_text(response_raw))   File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)   File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())   File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am not sure if this is an error regarding HTTPProvider not connecting to the "https://ropsten.etherscan.io", or is the url that I have used to the HTTPProvider not correct for the ropsten testnet, or some other issue. I have double checked the contract address as well as the contract ABI. Or is it some problem regarding lack of gas/ether associated with account?

I tried testing another similar contract on the private testnet, and the same code was working well.


texts:
I had a MetaMask account with password.
Had used password to connect to DDex exchange for Ethereum connectivity, transactions, and token balance checks.
Recently, I deactivated MetaMask from one of my browsers, and can no longer log into MetaMask with password/ account. Why, and what way out?


texts: Contracts are “instantiated” by the account creating transaction?

texts:
I read the following in a research paper:
Short Paper: Formal Verification of Smart Contracts

that:

  contracts are “instantiated” by the account creating transaction; this
  will allocate the properties of the contract in the global storage and
  call the constructor (the method with the same name as the contract).

What does the above mean?
Does it mean that we don’t have the main method in Solidity?
And also does it mean that we can’t load the contract within EVM/block chain as
for example we load compiled java code into JVM by using “java
contract” where suppose contract is a compiled java code & for that reason we need some external process like Truffle to push the
contract into the EVM/block chain?

Zulfi.


texts: Ethereum wallet version 0-7-5 - Solidity compiler version?

texts: Is there a way to get the Solidity compiler version used by the official Ethereum wallet when deploying a contract to the blockchain?


texts: What exactly does the miner verify in the process of verifying the transaction?

texts:
I have seen different answers to this question. For example, one transaction calls a function on a smart contract. Some people say that the miner uses the same input to verify that the output is the same. Some people say that the miner does not verify the output, but only verifies that the contract is deployed correctly, interacts as expected with the network and follows the rules of the ethereum protocol.
I am very confused now and hope to get your help!


texts: How can I list The DAO proposals and vote from the command line?

texts:
Are there any command line tools to vote on The DAO proposals?

I would like to:

List the open proposals
Check whether I have already voted on these proposals
Check my voting history
Vote on the proposals for each of my accounts with The DAO token balances
Check my account balance, and show me which accounts have The DAO token transfers blocked, by which proposal and the expiry time
And do this from the command line

Why would I want to do this from the command line?

I want to vote without having to send my details (wallets and passwords) over the Internet.
I don't want to wait for the Ethereum Wallet (Mist) to unfreeze, and I cannot view the list of proposals in Mist.
And I just wanna use geth (with a simpler interface).


texts:
Need a smart contract to exchange ERC20 for Ether and Ether for ERC20.

The goal is, you send ether you get erc20, you send erc20 you get ether back. Without having to use web3 tools.

The only way I can think for implementation is to use the ERC20 itself as exchange contract.

Then the token address will have to hold both ether and its own tokens.

This sounds like bad practice, or is it? Any better idea to achieve that?


texts: Deploying smart contracts from mobile device

texts: I have recently started learning solidity but I don't have access to a laptop. All I have is a Samsung s4. I know it is not ideal, but is there a wallet that has the ability to deploy from Android


texts: Generating a BIP-39 compatible Ethereum wallet results in IndexOutOfBoundsException?

texts:
Trying to configure android app to use a master seed phrase instead of individual private key generation.

Using the new(ish) generatebip39wallet results in an indexoutofboundsexception.

Offending code:

 Bip39Wallet bip39Wallet = WalletUtils.generateBip39Wallet(seed, getFilesDir());

Log file:

03-22 14:08:19.519 31451-32106/example.crypto.keyapp E/AndroidRuntime: FATAL EXCEPTION: IntentService[WalletGenService]
                                                                   Process: example.crypto.keyapp, PID: 31451
                                                                   java.lang.IndexOutOfBoundsException
                                                                       at java.util.Collections$EmptyList.get(Collections.java:102)
                                                                       at org.web3j.crypto.MnemonicUtils.generateMnemonic(MnemonicUtils.java:61)
                                                                       at org.web3j.crypto.WalletUtils.generateBip39Wallet(WalletUtils.java:95)
                                                                       at example.crypto.keyapp.WalletGenService.onHandleIntent(WalletGenService.java:97)
                                                                       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                       at android.os.Looper.loop(Looper.java:168)
                                                                       at android.os.HandlerThread.run(HandlerThread.java:61)
03-22 14:08:19.643 31451-31653/example.crypto.keyapp E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb8c19460

So I'm not too sure what's going on.  Can anyone help

EDIT: The error is coming from populateWordList in mnemonicUtils.java

private static List<String> populateWordList() {
    URL url = Thread.currentThread().getContextClassLoader()
            .getResource("en-mnemonic-word-list.txt");
    try {
        return readAllLines(url.toURI().getSchemeSpecificPart());
    } catch (Exception e) {
        return Collections.emptyList();
    }
}

Is this error trying to say that there are too many words to load into a single index.  The file which contains them "en-mnemonic-word-list.txt" has over 2000 words in it's index.  Curious if anyone has solved this problem or if it's solvable without reducing security.


texts: Should investors add token address to their account to receive the ICO rewards?

texts:
I just created a token in blockchain and when I test it on Rikenby network but no tokens appear on my wallet until I added the Token address to watch list.

1- Is that normal that investors should add token address to their account to receive the ICO rewards ?

2- When I added the token to an other account I can change the Decimals! is that normal ? or there is a way to lock Decimals from being changed ?

Kind Regards.


texts: What is saved on every block on Ethereum?

texts:
In Bitcoin every block has the information about the transaction (A sends money to B, C to D etc). And everytime a new transaction (someone sends money to another address) is sent, the miners will create a new block (or add to the new one).
What is saved in Ethereum?
I guess if we are sending ETH to some address, then the same data (A transfers ETH to B) is saved, but I guess Ethereum is saving more data too, because of the smart contracts.
So what data is saved in Ethereum? and when is created a new block in Ethereum? (in Bitcoin a new block is created every 10 minutes and it includes the transactions from one address to another one registered by the minner who discovered the nonce).

Not sure if this questions makes sense :(


texts: Installing geth on Raspberry Pi 3 - cannot allocate memory error

texts:
I've been using this script to attempt to install geth on a Raspberry Pi 3.

It seems to work ok until part way through the build:

pi@raspberrypi:~/go-ethereum $ make geth
build/env.sh go run build/ci.go install ./cmd/geth
>>> /usr/lib/go-1.7/bin/go install -ldflags -X main.gitCommit=bdef758d5c6d397584d0c35e53d6f6c318e61351 -v ./cmd/geth
github.com/ethereum/go-ethereum/cmd/geth
# github.com/ethereum/go-ethereum/cmd/geth
/usr/lib/go-1.7/pkg/tool/linux_arm/link: running gcc failed: fork/exec /usr/bin/gcc: cannot allocate memory

util.go:43: exit status 2
exit status 1
Makefile:15: recipe for target 'geth' failed
make: *** [geth] Error 1

It is saying cannot allocate memory - there is ~8GiB free on the SD card (1GB RAM).

Can anyone recreate this error? What tips are there for debugging/fixing?

N.b. This question is similar to Installing ethereum node on Raspberry pi errors.

Also, a similar problem was reported here: https://groups.google.com/forum/#!topic/cloud-print-connector/zF_xyViClLM


texts: Is there any gas cost when executing `msg.sender.transfer(0)`?

texts:
I have a function which looks more or less like this:

function exchange(uint256 amount, bool specialCase) external returns (uint256) {
    let retVal;
    if (specialCase) {
        register(amount);
        retVal = 0;
    }
    else if (amount > address(this).balance) {
        register(amount - address(this).balance);
        retVal = address(this).balance;
    }
    else {
        register(0);
        retVal = amount;
    }
    require(authorized(msg.sender));
    msg.sender.transfer(retVal);
    return retVal;
}

As you can see, in some cases, it will execute msg.sender.transfer(0).

Of course, I can avoid this by placing msg.sender.transfer(retVal) only where retVal > 0.

But I think that my code looks "cleaner" this way, and I would like to keep it as is.

So I would like to know if there is any gas cost in executing msg.sender.transfer(0).

Thank you!!!


texts: Call write function, which doesn't change contract value

texts:
I'm new in smart contracts and faced with one problem.
After deploying contract to my test local blockchain network, i try to set new value via setter, after that I call get method of contract and it return old value.

This is my contract,

pragma solidity ^0.4.10;

contract Storage {
    uint256 storedData;

    function set(uint256 data) {
        storedData = data;
    }

    function get() constant returns (uint256) {
        return storedData;
    }
}

What steps I did:

Deploy contract via web3j in java code, after deploying I see address of my contract,so it's deployed
After than in geth console create variable abi:
var abi = [{"constant":false,"inputs":[{"name":"data","type":"uint256"}],"name":"set","outputs":[],"payable":false,"statemutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"statemutability":"view","type":"function"}];
load contract: var storage = eth.contract(abi)
load contract by adress: var contractInstance = storage.at("0x45564fe8d90e542f3f896dd43b374210bc109299");
try calling method get(): var result = contractInstance.get();
it's output 0
then try set new value: var result = contractInstance.set(566);
After that I see something like this:
INFO [09-07|08:42:07] Submitted transaction                    fullhash=0x7110b3fdfc8005187ed367beb8275a6f4b926f4852f726784219a5a3aa9c8d9e recipient=0x45564fe8d90e542f3f896dd43b374210bc109299
"0x7110b3fdfc8005187ed367beb8275a6f4b926f4852f726784219a5a3aa9c8d9e"
Next I start mining: miner.start(), at the beginning of mining a see log like this: INFO [09-07|08:44:15] Commit new mining work                   number=38 txs=1 uncles=0 elapsed=1.044ms
INFO [09-07|08:44:15] Successfully sealed new block            number=38 hash=e62548…39ad89
INFO [09-07|08:44:15]  block reached canonical chain          number=33 hash=9a6ae1…9cb82d
INFO [09-07|08:44:15]  mined potential block                  number=38 hash=e62548…39ad89
INFO [09-07|08:44:15] Commit new mining work                   number=39 txs=0 uncles=0 elapsed=182.5µs
INFO [09-07|08:44:15] Successfully sealed new block            number=39 hash=87b682…f52e39
INFO [09-07|08:44:15]  block reached canonical chain          number=34 hash=cc9a2d…36838a
INFO [09-07|08:44:15]  mined potential block                  number=39 hash=87b682…f52e39
INFO [09-07|08:44:15] Mining too far in the future             wait=2s
Then I stop mining: miner.stop()
9.Then call contractInstance.get(): and see the same value 0

I'm confused(
Thanks everybody for help!


texts: How has the average TX fee on the Ethereum network changed over time?

texts:
TX fee meaning the gas price * gas limit of a transaction .

Average meaning, how much ETH (or WEI) are people spending on average on a transaction today (May 2017) vs 1 year ago (May 2016) vs the beginning (August 2015)

I would assume the fees themselves have gone up due to gas limit as people increase the gas necessary to interact with contracts, send tokens, etc.

However, there were some periods where the average gas price was much higher than it is now.

Mostly, I'm just curious.

Thank you for your time.


texts:
When I should consider to use Ethereum Private network for Production use case?

Can I dictate network difficulty rules and apply permission on such network.

Regards
Dev


texts: Minimum theoretical hardware requirement for geth

texts: Is there any theoretical requirement for RAM, storage size etc. when I run geth? I mean the real necessary hardware required to get geth running at the very least, but not the optimal or profitable configurations. Like if I run a private chain for experimental purpose, what is the absolute minimal hardware I need for each node? If yes, how are these requirements different in light mode/full node, miner and not miner?


texts: Ethereum paper wallet address generator with ability to upload your own graphic to give as gifts

texts:
I'm looking to give eth to friends and family for christmas this year. But I wanted to upload my own background image if possible to an Ethereum paper wallet generator. Is there such a thing? I don't want to have to edit the paper wallet source code just to do this if I don't have to.

Also, I can also send erc20 tokens to any ethereum paper wallet address right?


texts: Who are the main developers of Ethereum?

texts: Bitcoin has a handful of core developers like Gavin, Mike Hern, and etc that are the gatekeepers to implementing core features depending on community feedback. Who are the core devs in Ethereum and which parts of Ethereum are they responsible for?


texts: Why my transaction is always reverted and the other one not?

texts: I have a ethereum smart contract online. There is a function anyone can execute. In fact it's a bug, then there is a guy always execute the function successfully and rapidly with low gas, while my transaction is always reverted even with higher gas. It seems that the guy has a priority and higher speed to execute the function. How did this happen? And how should i solve this issue? I use ethers.js as client lib. Thanks very much.


texts: With the growing popularity of smart contracts, there is a high price associated with getting a smart contract audit. I was wondering if a pre-ICO would require a smart contract? Or should the tokens be generated first then during the ICO, all whitelisted address would receive their tokens including those from the pre-ICO. Thank you for your constructive responses.


texts: transfer back msg.value to caller on error

texts:
I have a function with modifier 'payable' in the contract. My understading is, msg.value gets added to the contract's balance and then further code is executed.
First question, is this a correct understading ?
Second question, how do i send back msg.value to caller if there is a error, i could think of doing this,

if(<check for error case>){
  msg.sender.send(msg.value)
}

or is there a way to use 'require'?


texts: How descriptive do I have to be in external calls to deployed contracts?

texts:
Let's say I have a contract right now that I want to interact with a future or existing contract. This contract has two modifiers (onlyPermittedContracts and onlyOwner) that dictate whether or not a contract or user is allowed to invoke a certain function.

contract owned {
    address public owner;
    mapping (address => bool) public permittedContracts;
    function owned(){
        owner = msg.sender;
    }
    modifier onlyOwner{
        if(msg.sender != owner){
            throw;
        }
        _;
    }
    function transferOwnership (address newOwner) onlyOwner{
        owner = newOwner;
    }
    function addPermittedContract(address newPermittedContract)onlyOwner{
        if(permittedContracts[newPermittedContract]==true){
            throw;
        }
        permittedContracts[newPermittedContract]=true;
    }
    function removePermittedContract(address oldPermittedContract)onlyOwner{
        if(permittedContracts[oldPermittedContract]!=true){
            throw;
        }
        permittedContracts[oldPermittedContract]=false;
    }
    modifier onlyPermittedContracts{
        if(permittedContracts[msg.sender]!= true){
            throw;
        }
        _;
    }
}

contract ExistingContract is owned{
    //stuff has been removed
    mapping (address=> uint) public balanceOf;
    function issueNewToken(address recipient, uint amount)onlyOwner onlyPermittedContracts{
        if(balanceOf[recipient]+amount<balanceOf[recipient]){throw;}
        balanceOf[recipient]+=amount;
    }
}

Now let's say I want to make a new contract that will refer to this existing, pre-deployed contract:

contract NewToken{
    oldToken previousToken = new oldToken();
    previousToken.issueNewToken(xxxxx, yyyy);

}

//an abstract contract
contract OldToken{
    function issueNewToken(address recipient, uint amount){}
}

My question is, how much information do I need to include in the issueNewToken() function in the abstract contract I have in my second contract? Do I need to describe the various modifiers, or is this sufficient for the program to run? Thanks.


texts:
I recently traded BTC for 1 Ether using shapeshift.io

The transaction was successful, but there is no record of Ether in my local account.

Here is the tx reference.

I fear that I have made a mistake, transferring into a account on Testnet, instead of the main network - but can't find any literature on whether my hunch is true.

More info:

My Ethereum Wallet is the latest build (0.5.2), and all nodes / blocks are synced.

I'm not looking to build any apps for the moment, I'm merely interested in investing in the currency by holding Ether. If what I did was incorrect, what should I be doing instead?

If it makes any difference, the generated avatar displayed on the account is exactly the same as the one in my local account.

tl;dr: Purchased Ether using a account generated on testnet, but it's not reflecting locally. How to import an account from testnet?


texts: Unable to see Rinkeby balance in Geth console

texts:
I set up a node on the Rinkeby test network and connect to it with the following command.
geth --rinkeby

Once this is up and running, I connect to the corresponding console with
geth --rinkeby attach

I already created an account and requested Ether to it via faucet.rinkeby.io. Also I checked, that this account has the correct balance via rinkeby.etherscan.io.
My problem is, that I cannot see that balance when using the geth console connected to Rinkeby. I am using the following command in order to check the balance, which always retrives 0.
eth.getBalance("myAccountsHash")

Many previous post assume, that the reason for this is, that I am out of sync with the network. But I am not, according to this info (my account received Ether during block 7903687):
> eth.syncing
{
  currentBlock: 7904237,
  highestBlock: 7904364,
  knownStates: 29412402,
  pulledStates: 29392902,
  startingBlock: 7904202
}

So why do I not receive the correct balance for this account in the geth console?
What is strange is, that while above indicates, that I am nearly in sync with the network, when I execute the following, I receive 0.
eth.blockNumber


texts: Type Error : contract " erc20interface " should be marked as abstract

texts:
Code :
contract ERC20Interface {
    function totalSupply() public view returns (uint);
    function balanceOf(address tokenOwner) public view returns (uint balance);
    function allowance(address tokenOwner, address spender) public view returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);


texts: A byte array with super large size : is this practical in Solidity?

texts:
I want to store cells of an Excel file with 94 rows and 104 columns (it means 9776 cells!) in a byte array as follows :

I define my array as follows :

struct StateStruct {
        bytes32 description;
        mapping(bytes32 => bytes32) sub_state;
    }

    struct ObjectStruct {
        StateStruct state;
        address owner;
        bool isObject;

        bytes32 review;
    }

    mapping(bytes32 => ObjectStruct) objectStructs;
    bytes32[] public objectList;

bytes32[9776] ExcelFields = [bytes32("cell_1"),bytes32("cell_2"),bytes32("cell_3"), ... , bytes32("9776")]; // !!! How can I do this ? and How long does it take ?

function setExcelCell(bytes32 _id, bytes32[9776] cell_values, address _owner) public returns(bool success) {
        require(!isObject(_id));

        uint256 counter=0;
        for(counter; counter < 9776; counter++) {

            objectStructs[_id].state.sub_state[ExcelFields[counter]] = cell_values[counter]; // cell_values[counter] may be "true", "false" or other value.

        }

        return true;
    }

According to answer and comment of User "AnAllergyToAnalogy" I defined also following "alternative function" :

mapping(uint => mapping(uint => bool)) myNestedMapping;

setMyNestedMapping(bytes32 column,bytes32 row,bool[9776] value) public returns(bool success) {

uint256 counter=0;
uint256 i=0;
uint256 j=0;
        for(i; i< 9776; i++)
            for(j; j< 9776; j++){

            myNestedMapping[i][j] = true;

        }

return true;
}

You can see a screen shot of this Excel file here : Excel File Screen Shot

You also can download this file from here : http://www.filedropper.com/usecase5heatpumpomplan

And in parallel, I'm going to save the hash of this file in a byte array or by an event.

However, in general, I am not sure my strategy for designing and developing such a Smart Contract is correct and logic ? or I'm going totally wrong ?

**

  Important Note : Is it possible to use IPFS for this purpose ?  and
  can it help us ?

**


texts: How to pass arbitrary bytes to a function (2016)

texts:
I'm trying to implement a contract which will store bytes blob, a dynamic bytes array.

For example I have following struct:

Sign {
    address signer;
    bytes16 signType;
    bytes   sign;
}

plus an event:

event Signed(
    bytes16 signType,
    bytes sign
);

and trying to set it:

function addSignature(byte16 signType, bytes sign) {
    // ... store data
    ... = Sign(msg.sender, signType, sign)
    // raise event
    Sign(signType, sign);
}

The problem that I can't find a way to pass bytes to the function from Javascript.

I'm using Truffle, and tried following Javascript code:

var type = web3.fromAscii('test', 16);
var sign = [0x12, 0x34]; //also tried web3.toBigNumber('0x1234');
contract.addSignature(type, sign, {from: myAccount, gas: 2000000});

it makes a transaction, but I don't see correct value stored into my contact. For example by listening to Signed event I see that there're an empty array. If I try to read data, I got zeros (actually it's more weird, I get signType padded with long array of zeroes).

What is a proper way to use arbitrary bytes array? hot to send to contract, how to read?

PS I'm using Truffle with TestRPC.


texts: Private ethereum blockchain without ether

texts:
New to Blockchain and Ethereum technology here so forgive me if this has been asked before, however I can't seem to find anything on it.

Effectively I am looking a creating a new contract and a private ethereum block chain for a research project and was wondering if it was possible to create a private smart contract and block chain and run it without ether?


texts:
i trying to deploy an token on remix and i got this error message:

CompilerError: Stack too deep, try removing local variables. -->
bestTokenEver.sol:1027:80: | 1027 | (uint256 rAmount, uint256
rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee,
tLiquidity, tCharity, tTeam, _getRate()); | ^^^^^^^

function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
    (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tCharity, uint256 tTeam) = _getTValues(tAmount);
    (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, tCharity, tTeam, _getRate());
    return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity, tCharity, tTeam);
}

i dont really understand why i got this error message. is one of the lines maybe to long and how can i fix it?
hope you can help me
edit:
the solution from other post dont works here:
// Helps to avoid "Stack too deep" in swap() method
function _fromToken(bytes memory data) internal pure returns(IERC20 token) {
assembly {
token := mload(add(data, 36))
}
}
// Helps to avoid "Stack too deep" in swap() method
function _destToken(bytes memory data) internal pure returns(IERC20 token) {
assembly {
token := mload(add(data, 68))
}
}


texts: why am I getting this error : Fatal: Error starting protocol stack: datadir already used by another process

texts:
I was trying out on creating a private ethereum network by following this link .
However the first connection took too long so I uninstalled it and reinstalled it again.
However when I try to run geth .exe I get this error message:

  WARN [01-16|09:29:36] No etherbase set and no accounts found as
  default Fatal: Error starting protocol stack: datadir already used by
  another process


texts: How to verify token after etherscan, and submit icon

texts: Sorry, my English is not good, I verified my token on etherscan, but I do not know how to change the token's icon.


texts: Current Mist is 0.8.5 and it runs geth 1.4.17. How can I initial geth 1.5.0 by Mist 0.8.5 without manually start Geth 1.5.0 first ? It's all to do with instruct geth that chaindata is on an external storage by issue --datachain option and bypass the default location if started with Mist.


texts:
I'm trying to send a transaction into testnet from an account having a balance of 516,561,000 Babbages. According to my calculations, this is exactly the cost of the transaction to perform. Nevertheless result is always "Insufficient funds for gas * price + value".

This is the transaction I want to send:

eth_sendTransaction: [{
    "from": "0xa7e3c7c227c72a60e5a2f9912448fb1c21078769",
    "to": "0x6861973632a44775a0dae132ef4578a95fcebd6c",
    "value": "1000000000",
    "gasPrice": "20000000000",
    "nonce": "0x100000",
    "data": "0x4d61726b65745061792e696f202d2041756469744c6f673a204175646974206c6f672074782066726f6d206a75616e20746f20616c656a616e64726f206f662031206575726f73"
}]

result => Insufficient funds for gas * price + value

This is the estimated gas calculation for this transaction:

eth_estimateGas: [{
    "from": "0xa7e3c7c227c72a60e5a2f9912448fb1c21078769",
    "to": "0x6861973632a44775a0dae132ef4578a95fcebd6c",
    "value": "1000000000",
    "data": "0x4d61726b65745061792e696f202d2041756469744c6f673a204175646974206c6f672074782066726f6d206a75616e20746f20616c656a616e64726f206f662031206575726f73"
}]

result => 0x64e4 // gasEstimated = 25828

And this is the medium price of the gas:

eth_gasPrice: []

result => 0x4a817c800 // 20000000000 (gasPrice medium = 20,000 Babbages)
)

So,

  txFeeEstimated = gas * price = 516,560,000 Babbages

  Minimal funds = gas * price + value = 516,561,000 Babbages

And according to https://testnet.etherscan.io/address/0xa7e3c7c227c72a60e5a2f9912448fb1c21078769

The ETH Balance is 0.000516561 Ether

Why the error? Is not balance = gas * price + value in this case?


texts: Difference between rinkeby.etherscan and etherscan alone

texts:
Which is the difference between both?
Both are useful to have the own ethereum tokens or someone is better than other.
Can someone explain??


texts: Deploying a contract web3 error: invalid argument 0: missing 0x prefix for hex data


texts: Proper way to fire smart contract function passing an array with web3js

texts:
I'm using web3js version 0.20.7

The smart contract originally had a function (called whiteListAddress(address _address, bool value) ) that took an address and a boolean value, which was called like this in the js code:

var getData = Coursetro.whiteListAddress.getData(whitelistaddress,1);
        const paymentAddress = '0x...'

          web3.eth.sendTransaction({
          to: paymentAddress,
          gas: 6000000,
          data: getData,
          value: web3.toWei(0, 'ether')
        }, (err, transactionId) => {
          if  (err) {
            console.log('whitelist failed', err)
            //$('#status').html('Payment failed')
          } else {

         console.log('whitelist successful', transactionId)
            //$('#status').html('Payment successful')

            }
        })

This worked just fine, but i was required to add a function that did this process for a bunch of addresses, so I made a function which takes an array instead, like this bulkWhiteList(address[] _addresses, bool value)

I'm calling it the same way (obviously, wWallet is an array of wallets):

var getData = Coursetro.bulkWhiteList.getData(wWallet,1);
web3.eth.sendTransaction({
          to: paymentAddress,
          gas: 6000000,
          data: getData,
          value: web3.toWei(0, 'ether')
        }, (err, transactionId) => {
          if  (err) {
            console.log('whitelist failed', err);
            console.log(wWallet)
            $('#status').html('Transaction failed');
          } else {

         console.log('whitelist successful', transactionId)
            $('#status').html('Transaction sent')

            }
        })

The function fires and the transaction is confirmed, but when it seems at some point the array is broken and the wallets don't show in the appropiate format, since in etherscan this is what is being passed apparently:

but when i print the array in my console this is what i see:

So, to summarize, what is the problem with the array I am passing? Or is there something else that i'm doing wrong?

-- EDIT --------

Just tried this approach:

Coursetro.bulkWhiteList(wWallet,1,{
          to: paymentAddress,
          gas: 6000000,
          value: web3.toWei(0, 'ether')
        }, (err, transactionId) => {
          if  (err) {
            console.log('whitelist failed', err);
            console.log(wWallet);
            $('#status').html('Transaction failed');
          } else {
              console.log(wWallet);
         console.log('whitelist successful', transactionId);

            $('#status').html('Transaction sent')
            }
        });

got the same result


texts: Possible replay attack when paying to smart contract

texts:
I am afraid of a possible replay attack when paying to a smart contract.
Given these 3 assumptions

An action gas cost may change according to the state of the blockchain (even if its the same action).
If I payed to some smart contract (that I didnt created myself), and it run out of gas, I need to retransmit the same funds in a new transaction, with a higher gas price and the next nonce.
If an action runs out of gas, it may be re-added to the blockchain and run without running out of gas

Assuming all of those actions, a reply attack is possible!
(I understand that waiting for many blocks to avoid forks is a possibility... but it just sounds like a very partials solution)

Any insights?

===EDIT===

Pseudo code of the problem

tx1={from=me, to=contract, nonce=10, gas limit=100'000,...}
Send (tx1)
tx1 run out of gas (needed 100'001 gas..)
tx2={from=me, to=contract, nonce=11, gas limit=200'000,...}
Send (tx2)
Blockchain fork occurred, and tx1 revaluated and tx 1 now approved
tx2 approved too

Doable spend occurred


texts: TypeError: Address  must be provided as a string [web3.py]

texts:
I am trying to call a function using web3.py. I am looking to call transact on a funciton call using my account, however I'm running into some issues.
from web3 import Web3
from eth_account import Account

acct = Account.from_key(PRIVATE_KEY_HERE)
erc20 = w3.eth.contract(address=erc20_address, abi=erc20_abi)
erc20.functions.approve(spender, amount).transact({'from': acct})

I keep getting this error:
TypeError: Address <eth_account.signers.local.LocalAccount object at 0x7fc0780ad040> must be provided as a string

It looks like this person had the same error.


texts: Why do MakerDAO auction keepers overpay for ETH?

texts: Looking at a recent closed auction (https://defiexplore.com/liquidation/ETH/4876), I see that the auction keeper overpaid for too little ETH. Why?


texts: Explanation on why I need an address, a pool and a wallet

texts:
I am very new to this world so this is a very newby question but as much as I have searched there don't seem to be any newbie getting started guide that spells this stuff out.

I am trying to setup my machine as a miner.

I have downloaded Geth and have used it to create an address.

I have kept a copy of the address file somewhere safe so that I can't lose it (and the password for my address).

Apparently I need to mine to a pool - is this necessary? Can't I just mine to my address?

To get money from the pool apparently I need a wallet. Why can't I just transfer money from the pool to my address?

I get another json file and a must-never-lose password for the wallet as well.

Can someone explain when I need my address file and password and when I would need my wallet address and password?

If I want to give my address to someone to receive funds do I give them my address or my wallet address?

Thanks


texts:
So I just started mining and dont know that much.
I use lolminer (windows version)
and have set it up like this:
set "POOL=eth-eu.sparkpool.com:3333"

set "WALLET=0x4D6E##################32249B80A0.sp_*****"

Where # I just omitted the characters of my wallet and * my sparkpool worker's name (copy pasted it from their site no spaces)
The miner seems to work,doing its thing showing shares and hashrates of my GPUs
But its been like three hours now and on my income at my sparkpool account everything is 0
On the site it says it will update within 5 to 10 minutes...
Does it work ? I mean that everything is ok and it just shows 0 because I didnt contribute anything yet? (lolminer runs for 3 hours nonstop @ about 80Mh/s and is still running as I type this)
or did I forget to set something up? Maybe I need to delete my wallet since it is a share pool and I dont solo mine ? but then what do I enter on the "set Wallet=" field?
Sparkpool is chinese and doesnt have much of a documentation non that I can find of.. it just lists that as a rigID I should put sp_myworker'sname.1234
what is that 1234? when I created the worker it did not ask me to enter a pin for it or a pass... Should I put my sparkpool account password there instead?
like set "WALLET=0x4D6E##################32249B80A0.sp_*****.sparkpoolpassword" ?
P.S I also checked my wallet app associated with the wallet string above and it shows 0 too


texts: My address is no longer listed in cpp-ethereum's eth. How do I access my wallet/account?

texts:
Context

I'm using Ubuntu 14.04 LTS. I cloned the cpp-ethereum repo and built everything using the makefiles. Now (in the same path) I have a bunch of executable binaries in folders such as eth, ethkey, and ethminer.

To quote the ethdocs: Creating a key is tantamount to creating an account. Therefore, I'll assume the following terms are all equivalent and I'll use them interchangeably: wallet, account, key, keyfile, keystore. (Please, correct me if I'm wrong.)

So I went ahead and created a so-called "account" using eth:

./eth account new

This listed 3 things:

A created key, starting with ef9a8d59
An ICAP, starting with XE240BF3
An address, starting with 00134f5f

Additionally, I had to create

A password

Then I ran ./eth account list and I saw my account's address. Sweet.

To quote the go-ethereum wiki: If you lose the password you use to encrypt your account, you will not be able to access that account. Repeat: It is NOT possible to access your account without a password and there is no forgot my password option here. Do not forget it.

So I assumed having these 4 data (especially the password) were equivalent to having total access to my account, and that they were all I'd ever need to access my Ether from anywhere (say, if I purged the disk did a fresh install of Ubuntu).

Problem

Fast-forward a few weeks, and today I'm trying to transfer my funds using eth. However, my old account is no longer listed when I run ./eth account list.

So I try running

eth account import <my_address>

but I get

  ✘  03:07:08 PM.525|eth  Invalid JSON in key file
Error: reading key file failed

Besides, I don't see any "keyfiles" lying around in the cpp-ethereum path.

Questions

How can I "add back" my account/wallet/address to eth? What data do I need?
How can I "add" my account/wallet/address to the Ethereum Wallet GUI application (using eth, if possible)? I only see options for "Create new account" and "Import pre-sale accounts". What data do I need?
Please ELI5 how wallets/accounts/keyfiles/keys/keystores work. Are these terms equivalent?
What data allows one to have total access to one's account from anywhere, anytime? Eg. I see some wallet applications (such as the GUI one) generate "keyfiles" (actual files on one's computer that look like Python dicts / JSON), but there seems to be no universal/canonical representation of an Etherem wallet. Are those "keyfiles" the absolute master key to one's account?
How can I take the funds in my account and convert them to bitcoin?


texts:
I sent yesterday a couple of transactions from IDEX to myetherwallet, they are accepted and being mined. However, it was the 1st time I used it and I think I set up a very low gas price (12, the one suggested by IDEX), and over 5M blocks only 5000 have been mined in 8 hours.

Is there a way to cancel it and resend it with more gas? If I go to IDEX I actually see that amount of tokens on myetherwallet so maybe I could make a deposit again on IDEX and send it back again?

Many thanks


texts: Error starting protocol stack: chaindata file exists

texts:
I'm trying to start geth from the terminal in Ubuntu 16.04 LTS. I've already done it several times before, but now I'm getting the following error message:

INFO [08-21|12:34:05] Starting peer-to-peer node               instance=Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1
INFO [08-21|12:34:05] Allocated cache and file handles         database=/home/titog/.ethereum/geth/chaindata cache=128 handles=1024
Fatal: Error starting protocol stack: mkdir /home/titog/.ethereum/geth/chaindata: file exists

The chaindata is supposed to exist. How can I fix this issue and run geth?

My chaindata directory is a symbolic link to another directory in another disk, but this shouldn't be a problem because it worked before.


texts: Remix Error - Trying to Follow Ropsten Faucet Instructions

texts:
I have been trying to get testnet Ethereum from Ropsten using Metamask wallet but instead I am getting errors. What am I doing wrong?
Here is what the Ropsten Faucet site said and the error on Remix
https://imgur.com/FQ7hgFd
Does anyone know an easier way to connect Ropsten to Metamask?


texts:
I posted a question 1 day ago asking if it was possible to have multiple coin types in a single contract and I am trying to implement the answer I received.

Is it possible to have multiple coin types in one contract?

The answer said to use nested mappings which works perfect for me, but I can't have:

mapping string => mapping (address => uint)) coinBalanceOf;

because it generates an error "Accessors for mapping with dynamically-sized keys not yet implemented"

So I am trying to find a way around this so that I can have multiple coin types in a single contract but allow the user to specify a string as the coin type when they use the transfer function in my contract instead of an integer.

For example here was the answer code from my last question:

contract token {
  mapping (uint => mapping (address => uint)) coinBalanceOf;
  event CoinTransfer(uint coinType, address sender, address receiver, uint amount);

  /* Initializes contract with initial supply tokens to the creator of the contract */
  function token(uint numCoinTypes, uint supply) {
    for (uint k=0; k<numCoinTypes; ++k) {
    coinBalanceOf[k][msg.sender] = supply;
  }
}

/* Very simple trade function */
function sendCoin(uint coinType, address receiver, uint amount) returns(bool sufficient) {
  if (coinBalanceOf[coinType][msg.sender] < amount) return false;

  coinBalanceOf[coinType][msg.sender] -= amount;
  coinBalanceOf[coinType][receiver] += amount;

  CoinTransfer(coinType, msg.sender, receiver, amount);

  return true;

}

When creating this contract it takes the number of coin types and uses that to create a nested mapping of addresses so it contains "1, 2, and 3" and the user can specify which type they want to transfer and how much they want to transfer.

What I want is for the user to be able to say they want to transfer "Type 1" instead of just specifying "1" under the coin type. I want to do this because in example I used Coin Type 1, Coin Type 2, etc but in reality they aren't going to be named like that and the user won't know the index number associated with each coin type.

My initial thought was to have something like this:

contract token {
  string[] public assets = [
    'Coin 1',
    'Coin 2',
    'Coin 3'
  ];

  mapping (uint => mapping (address => uint)) public coinBalanceOf;
  event CoinTransfer(string coinType, address sender, address receiver, uint amount);

  function token(uint256 initialSupply) {
    if (initialSupply == 0) initialSupply = 1000000;

    uint length = assets.length;

    for (uint k=0; k<length; ++k) {
      coinBalanceOf[k][msg.sender] = initialSupply;
    }
  }

  function sendCoin(string coinType, address receiver, uint amount) returns(bool sufficient) {
    uint Index = getIndex(coinType);

    if (coinBalanceOf[Index][msg.sender] < amount) return false;

    coinBalanceOf[Index][msg.sender] -= amount;
    coinBalanceOf[Index][receiver] += amount;

    CoinTransfer(coinType, msg.sender, receiver, amount);

    return true;
  }

  function getIndex(string coinType) {
    for(uint i = 0; i<assets.length; i++){
      if(coinType == assets[i]) return i;
    }
  }
}

But I get an error when trying to call the getIndex function "Not enough components (0) in value to assign all variables (1)." and I'm not sure where to go from here.

Any help is greatly appreciated!


texts: Why does f2pool mine almost empty blocks despite large amount of pending txs with 50GWei gas price

texts:
We currently (2017-06-21) have a constant large load of pending txs (over 10k on Etherscan). Many of these transactions seem to have 50GWei gas price. Despite that, the f2pool which ethgasstation http://ethgasstation.info/ reports to accept down to 1GWei gas prices, mines blocks with only very few transactions.

Examples:

https://etherscan.io/block/3908819
https://etherscan.io/block/3908816
https://etherscan.io/block/3908814
https://etherscan.io/block/3908809

What could be a motivation for that? They seem to constantly forgo about 0.2 ETH that other miners make more by filling up the blocks.


texts: GETH - Anything i can do to get Blocks faster/better?

texts:
Hi had Variance over 200% and dont get a block for over 2 Hours...

Is there anything i can do, to make the Chance higher to get a Block on Geth?

Like i can say he must use 100% RAM or more CPU Threads or anything on my Server?
I see one Site, using other coin but Ethereum Blockchain and running geth, who is saying info:Running on 100% RAM Disk .

What is this?


texts: Is it possible to connect remix and Parity?

texts: I would like to connect remix to a parity node running on my machine. Even if I am setting up parity with the --rpc or --jsonrpc switch, I cannot connect. Is it even possible? Thanks!


texts: ParserError: Expected token Comma got 'SubEther'

texts:
I am having trouble with this parse error when I compile the abi.  I want to be able to add the argument that gets passed into the function to the workdone. However when I try to do that I get a parse error. If I hardcode in a number then it compiles without issue.  Any help?

doesn't compile

function test1(address addr1, uint8 num) nonReentrant external {
    for (uint8 i = 0; i < num; i++) {
       //do the thing
    }
    workDone[msg.sender] = workDone[msg.sender].add(uint256(num ether));
}

compiles fine

function test1(address addr1) nonReentrant external {
    for (uint8 i = 0; i < 10; i++) {
       //do the thing
    }
    workDone[msg.sender] = workDone[msg.sender].add(uint256(10 ether));
}


texts: How to find keys mapped to valid values in a given range (n_start, n_end) at runtime?

texts:
My question is related to finding keys mapped to valid values in a given range (n_start, n_end) at runtime using minimum gas, if possible.

mapping(uint => myStruct) clusterContract;

uint contains the block number on the blockchain. So this may be in between 0 and  1,000,000 and keep increases. Based on client's behaviour new mapping will be generated but there may be some empty spots, for example exiting mappings as follows:

clusterContract[0]    = structA;
clusterContract[1001] = structB;
clusterContract[1002] = structC;
clusterContract[1003] = structD;
clusterContract[1100] = structE;
clusterContract[2000] = structF;
clusterContract[7999] = structG;
clusterContract[8001] = structH;

Following answer says that:

  Unfortunately not. A mapping just matches a key to a value. It doesn't
  have a list of either per se.

At this point, for example: I just want to reach structs that pointed from valid keys in between 1000 and 8000, which should be 1001(structB), 1002(structC), 1002(structD), 2000(structF) and 7999(structG).

In order to do that only solution I have come up with is to iterate through all elements from 1000 to 8000 and check that each block number valid key or not and if it is valid do the operation I want to:

for(int i=1000; i++; i<8000) {
    if( clusterContract[i] ) //check whether key exists. I could not figure out how to check key exists or not.
       clusterContract[i].StructX.val = 64; //or do something else.
}

[Q] As you can see, I need to iterate through 7000 values to check if their keys are valid or not. Is this a suggested solution, where gas usage might be inefficient since I need to do 7000 if then or more if the range increases? Any recommended solution would be very appreciated. Please note that Binary Search Tree might be a good solution but again larger the tree, there would be inefficient gas for adding new nodes or searching within the tree.

=> Or if I remove the key validity check (whether key i exists or not), when this code piece is converted into lowest level code piece (Ethereum Virtual Machine code) by Solidity, would nonexisting keys be ignored automatically, since they don't exist? Hence only valid keys will be considered and it won't iterate through 7000 items.

for(int i=1000; i++; i<8000)
   clusterContract[i].StructX.val = 64; //only existing keys are updated.

Thank you for your valuable time and help. I am sorry if there is grammar mistakes, I did my best to explain this problem with some examples.


texts: Why hasn't the gas price decreased since it's large raise in value?

texts: I remember ETH being at $90 USD and now it's at $175 USD however still gas price is still at 20 gwei? Can anyone explain this?


texts:
I red over ethash source code and saw this code:

func CreatePoW(config *Config) (pow.PoW, error) {
    switch {
    case config.PowFake:
        glog.V(logger.Info).Infof("ethash used in fake mode")
        return pow.PoW(core.FakePow{}), nil
    case config.PowTest:
        glog.V(logger.Info).Infof("ethash used in test mode")
        return ethash.NewForTesting()
    case config.PowShared:
        glog.V(logger.Info).Infof("ethash used in shared mode")
        return ethash.NewShared(), nil
    default:
        return ethash.New(), nil
    }
}

What does shared mode mean? And when is ethash in shared mode?


texts: How to convert a uint to bytes in Solidity?

texts: Is there an easy way to convert a uint to bytes in Solidity?


texts: If every node executes the transaction, who collects the transaction fees?

texts: I read here -- On which node smart contract get executed taht once your smart contract gets incorporated into the Ethereum network, every node on the network will execute that contract (done to prevent someone from cheating and claiming it required more gas than it did).  However if everyone is executing the contract, who is receiving the transaction fees?  Please let me know what fundamental things I'm missing here.


texts: How does ecrecover() in solidity work? Looking at ethervm.io there doesn't seem to be an opcode for ecrecover? To what bytes is a ecrecover() call compiled?


texts:
My struct:
struct ContractInfo {
    address contractAddress;
    string name;
    string version;
}

Function:
function getContractInfo(bytes32 contractHash) public view returns (address contractAddress, string name, string version) {
    ContractInfo storage contractInfo = contracts[contractHash];
    return (contractInfo.contractAddress, contractInfo.name, contractInfo.version);
}

When I try to run function in truffle console I get this result:

truffle(test)> ContractRegistry.deployed().then(function(i){cr = i})
truffle(test)> cr.getContractInfo("a66258df673fb6a40d8868da50898ad3db8ba197dcfcd3b370bde7cb93c7d500")
[ '0x6433623337306264653763623933633764353030', '', '' ]

Remix shows correct:

0: address: contractAddress 0x1Aab044DB8d37979d3180B40F2171E8bd4a8eca9
1: string: name ContractToBeStored
2: string: version 1.0

How can I read multiple values in console?


texts: Upgraded to geth 1.5.0: Bad block #383792

texts:
Recent Hardfork #4 Spurious Dragon has forced me to upgrade the geth node to last version.

After upgrading geth node to version 1.5.0 and reseting all blockchain data, to start from scratch, I got the following fatal error using testnet:

E1121 16:21:27.722211 core/blockchain.go:1212] Bad block #383792 (0x114aa8935ec9c308bdddd52030f096801be916e69b1b5db49aa87112472775eb)
E1121 16:21:27.722249 core/blockchain.go:1213]     gas used error (1554920 / 3141592)

This is the command line used to lauch geth:

./geth --rpc --testnet

Any ideas how to fix it? Is that a bug on 1.5.0 version? Thx!


texts: how much gas does an erroneous transaction consume?

texts:
Lets say, a transaction produced an error, for example, r,s,v fields are invalid. Will this transaction use the gas?

Looking at the sources, I see that it doesn't, it returns nil in consumed gas on error (third line, after tx.AsMessage() fails), but after doing some tests, I see it consumed the gas limit on the account balance in the statedb, so it isn't clear for me how much gas does an invalid transaction take (or should take)?

// ApplyTransaction attempts to apply a transaction to the given state database
// and uses the input parameters for its environment. It returns the receipt
// for the transaction, gas used and an error if the transaction failed,
// indicating the block was invalid.
func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, cfg vm.Config) (*types.Receipt, *big.Int, error) {
    msg, err := tx.AsMessage(types.MakeSigner(config, header.Number))
    if err != nil {
        return nil, nil, err
    }
    // Create a new context to be used in the EVM environment
    context := NewEVMContext(msg, header, bc, author)
    // Create a new environment which holds all relevant information
    // about the transaction and calling mechanisms.
    vmenv := vm.NewEVM(context, statedb, config, cfg)
    // Apply the transaction to the current state (included in the env)
    _, gas, failed, err := ApplyMessage(vmenv, msg, gp)
    if err != nil {
        return nil, nil, err
    }

    // Update the state with pending changes
    var root []byte
    if config.IsByzantium(header.Number) {
        statedb.Finalise(true)
    } else {
        root = statedb.IntermediateRoot(config.IsEIP158(header.Number)).Bytes()
    }
    usedGas.Add(usedGas, gas)

    // Create a new receipt for the transaction, storing the intermediate root and gas used by the tx
    // based on the eip phase, we're passing wether the root touch-delete accounts.
    receipt := types.NewReceipt(root, failed, usedGas)
    receipt.TxHash = tx.Hash()
    receipt.GasUsed = new(big.Int).Set(gas)
    // if the transaction created a contract, store the creation address in the receipt.
    if msg.To() == nil {
        receipt.ContractAddress = crypto.CreateAddress(vmenv.Context.Origin, tx.Nonce())
    }

    // Set the receipt logs and create a bloom for filtering
    receipt.Logs = statedb.GetLogs(tx.Hash())
    receipt.Bloom = types.CreateBloom(types.Receipts{receipt})

    return receipt, gas, err
}


texts: Looking for specific kind of smart contract for my token

texts:
I am playing around with ERC20 token creation.
Created one using this tutorial - https://www.youtube.com/watch?v=-Nje9ucd5rY
Now I want to be able to :
-Give away tokens. For example, when buyer deposits one dollar to me, I give one token to buyer.
-Generate any amount of tokens
-Burn any amount of tokens
-Transfer to given addresses
-Receive tokens on my address
As I understand, I need to find a smart contract which does that. Where can I get this kind of smart contract?


texts: getting error in transferring the erc721 token from contract to other EOA

texts:
i am trying to build  market place, where user can  sell and buy unique products. sell() function is working fine  in which erc721 token is minted and transferred to contract , but when some one call buy() function, transaction   get failed

import "ERC721.sol";
import "ERC721Holder.sol";

contract NftMarket is ERC721, ERC721Holder{

    // store the address of the sellers
    address [] public Sellers;

    // store the list of item that has been listed for the sale
    string [] public Item;

    // list of bidding done by buyer
    Bid [] public bid;

   // tokenId
    uint public Counter = 999;

    // tell the state of item
    enum State { available, sold

    }

    // detail of the bid
    struct Bid{

        address bidder;
        uint time;
        uint price;

    }

    // mapping of item --> bid
    mapping(string => Bid) item_to_bid;

    // mapping of item --> price
    mapping(string => uint) Price;

    // mapping item --> state
    mapping(string => State) public state;

    // mapping item --> seller;
    mapping(string => address ) item_to_seller;

    // mapping seller --> tokenId
    mapping(address => uint) seller_to_tokenId;

    constructor() ERC721("yART", "yART") public{

    }

    function sell(string calldata item, string calldata _uri) external payable{

        // cases of checking item id , prevent listing  of same product

        _mint(msg.sender, Counter);
        _setTokenURI(Counter, _uri);
        state[item] = State.available;
        item_to_seller[item] = msg.sender;
        seller_to_tokenId[msg.sender] = Counter;
        safeTransferFrom(msg.sender, address(this), Counter);

        Sellers.push(msg.sender);
        Item.push(item);
        Counter++;

    }

    function approveAll(address _adr) external{

        setApprovalForAll(_adr, true);
    }

    function bid_On(string calldata item , uint price) external {

        if( price > Price[item]){

                 Bid memory _bid;
                _bid.time = now;
                _bid.price= price;
                _bid.bidder= msg.sender;

                bid.push(_bid);
                item_to_bid[item] = _bid;
                Price[item] = price;

        }

        else{

            revert("price is low ");
        }

    }

    function buy(string calldata item, uint price) external {

        require(state[item] == State.available, "item not available");
        require(price != 0, " price cant be zero");
        require(price >= Price[item], " price is low");
        address item_owner =  item_to_seller[item];
        uint item_id = seller_to_tokenId[item_owner];

       (bool s, ) =    address(this).call(abi.encodeWithSignature
                                ("safeTransferFrom(address,address,uint)", address(this), msg.sender, item_id));
        require(s, "failed");

        state[item] = State.sold;

    }

    function Price_of_item(string calldata _item) external view returns(uint){

        return Price[_item];
    }

}


texts: How do you configure geth to use coinbase?

texts:
I'm a novice.  I'm looking for instructions on how to configure geth so it sends my mined eth to coinbase.

In my head, I think the process is:

Sync the blockchain

geth --datadir /data/ethData --autodag --verbosity 1

wait for it to finish.   Get an ETH address from https://www.coinbase.com/addresses

geth --etherbase '0xa4d8e9cae4d04b093aac82e6cd355b6b963fb7ff' --mine

Profit!

Is that correct?


texts:
I just came across uniswap recently. I know that it is a trade pool of two tokens that get their pricing from being put against each other with people buying one token with the other token as currency, thus creating scarcity and higher values for one and decreasing it for the other.
It is a cool idea and all, but what is it needed for? why do we need these small binary marketplaces


texts: What is the range of the random number generated by this code?

texts:
uint256 seed = uint256(keccak256(abi.encodePacked(
            (block.timestamp).add
            (block.difficulty).add
            ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
            (block.gaslimit).add
            ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add
            (block.number)
        )));
        seed = seed - ((seed / 10000000) * 10000000) + 1;

Is the range of seed 1-100000000, 1-99999999, or something else?