texts: Can I give multiple address parameters to a payable function?

texts:
Newbie here, making my very 1st Smart Contract (a rock/paper/scissors game).
I'm using 0.5.11 because that's what the tutorial I'm learning from is taught in.
I'd like to call my payable placeBet function with 3 parameters:

The wager
The address of Player 1
The address of Player 2

I want Player 1 and Player 2 to send the wager amount to my contract.
But I'm having trouble implementing this.


texts: pyethapp fails to send transactions in a private net

texts:
This question is related to this question but I'm using the pyethapp client instead of web3.js.

I've created two accounts using pyetahpp:

pyethapp account new # 1
pyethapp account new # 2

and then launched pyethapp on a private test net in console mode. I made a transaction:

In [6]: acct_service = eth.services.accounts
In [7]: acct1 = acct_service.accounts[0]
In [8]: acct2 = acct_service.accounts[1]
In [9]: acct1.unlock('')
In [10]: acct2.unlock('')
In [11]:  acct_service.accounts
Out[11]:
[<Account(address=a741c1ad30bfc3d4f16435e9d32ddb31198ed487, id=None)>,
 <Account(address=bdce83daac449aa98446e1a0d3b9f95eff53cf02, id=None)>]
In [12]: tx = eth.transact('bdce83daac449aa98446e1a0d3b9f95eff53cf02', value=100)
In [13]: eth.find_transaction(tx)
Out[14]: {}
In [15]: INFO:pow.subprocess    nonce found
INFO:pow.subprocess sending nonce
In [16]: eth.find_transaction(tx)

In [15]: eth.find_transaction(tx)
Out[15]: {}

Why can't I see the transaction? There is only one node that is running in the testnet and it is also mining. From what I've seen, pyethapp stops mining once launched in console mode (with the --console flag after run).


texts: Retrieving a State_object value on go-ethereum

texts:
I have a deployed contract address and I need to query a contract storage value, a token account balance that is stored on a mapping variable:

mapping (address => uint256) balances;

From go-etherum code, I would like to get that value for a given account avoiding making a call to the contract ( I do not have an EVM reference, just a StateDB reference) so I guess I could retrieve the variable value using the StateDB reference and getStateObject function:

core\state\statedb.go(511): func (s *StateDB) getStateObject(addr common.Address) (stateObject *stateObject)

So, how can I build a stateObject from the contract address, and the variable name (balances) and type (mapping (address => uint256)) ?

Thanks a lot!


texts:
I would like to develop Dapp which aimed to be very responsive. I mean users should not wait until some small operations will be added to the block.
Is this next pattern correct for Dapp?
I'm going to immediate handle user's activity in browser JS code and change UI state regarding user activity.
As I undestand correct my transaction will be added to the ethereum blockchain anyway so I'm not forced to wait until this will happen.


texts: How Geth and Parity knows the global gas limit?

texts:
As said in Péter Szilágyi post DAO Wars: Your voice on the soft-fork dilemma:

  Miners supporting the DAO soft-fork can do so by starting Geth 1.4.8
  with --dao-soft-fork. This will cause the block gas limits to be
  lowered towards Pi million until the deciding block 1800000 (approx. 6
  days from now) is reached. If the gas limit of this block is below or
  equal 4M, the soft-fork goes into effect and (all updating) miners
  will start blocking DAO transactions that release funds.

How does the Geth (or Parity) client knows the current global network gas limit ? I can't see any explorer that shows it except https://ethstats.net/ that only shows some voluntary nodes.


texts: Using B.call gives a warning to check the return status, while b.foo() does not. Why?

texts:
Using .call to invoke a function on another contract,

address B = 0x4a915089aeC328Dac1F0b197Aba7EB8C1853882d;
bytes4 callSig = bytes4(sha3("foo()"));
B.call(callSig);

gives a warning,

  Warning: Return value of low-level calls not used.

using

B public b;

b = B(0x4a915089aeC328Dac1F0b197Aba7EB8C1853882d);

b.foo();

gives no warning.

In what ways does b.foo() know that the call is safe, while B.call(callSig) does not ?


texts:
Let's say I want to airdrop various amounts of an ERC20 token to 10,000 different wallets.

How/Why is a smart contract that handles the airdrop in batches (as described here) is cheaper in gas than 10K singular transactions, each for every recipient?

I mean, the EVM bytecode to run both methods should end up quite the same, doesn't it?


texts: How to detect if a contract has a particular function implemented?

texts:
I would like to detect if an address has a particular function implemented.
 In this case isSafe:

interface ISafe {
   function isSafe() public pure returns (bool _true);
   // other functions I want to call: function doStuff()...
}

contract Foo {

   function foo(address _addr) public {
      ISafe iSafe = ISafe(_addr);

      // this throws... but I'd like it to return a bool instead.
      if (iSafe.isSafe()) {
          // ...
      }
   }

}

I'm finding the above causes a revert error if isSafe is not implemented on _addr.  I'd like, instead, to obtain a boolean value. Is there a way to catch the error?

For my particular use case, it's not even important what the return value is. I just need some way to identify that _addr has some expected function defined.

Note: The solution should not return true if the function is not defined and there is no fallback function.


texts: Why struct are not stored in my smart contract

texts:
I have written a code to add offer in my contract, however, when I compiled the code in the console and I tried to return the number of offer in this contract, I got 0.
PS: I tried this code in the solidity compiler online and  it works well !

pragma solidity ^0.4.9;

contract Offer {

    address public owner;
    struct Offer {
        string title;
        string description;
        uint  offerTime;
        mapping (address => uint) subscribers;
        mapping (uint => address) subscribersAddress;
        mapping (uint => uint) nbrSubscribersPerID;
        uint price;
    }

    Offer[] public  offers;

    // add offer
    function addOffer(string  description1, string title1, uint price1,uint offerTime1)
      returns (uint, string, string, uint, uint) {
        uint offerID = offers.length++;
        Offer o = offres[offreID];

        o.description = description1;
        o.offerTime=offerTime1;
        o.title = title1;
        o.price = price1;
        return (offerID, offers[offerID].description, offers[offerID].title, offers[offerID].price,
          offers[offerID].offerTime);
    }

    //return the  number of offers
    function returnNbroffer() public returns(uint) {
        uint nbr_offer =offers.length;
        return(nbr_offer);
    }
}

I still getting 0 in my console! I replaced public with constant but it doesn't work! I dont know why it works well when I tested it in the solidity compiler online .


texts: Where are finally ethereum event logs stored?

texts:
Hello it's been written many times, but as I observe none of the answers might be the one. I'm interested in the following thing. If in a smart contract I made the event , where will it be stored? in blockchain , if yes, where exactly?if not there, maybe in nodes? I'm building a serious app and i have to store many things there. so i have finally 2 questions.

1) where are logs stored exactly?
2)if in block header, can you describe how i can trust those logs getting in web3.js front-end?


texts: What are some practical considerations for leap seconds?

texts:
From the solidity docs on time units:

  Take care if you perform calendar calculations using these units, because not every year equals 365 days and not even every day has 24 hours because of leap seconds. Due to the fact that leap seconds cannot be predicted, an exact calendar library has to be updated by an external oracle.

If say my contract calculates how much to withdraw based on a delta between two timestamps, should I worry about leap seconds?


texts: geth.ipc is generated while initialising genesis.json file for private net


texts:
I am trying to delete all the players that played a turn in a game.
The contract is not meant to permanently store a list of players, it
simply keeps track of players that have played in the current turn.
Player status is held in a struct, however deleting the struct inside
a mapping does not work. how do I zero the storage(delete) after
each turn. Here is my code:

contract MyGame {
  struct Register {
    bool played;
  }
  mapping (address => Register) players;
  Register Reg;

  function Play {
    players[msg.sender].played=true;
  }

  function SetUp {
    /*this should zero storage before next game*/
    delete Reg;
  }
}


texts:
Just out of curiosity. Let's say I want to run a contracts function that costs 300k gas and I supply only 150k. It will fail but how. The function will stop during 'work' or whole function won't execute.

Cheers!


texts: IPC Connect to Ethereum node running on docker

texts:
I am creating a Ruby client to connect to Ethereum node inside a docker container. So far,

I was able to run ethereum-go inside docker container Then I bash into docker container & able to connect my ruby client using ipc file location .ethereum/rinkeby/geth.ipc

But is there a way I can connect to that docker ethereum node from another container? or else from host computer? Because I want to run my Ruby client in another container


texts: Web3's eth_sign with metamask notification never closes and promise doesn't resolve!

texts:
I'm trying to call web3's eth_sign with metamask's provider, like so

        var signature = await web3.eth.sign(web3.utils.utf8ToHex(randomMsg),acc0)

The metamask windows notification pops up and everything works correctly, I click on Sign and it seems to work since the loading finishes and I'm returned to the list of transactions, but the notification never closes and the eth_sign promise never resolves.

I'm using web3.js version 1.2.4 and the latest metamask. I've tried updating to the 2.0.0 alpha version of Web3 but the same happened.


texts: Formal definition of the EVM as a Turing Machine

texts:
I am trying to understand the EVM in the context of a classic Turing Machine.  I have read through the yellow paper and taken what I can from the internet, but I still feel like I could use some help pinning my question down.

In the paper, they call the EVM "quasi-Turing complete", and I understand this to mean that it is Turing complete as long as there is gas to run a smart contract.  The reasoning behind this is to protect against spamming the network.  However, it seems to me that this also has implications in the halting problem.  It is not that we can detect infinite loops, but we can terminate possible infinite loops if code is running longer than expected.  Is that accurate?

Now, I see where the gas requirement of code execution is a parameter in the exception handling state.  The first one in fact.

  Z(σ, µ, I) ≡ µ_g < C(σ, µ, I) ∨ ...

What I would like to do is boil this down to a formal 7-tuple Turing Machine.

My intuition is to say that the transition function contains a jump to the reject state if an exception state is detected.  So the transition function is something like:  δ : Q × Γ = Q × Γ × {L, R, Reject}?

I could be way off base here.  I guess where I am having trouble is that the gas requirement of running code in the EVM is handled in Exception Halting and not in the Transition Function.  I can't find where the yellow paper unifies state transitions and exception states, other than they say:

  "It is assumed that any transactions executed first pass the initial tests of intrinsic validity"

which I assume they mean they run the exception handling before the state transition.

Is there an accurate way to define the EVM in terms of a Turing Machine?  Are there any TM's or automatas that accurately represent a limited number of state transitions like the EVM?  Is it accurate to say that the EVM is decidable considering it will halt eventually on all inputs?  Any thoughts or comments on my ramblings here would be very appreciated!


texts: Issue in transffering ethers from account to contract

texts:
This is the function I used to transfer the ethets:

function addBalance(address beneficiary) payable returns(bool success){
        if (beneficiary.send(msg.value))
            throw;
        return true;
    }

Call to the function using web3:

contract.addBalance.sendTransaction(contractAddress,
        {from: senderAddress, to: contractAddress, gas:1000000, value: web3.toWei(7, "ether")},function (error, result){
            if(!error){

                } else{
                    console.log(error);
                }
        });

OR

contract.addBalance.sendTransaction(contractAddress,
        {from: web3.eth.accounts[5], to: contractAddress, gas:1000000, value: web3.toWei(7, "ether")},function (error, result){
            if(!error){
                } else{
                    console.log(error);
                }
        });

When I call this It gives error Saying:

Error: authentication needed: password or unlock
at Object.InvalidResponse (errors.js:35)
at requestmanager.js:86
at XMLHttpRequest.request.onreadystatechange (httpprovider.js:118)

I have already unlocked my account
If I change the sender address with address of coinbase it works fine, but not working with any other account address

The call which works fine is bellow :

contract.addBalance.sendTransaction(contractAddress,
        {from: web3.eth.coinbase, to: contractAddress, gas:1000000, value: web3.toWei(7, "ether")},function (error, result){
            if(!error){

                } else{
                    console.log(error);
                }
        });


texts: Cannot verify contracts with libraries on Etherscan

texts:
Since the last week I have not been able to verify contracts on Etherscan if they use libraries. I was able to do this before. Apparently something has changed in Etherscan, Solidity compiler, or related that makes it not to picked up libraries I have linked in.

The contracts without libraries are fine.

What could such change to be? Any workaround (use specific Solidity version, etc.)?


texts: Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested

texts:
function endSuply() public {
    require(msg.sender == admin,"only admin can end the token sale");
    require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))),"balance not transferring");

    selfdestruct(admin);
}

here admin is a state variable declared as address admin;

But the error pops up and doesn't compile !

I just need to disable the contract, how can it be done ?


texts:
How do NFT projects combine their assets with all possible combinations? e.g. Cryptokitties: you have like 10 skin colors, 10 eyes shape ...etc. to combine these assets, you get let's say 10000 combinations, each one is unique.
My question is, which software (if any) can I use to combine specific assets into all possible unique combinations? or do I have to create my own software for that?


texts: Error can't create a new Web3 object on angular

texts:
I've tried on ubuntu, windows with different versions and browsers. web3 1 latest beta:

  WARNING in ./node_modules/asn1.js/lib/asn1/api.js Module not found:
  Error: Can't resolve 'vm' in
  'C:\Users\x\Desktop\backmeapp\node_modules\asn1.js\lib\asn1'

  ERROR in ./node_modules/eth-lib/lib/bytes.js Module not found: Error:
  Can't resolve 'crypto' in
  'C:\Users\x\Desktop\backmeapp\node_modules\eth-lib\lib' ERROR in
  ./node_modules/web3-eth-accounts/node_modules/eth-lib/lib/bytes.js
  Module not found: Error: Can't resolve 'crypto' in
  'C:\Users\x\Desktop\backmeapp\node_modules\web3-eth-accounts\node_modules\eth-lib\lib'
  ERROR in ./node_modules/web3-eth-accounts/src/index.js Module not
  found: Error: Can't resolve 'crypto' in
  'C:\Users\x\Desktop\backmeapp\node_modules\web3-eth-accounts\src'
  ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js Module
  not found: Error: Can't resolve 'http' in
  'C:\Users\x\Desktop\backmeapp\node_modules\xhr2-cookies\dist' ERROR in
  ./node_modules/xhr2-cookies/dist/xml-http-request.js Module not found:
  Error: Can't resolve 'https' in
  'C:\Users\x\Desktop\backmeapp\node_modules\xhr2-cookies\dist' ERROR in
  ./node_modules/xhr2-cookies/dist/xml-http-request.js Module not found:
  Error: Can't resolve 'os' in
  'C:\Users\x\Desktop\backmeapp\node_modules\xhr2-cookies\dist' ERROR in
  ./node_modules/browserify-sign/browser/index.js Module not found:
  Error: Can't resolve 'stream' in
  'C:\Users\x\Desktop\backmeapp\node_modules\browserify-sign\browser'
  ERROR in ./node_modules/cipher-base/index.js Module not found: Error:
  Can't resolve 'stream' in
  'C:\Users\x\Desktop\backmeapp\node_modules\cipher-base' ERROR in
  ./node_modules/hash-base/index.js Module not found: Error: Can't
  resolve 'stream' in
  'C:\Users\x\Desktop\backmeapp\node_modules\hash-base'


texts:
When I create my contract on remix using metamask (injected web3) it asks me to lower my gas fee. Once I lower it (if I don't I can't create it) the contract gets created BUT my variables inside the contract are not initialized. For example a var a = 10; is returning 0.
When I comment out some oraclize functions and lower the gas need then my contract deploys fine. I have no idea what's going on.

I added the code and a screenshot. As I said. Once I started commenting out 'oraclize' function at some point it starts to work just fine...

pragma solidity ^0.4.20;
import "./oraclize.sol";

contract Casino is usingOraclize {
   address owner;
   uint public betAmount = 30 finney; //Equal to 0.01 Ether
   uint public totalBet; //Amount of Ether bet for current game
   uint public numberOfBets; //Total number of current bets
   //uint public maxAmountOfBets = 1 //Maximum amount of bets can be made for each game by each user
   uint public limitAmountOfBets = 3; //Maximum amount of bets for each game
   uint public numberWinner; //Number that won last game
   address[] public players; //Players
   mapping(uint => address[]) numberBetPlayers; //Who bet for which number
   mapping(address => uint) playerBetsNumber; //Number bet by each player

   modifier onEndGame() {
       if(numberOfBets >= limitAmountOfBets) _;
   }

   //constructor - set bet amount and max bets in each game
   function Casino(uint _betAmount, uint _limitAmountOfBets) {
       owner = msg.sender; //set creator of contract to owner

       if(_betAmount > 0) betAmount = _betAmount;
       if(_limitAmountOfBets > 0) limitAmountOfBets = _limitAmountOfBets;

       oraclize_setProof(proofType_Ledger); //arge
   }

   //check if player exists in current game
   function checkPlayerExists(address player) public returns(bool) {
       if(playerBetsNumber[player] > 0) return true;
       else return false;
   }

   //bet function
   function bet(uint numberToBet) payable {
       require(numberOfBets <= limitAmountOfBets); //check if limit has been reached
       require(!checkPlayerExists(msg.sender)); //check that player hasn't bet before
       require(numberToBet >=1 && numberToBet <= 10); //check that the bet is between 1 and 10
       require(msg.value == betAmount); //check that ether send by sender is equal to bet amount

       playerBetsNumber[msg.sender] = numberToBet;
       numberBetPlayers[numberToBet].push(msg.sender);

       numberOfBets += 1;
       totalBet += msg.value;

       if(numberOfBets >= limitAmountOfBets) generateNumberWinner();
   }

   //generate random numbers using oraclize_newRandomDSQuery function
   function generateNumberWinner() payable onEndGame {
       uint numberRandomBytes = 4;
       uint delay = 0;
       uint callbackGas = 200000;

       bytes32 queryId = oraclize_newRandomDSQuery(delay, numberRandomBytes, callbackGas);
   }

   function __calback(bytes32 _queryId, string _result, bytes _proof) oraclize_randomDS_proofVerify(_queryId, _result, _proof) onEndGame {
       assert(msg.sender == oraclize_cbAddress());

       numberWinner = (uint(sha3(_result))%10+1);
       distributePrizes();
   }

   function distributePrizes() onEndGame {
       uint winnerEtherAmount = totalBet / numberBetPlayers[numberWinner].length; //how much each winner will get

       for(uint i = 0; i < numberBetPlayers[numberWinner].length; i++) { //sent ether to addresses
           numberBetPlayers[numberWinner][i].transfer(winnerEtherAmount);
       }

       for(uint j = 1; j <= 10; j++) {
           numberBetPlayers[j].length = 0;
       }

       totalBet = 0;
       numberOfBets = 0;
   }
}

Any help??
Thanks.


texts: What happens to my DAO tokens after the 2016-June Attack?

texts: Are my DAO tokens lost after the 2016-June attack? I understand they might hard fork to return the ether to everyone, but it seems like that would take some time to implement. What if the hard fork does not happen and more people take advantage of this loophole as time passes by?


texts: How to type-cast a function pointer in Solidity?

texts:
I have a function that takes a parameter of type function (uint256) view returns (uint256).

I want to pass it a pointer to a function of type function (uint256) pure returns (uint256).

Obviously there shouldn't be a problem with passing this pure function into a parameter that expects a view function, because the parameter and returns types are the same and pure is even more limiting than view. However, I get this TypeError:

  TypeError: Invalid type for argument in function call. Invalid
  implicit conversion from function (uint256) pure returns (uint256) to
  function (uint256) view returns (uint256) requested.

Things I've tried:

Assigning the function to a local variable gives a similar TypeError:

function(uint256) view returns(uint256) a = func;

  TypeError: Type function (uint256) pure returns (uint256) is not implicitly convertible to expected type function (uint256) view returns (uint256)

The usual type-casting syntax of Solidity gives a ParserError at the function keyword

function(uint256) view returns(uint256) a = function(uint256) view returns(uint256)  (func);

  ParserError: Expected primary expression

-------

I've noticed that the TypeError's keep telling me that the function pointer is not implicitly convertible. Is there a way to explicitly convert it?


texts:
Should I emit Transfer event, when zero amount of Ether or of a token is transferred?

Variants of the answer:

yes
no
both are OK


texts: Truffle and Ganache - do I need to set the same gas-price and gas-limit in both of them?

texts:
Or can I set different values?

If I can set different values, then how will they be used in the system (i.e., what gas-price and gas-limit will apply in every transaction that I execute)?

Here is my present configuration (using the same values for Truffle and for Ganache):

Truffle:

module.exports = {
    networks: {
        development: {
            host: "127.0.0.1",
            port: 8545,
            network_id: "*",
            gasPrice: 100000000000,
            gas: 6721975 // gas limit
        }
    }
};

Ganache:

--port=8545
--gasPrice=100000000000
--gasLimit=6721975

Thank you!!!


texts:
I have a key pair:

The data is encrypted off-chain:

and it is saved into the following smart contract:

contract Foo {
    string data;
}

Can I decrypt stored data on-chain, assuming I provide a corresponding private key?

function decryptData(string privKey){
    ...
}


texts: Any possible threats of making a private key of a testnet (Ropsten) available to public

texts: I'm about to publish a sample Dapp (with source code) and would like to provide an account and its private key available in the source code to make the life easy for anyone trying to use it. This account is created in Ropsten-revival and hence no Ether or any other known valuable info attached to it. I know Ropsten is vulnerable for D/DOS and just wanted to make sure whether I'm exposing myself or the testnet to any unknown dark side.


texts:
I've been using truffle, testrpc and metamask to test my contracts.

Recently I've observed that people are using geth to test deployed contract.

Question: Which one is recommended and better?

Edit:

Is there a huge difference between writing tests to interact with contract using truffle, testrpc and meta mask and writing actual transactions in the real blockchain?


texts:
in many token contracts the amount parameter is called wad

I was not able to make sense what this means or where it comes from. Does someone have a clue?


texts: How to get the internal transaction in Javascript?

texts: I am creating a wrapper for monitoring the transaction of accounts. I am able to trace the transaction which happens between two accounts, whereas if it happens through a smart contract, I cant able to trace it. In etherscan, I can see it in an internal transaction. How to trace the internal transaction in Javascript?


texts: Library calls fail depending on compiler version?

texts:
I'm trying to deploy my library and call it afterwards with the specific address.
While testing this I encountered that the behavior changed over the course of compilers.
I tried to follow How to call a library contract but the following inconsistency happened:
Library 1
pragma solidity 0.7.0;

library Seven {
    function seven() public returns (bool) {
        return true;
    }
}

Library 2
pragma solidity 0.4.6;

library Foursix {
    function foursix() public returns (bool) {
        return true;
    }
}

Main Contract
pragma solidity 0.7.0;
abstract contract Foursix {
    function foursix() virtual public returns (bool);
}

abstract contract Seven {
    function seven() virtual public returns (bool);
}

contract Foo {
    function callfoursix(address a) public {
        Foursix fs = Foursix(a);
        bool b = fs.foursix();
    }
    function callseven(address a) public {
        Seven s = Seven(a);
        bool b = s.seven();
    }
}

notice how Library 1 and 2 are identical besides the used compiler.
When testing in remix Library 1 gets the error:
transact to Foo.callseven errored: VM error: revert.
while the call to Library 2 succeeds.
Why is this the case and how do I call the Library 1 contract?
It does seem that ABI encoding has something to do with it as the newer version is seemingly not found but for the moment I'm clueless.


texts:
I noticed the following behaviour of event Log and wanted to confirm if that was the way it is supposed to work.

Code below.   Function create requires two fields.  I put "require" in place to check if the fields are non-zero and not empty.

If I only input a single field - say "name", it errors out as expected.   I entered a empty field for name and 10 for number as: "",10.   Solidity reads it correctly and identifies which element has the problem.

However - when function "create" errors out, it does not show any of the preceding Log statements within the function.   I was expecting the Logs to be printed sequentially and stop when the failure is detected.

I had the following questions:

When the function fails - does it ignore all the event Logs within the function?   If so, is there another way to run this to show the Logs sequentially for debugging purposes.
When "require" fails:  does it automatically return default (which in this case is false).  This is probably good because we do not have write return statements after every "require" checks.

-

    pragma solidity ^0.4.15;
    contract ABC {
        bytes32 public name;
        uint public number;

        event Log(string _myString);

        function ABC (bytes32 _name, uint _number) public {
            Log("Creating Object");
            name = _name;
            number = _number;

        }
    }
    contract XYZ {

        ABC myABC;

        event Log(string _myString);

        function create(bytes32 _name, uint _number) public returns (bool isSuccess) {

            Log("checking name");
            require(_name != "");

            Log("name valid, now checking number");
            require(_number != 0);

            Log("name and number non-empty, creating a new contract");
            myABC = new ABC(_name,_number);

            Log("new contract created");

            return true;

        }
    }


texts: How to generate thumbnails from IPFS URL?

texts:
I am trying to design a dapp which displays files uploaded to IPFS by a user.
On my web page, I wish to display thumbnails of all the files uploaded by him.
For this, I designed below mentioned EJS file which reads data from a MONGODB.
Inside the docs.url I have saved the complete IPFS URL.

With this approach, I am able to generate thumbnails of image files (.jpeg, .png) types, but unable to generate for .pdf, .xlsx, .doc types.

If someone has applied similar feature, can they please guide in this regards?

Thanks in advance.

        <% docinfo.forEach(function(docs){ %>

                   <img src="<%= docs.url %>">

<%= docs.name %>

                       <a href="/documents/<%= docs._id %>" class="btn btn-primary">More Info

        <% }); %>


texts: Where/how do I do reporting with my Augur REP?

texts:
With ownership of Augur REP comes the responsibility of doing and right to do reporting monthly on outcomes of prediction market entries made on Augur.net.

Where do I go to do this reporting with my Augur REP? Do I have to store my REP somewhere special or how does the reporting system know what I own? I have looked around on app.augur.net and have not found a way to prove I own some REP and then take the assigned reporting.


texts: I tried to install web3 in my mac by using sudo npm install web3 but failed many a times . Please help me to sort this matter out . i am attaching you the exact error that I am facing while running above command.


texts: unable to connect Ethereum node even RPC port: 8545 is open

texts:
I have created my private Ethereum blockchain network. From different servers I am able to connected and added into the network as peer without any problem.

The way I run my server:

geth --targetgaslimit "994712388" --port 3000 --networkid 23422 --identity node1
--verbosity 3 --nodiscover --nat none --datadir="/home/miner/MyEthereumEbloc"
--rpccorsdomain '*' --rpc --rpcaddr "localhost" --
rpcport="8545" --nodiscover --maxpeers=6 --ipcapi "admin,eth,web3" --autodag

As you can see the RPC port is open:

$ telnet localhost 8545
Trying 127.0.0.1...
Connected to localhost.

Inside my geth console:

> admin.startRPC("127.0.0.1", 8545, "*", "web3,net,eth")
HTTP RPC already running on localhost:8545

http://localhost:8545 is the RPC port of my locally running Ethereum node software. But on my browser at http://localhost:8545 I am seeing the following error:

{"jsonrpc":"2.0","error":{"code":-32600,"message":"eof"}}

Inside the geth console, where I run my bootstrap node; I am running the following code in order to communicate to my local node:

var Web3 = require("web3");
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
web3.isConnected()   //returns false

But web3.isConnected() keeps return false.

[Q] I know there is many documentation related to web3 connection to the local node and I have followed all the suggestions. But I am not able the fix the web3 connection problem I am facing. How could I fix this problem? Thank you for your valuable time and help.

I have done the suggestions from following questions:
How to connect a web site to a geth node?, https://forum.ethereum.org/discussion/3414/step-by-step-guide-to-connect-a-web-site-to-a-geth-node, https://gitter.im/ethereum/web3.js/archives/2015/12/31.


texts: Verify multiple state channel signatures in one transaction

texts: What are some ways to verify multiple state channel signatures (using ECverify) in a single transaction?


texts: What time of the day is eth gas fees the lowest to do a smart contract transaction that doesn't cost an arm and a leg? Is there a chart to see this gas fee time zone?


texts: Detect if web3 provider has successfully connected

texts:
I am connecting to local node from browser like:

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

If there is no node running at localhost, I see an error in browser console:

Error: Invalid JSON RPC response: ""

Is there a way to catch this error and provide useful informations to the user?  I have tried adding callbacks to new Web3() and new HttpProvider() calls, but none of them is firing.


texts: How to specify custom test directory path in truffle-config.js

texts:
How do I specify a custom test directory path in truffle-config.js? My test directory is not present at the same level as truffle-config.js, it is residing in a different directory.
Truffle has options to specify custom contracts and migration directory. Similarly, do we have for test directory?


texts: Browser Solidity: What does the "Transaction" tab do?

texts: In Browser Solidity, there's a "Transaction" tab (paper plane icon). You can choose one of two addresses, and a value. But there's no "send" button or anything of the sort. What is this section supposed to do?


texts: Having trouble figuring out Truffle testing with Javascript

texts:
I've started unit testing my contracts with Truffle (using Javascript). I'm fairly new to Truffle and Mocha both, and while I've tried to follow the tutorials, I'm struggling to follow exactly what's going on at each step. For instance, the following test code mostly works, but I get an error at test line 27:

whiteListLength = meta.getWhiteListLength.call();

with the error message: "cannot read property "call" of undefined". The full test is here:

it("should add the correct account to the whitelist", function(){
  var account_one = accounts[0];
  var whiteListLength;
  var isAccountWhiteListed;
  var meta;

  return EMBallot.deployed().then(function(instance) {
      meta = instance;
  return meta.addToWhiteList.call(account_one);
 })

.then(function(){
 whiteListLength = meta.getWhiteListLength.call();//this line is the problem
 return meta.amIWhitelisted.call(account_one);
})

.then(function(response) {
  isAccountWhiteListed = response;

  assert.equal(whiteListLength, 1, "Whitelist should have exactly one member");
  assert.isTrue(isAccountWhiteListed);
 //here comes the assertions
});

for a contract with code:

pragma solidity ^0.4.19;

contract EMBallot {

address[] whiteList;
 struct Proposal {
    uint voteCount;//how many votes this proposal has received
    string description;//what this option is about, what you are voting for
}
 struct Voter {
    bool voted;//if true, has already voted and any further attempts to vote are automatically ignored
    uint8 vote;
    string name;
}
Proposal[] proposals;

address admin; //there should only be one admin per election, this variable stores the address designated as the admin.
mapping(address => Voter) voters;//this creates a key-value pair, where addresses are the keys,
and Voter structs(objects) are the values.

function EMBallot() public{
admin = msg.sender;
}

function getWhiteListLength() constant returns(uint256){
    return whiteList.length;
}

function amIWhitelisted(address myAddress) constant returns(bool){
for(uint i=0; i<=whiteList.length; i++){//iterate over whiteList
if(myAddress == whiteList[i]){//i checked, you CAN use == on addresses
return true;
break;
}
return false;
}}

function addToWhiteList (address voter){
whiteList.push(voter);
}
}

Some of the code has deliberately been omitted for readability purposes, but these functions are the only relevant ones for the purposes of this test.

Sorry if this betrays an elemental lack of comprehension, but can anyone explain to me why these failures are happening? Thanks.


texts:
I'm trying to test the balance of the contract with truffle, but I'm obviously doing something wrong as the test passes.

it("should check balance", function() {
  Lottery.deployed().then(function(instance){
    return instance.balance.call();
  }).then(function(balance) {
    assert.equal(balance, balance - 1, "Balance incorrect!");
  })

What is wrong with the test?

Contract is basically empty.

pragma solidity ^0.4.17;

contract Lottery{
    address public owner;
    uint public fee;
    uint public jackpot;

    constructor() public {
        owner = msg.sender;
        jackpot = 0;
        fee = 1 finney
    }

    //buy ticket
    function buyTicket() public payable {
        require(msg.value == 1 finney, "Incorrect fee");

        jackpot += 1;
    }

    function () external payable {

    }
}


texts:
I'm not sure I fully understand how web3 interacts with the ethereum blockchain. When testing things out, I just use

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

And that allows me to access the test network locally. If I were to deploy this code on a website, what would I set this variable to, and how does that work? And what if that user is not running a local node and interacts with the blockchain through Metamask?


texts: Identify when a smart contract is deployed again in the network

texts:
I would like to automate the response of a Smart Contract from a script. Is there any way to identify when the contract was deployed again in the network to send a response?

UPDATED: If the solution is using events, how is possible to identify from the script of the launched dapp when a contract sends the event if you dont call any function?

Scenario: Dapp running. Contract is deployed again and sends a event to the script. Script should get the event without call any function.

In other words, how is it possible to keep the script "listening" until receiving an event.


texts: Is it possible to find out ETH adress generation time (I have adress and want to find out time of it's creation and if possible also is it was created by exchange)?


texts: I pasted an address from ETC when i sent ETH to my ledger nano s

texts:
I can see the transaction on etherscan.  Is there any way to recover these ether?

Thanks for any help!  If we can recover these I will send one or two for the assistance...


texts: Does each node dynamically connects to its connected nodes' peers?

texts:
I want to give example from private Ethereum network which has 5 nodes, but we can generalize it for much larger network that has thousands of nodes. On the figure double arrows represents connected peers, which they add themselves using addPeer(). Later, Node_1 adds Node_-2 and Node-3 as peers using addPeer() since it only knows enode://pubkey@ip:port of {Node-2 and Node-3} and connects to the network.

[Q1] After that, does Node_1 automatically fetches Node-2 and Node-3's connected nodes's enode://pubkey@ip:port,  which are {Node-4 and Node-5} and dynamically connects to them? and afterwards also fetches Node-4 and Node-5's connected nodes's enode://pubkey@ip:port which is Node-6 and connects into that. This operation could be done recursively. If no, does Node-1 statically remains as only connected to Node-2 and Node-3.

[Q2] This one is connected to first question. If Node-1 cannot fetch the Node-2 and Node-3's connected nodes's enode://pubkey@ip:port and only remain connected to Node-2 and Node-3, after few hours Node-2 and Node-3 shuts down. Does it leads Node-1 disconnects from the network as well?


texts: What are the differences between running a light node and connecting through the metamask server package?

texts:
What are the differences and what has to be considered to decide which approach to take?

What are the benefits and disadvantages of running a full node, instead of one of those two approaches?

By the way, I'm running a server because it needs to interact with the contract. Instead of running heavy computations in my contract, I look for a solution on the server and send it to the contract, which then simply verifies that the sent solution is in fact one.


texts: Issue in executing transaction using testrpc in truffle

texts:
I have created an app using truffle and testrpc.
I have verified the contract functions using truffle console..It worked.
But while executing the transaction from front-end it is getting the following error in the console of testrpc. How can I resolve this error?Is it possible by updating the gasPrice field in truffle.js?

  Transaction: 0x59b171fbc29cf9f89506f3f1a37bd6010863ae773c264e4f349477f1f3a47b71
  Gas usage: 3000000
  Block Number: 25
  Block Time: Fri Sep 29 2017 11:30:31 GMT+0530 (IST)
  Runtime Error: invalid opcode

Any help is appreciated


texts:
Good Evening

I currently mine with my R9 280x and I'm gaining around 13 Mhs on average which is not bad.

Why is my hashrate so unstable? My card runs at less than 60 degrees and it's overclocked to 1.2 Ghz core and 1.6 Ghz mem...

Thanks for answering!


texts: Where to check total circulation of ETH, creation of ETH and supply of ETH?

texts:
Where can I check stats on how many ETH will there be created (what is the limit), how it will reduce in its creation, what are the caps (if any).

I understand that there isn't limited amount like in BTC, so I want to know the process of ETH supply. From what I see, this price has jumped majorly, but for a lot investors it depends how many ETH are mined each day and how will this progress in the future.


texts: Accidentally deployed two identical contracts on blockchain. How can I pick the one I wish to interact with?

texts:
I deployed two identical contracts on the same blockchain.
contract V1   address:0x48A2a37fF1Cff6eB1984aCA7fCA4cAa25B1C9287
contract V2   address:0xdfaDE9c110eBD5C00243Ca0b3AdCf5B73A8f0e42
However I would like to interact with the contract V1 where I already had some data mapped, yet, when using commands in the truffle console terminal it defaults to contacting the contract V2
let smartContract = await contract.deployed()

contract.address always returns 0xdfaDE9c110eBD5C00243Ca0b3AdCf5B73A8f0e42 an address of contract V2
Does anyone here know truffle commands to interact with the contract directly by its address instead of by its deployed name? So I might connect to contract V1 .


texts: `web3.py`: AttributeError: 'Contract' object has no attribute 'eventFilter'

texts:
Update:

For web3 v5.x.x,

Event Log Filters is as follows:

event_filter= myContract.events.<event_name>.createFilter(fromBlock="latest", argument_filters={'arg1':10})
event_filter.get_new_entries()

Goal: I want to print logs of the smart contract, like I do on web3.js, using web3.py.

On web3.js side, following code piece works:

var event = myContract.LogJob({}, {fromBlock:0, toBlock:'latest'});
event.watch(function(error, result) {
  console.log(JSON.stringify(result));
});

But on the web3.py side I was not able to make it work. :( I have followed following documentation.

event_filter = myContract.eventfilter('LogJob', {'filter': {'arg1':10}})

Error I am having:

AttributeError: 'Contract' object has no attribute 'eventFilter'

I have also tried following line of code, but it did not worked as well:

event = myContract.call().LogJob({}, {'fromBlock':100, 'toBlock':110});

[Q] Am I doing something wrong? How could I fix this?


texts: How to connect to different node using geth?

texts:
I have created two instances.One for local server and another for AWS server.

I have install Geth/v1.4.18-stable-ef9265d0/linux/go1.7.1 in local server and Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1 installed in AWS server.

How to connect this two node using geth ?


texts: Who uses the ABI typically? Is it the wallet?

texts: I have seen all kinds of explanations of ABI. But I am still wondering who would use it. As per my current understanding it should be wallet apps using it. Or is it the node app? Can someone please confirm?


texts: Publish a ERC-20 based token in a private chain

texts:
What are the steps to follow if I want to publish a Togen generated token. Into a exchange platform. The goal is something realted to be able to buy my own token with real money, using a platform like Changelly

It´s neccesary to deploy the ERC-20 inherit Token in the MainNet to be able o buy that tokens using real money?

Its posible to manage this operation inside a private chain, instead of the MainNet to not have to pay the GasPrice in ether each time that somebody buy some tokens with real money?

Thanks


texts: Is it good practice to use revert() in case a function does find a match in case of a search?

texts:
This Solidity function:

function findSupplierByName(string supplierName) public view returns (address id, string name) {
    for (uint idx = 0; idx < supplierAddresses.length; idx++) {
        address supplierAddress = supplierAddresses[idx];
        var supplier = suppliers[supplierAddress];

        if (keccak256(supplier.name) == keccak256(supplierName)) {
            return (
                supplier.id,
                supplier.name
            );
        }
    }

    revert();
}

Is this correct ?
Or should I just remove the revert(); statement, so that this function returns a 0 for address and a "" for the name?


texts: geth: view all current contracts on a private testnet?

texts:
How can I query a list of all current contracts with geth?
Is there a way to see the contracts' class names?


texts: Web3j send ether transaction pending forever

texts:
i'm trying to send ether to a smart contract with a specified amount of gas usage, the transaction sending works fine and it propagates to the network but remains pending forever not being executed as i see on rinkeby.etherscan.io.
The code i use is this:

    Web3j web3j= Web3j.build(new HttpService("https://rinkeby.infura.io/ZE3AbqRo2GCvqu1WbY6O"));
    Credentials credentials = WalletUtils.loadCredentials(PASSWORD, WALLET_PATH);
    BigInteger nonce = web3j.ethGetTransactionCount("0x15Ced4F0b7C3fE42D680FD705aE369a9e986EA92",
            DefaultBlockParameterName.LATEST).send().getTransactionCount();

    //Constructing transaction
    RawTransaction rawTransaction  = RawTransaction.createEtherTransaction(
            nonce,
            new BigInteger("300"),
            new BigInteger("50000"),
            "0x5A47C8d694F4edb653Ff50139c91994f492C1d1e",
            new BigInteger("200000000000000000")
    );

    //Signing transaction
    byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
    String hexValue = Numeric.toHexString(signedMessage);

    EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
    String transactionHash = ethSendTransaction.getTransactionHash();

Is there something that i'm doing wrong ?


texts: debug transaction in remix-ide not working

texts:
i want to debug a transaction in remix-ide, connected to my cpp-ethereum node on ropsten. When i input tx-hash and press play button nothing happens.
What went wrong?


texts: I want to compare hash that I have passed in the argument of the function but keep getting this error

texts:
function compare(string memory input, uint _y) public returns (uint){
  bytes32 hashedinput = keccak256(input);
}

Error: Invalid type for argument in function call. Invalid implicit conversion from string memory to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding.
  bytes32 hashedinput = keccak256(input);
                                  ^---^


texts: Parity transaction tracing and how to determine transaction/call failure or success

texts:
I am currently working on a in-payment monitor system for Ethereum using the trace functionality in the Parity Ethereum Client.

The reason I am using the trace functionality instead of just looking up transactions is because I want to be able to pick up payments from contracts of any form, shape and size. My understanding is that a contract can generate any number of sub-calls which may or may not transfer ether to an account (or another contract). If this is not the right way to go about making a "universal in payment monitor" please yell at me.

My understanding is also that any number of things can happen to not only the entire transaction but also any sub-calls within the transaction which may or may not fault the entire transaction or parts of the transaction and sub-calls within it.

So my question is how does one accurately and securely determine if a given transaction and (sub)call has failed or succeeded? There seems to be a lack of good functionality for people who develop low-level wallet and exchange style monitors. This is pretty important to get right as well, much moneys could be lost.

This is what I am doing currently:

Fetch transaction and transaction block over RPC API for basic validation (eth_getTransactionByHash and eth_getBlockByHash).
Fetch transaction receipt over RPC API to check status field (0x1 = success, anything else = fail) (eth_getTransactionReceipt).
Fetch transaction trace over RPC API for detailed validation (check if error field is present in payment-spesific (sub)call) (trace_transaction).

More specifically I am wondering if its necessary to do any more validation of the (sub)call trace path (parent calls). If a parent call fails, does that mean all sub-calls fail as well? Or does this not matter? I have seen evidence and information for both cases.

One example is this transaction: https://blockchair.com/ethereum/transaction/0x626590b434e06b79fdd2187b28a55569f6c0636c6806808beb6ce2c743e88188

It shows that the sub-call (0.0.2.0.0.0.1) failed, but it has further sub-calls 0.0.2.0.0.0.1.0, 0.0.2.0.0.0.1.1 and 0.0.2.0.0.0.1.2 which seems to have succeeded. But then again no ether was transferred in those sub-calls so idk. Obviously, unless there is a bug in blockchair.com, a sub-call of a failed parent call can be successful, but does anyone actually know the rules at play here?

EDIT:
After some scanning through the Ethereum blockchain I also found this transaction: https://blockchair.com/ethereum/transaction/0x52c77e78c8d74e8fca4fc5760b8ed3775befeb9c072904b8c3568f2a5916aca9

It also shows sub-calls being successful after a failed parent call, this time also with ether being transferred (non zero value). However this time I am having a hard time seeing if this actually succeeded. Especially when one of the sub-calls are using a ether value that failed to transfer in a parent call. Checking the transaction on etherscan does indeed show that the state diff are not reflecting the seemingly successful sub-call of 0.000002 ETH (https://etherscan.io/tx/0x52c77e78c8d74e8fca4fc5760b8ed3775befeb9c072904b8c3568f2a5916aca9#statechange)

This leads me to believe that any sub-calls performed by a parent call that failed also have failed. Especially noticing that value that is transferred by a parent-call sometimes is used by subsequent calls.

EDIT2:
After scanning through several hundred thousand blocks and millions of transactions I am concluding this on my own. The rule seems to be consistent; If a parent call has failed, so has all subsequent sub-calls. Which totally makes sense. Feel free to comment if you have something you want to add or elaborate on.

This is one of many transactions that makes it clear: https://blockchair.com/ethereum/transaction/0x2fdf456085e159a0b52776b01472b8d5d0d37a31be15578466c7e3e82c456fb5

https://etherscan.io/tx/0x2fdf456085e159a0b52776b01472b8d5d0d37a31be15578466c7e3e82c456fb5/advanced#internal

https://etherscan.io/tx/0x2fdf456085e159a0b52776b01472b8d5d0d37a31be15578466c7e3e82c456fb5/advanced#statechange


texts: How to delete testnet blockchain files on Mac to save some space?

texts:
I'm new for ethereum. I downloaded the wallet. I found out I'm on test net. I moved to main now. I would like to delete blockchain file of test-net if it is different then main?
Thanks


texts: Using Golang how to get the number of transactions in a block

texts: I cant seem to find any way to get the number or transactions within a block using the block number in golang.. anyone have any idea how to do this


texts: How do I prompt a transaction to MetaMask using web3/truffle? Like if I want a charge a user x amount of ether, and have them confirm the transaction via MetaMask.


texts: How to simulate out of gas events on a private blockchain?

texts:
I want to get the error message "Intrinsic gas too low" during a eth.sendTransaction call.

Is it possible to simulate the condition of having run out of gas in a private blockchain scenario?

Can someone please point the way to understand this and other possible edge cases?

EDIT -

  web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
  21

  eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], gas:100000, value: web3.toWei(10, "ether")})

  miner.start(1); admin.sleepBlocks(1); miner.stop();

  web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
  21

Why did my coinbase account balance remain 21?


texts: How to I update to the latest wallet version (0.8.3) on Windows 10?

texts: I've been using Ethereum for a while and have quite a bit invested so I think it would be wise to update to the latest version. I visited the GitHub page and downloaded the latest Windows installer and found that all it does is open up an un-synced Ethereum wallet on the latest version, without any of my wallets, etc. How do I go about updating the wallet properly and safely?


texts: Why Do I need to deploy contract each time I start a geth node

texts:
I have a simple smart contract that I deploy to my own geth node and it works fine
but the problem is when I close the geth console and start it again I have to redeply the smart contracts again
Here is the code I am using to start the geth node

geth --port 3001 --networkid 5777 --datadir=./node1 --maxpeers=50  --rpc --rpcport 8545 --rpca
ddr 127.0.0.1 --rpccorsdomain "http://localhost:3000" --rpcapi "eth,net,web3,personal,miner" --allow-insecure-unlock con
sole 2>>eth.log --mine  --miner.gasprice 0   --syncmode 'full'

Am I missing something ?????

EDIT:
It is a SimpleStorage Contract, I can get the value after restarting the node but when I try to set it , it doesn't work

EDIT2:
I tried using ganach and it worked perfectly as expected, So I am almost certain that I have a problem with geth


texts: How to use web3.js@1.0.0-beta34 with TypeScript?

texts:
Here is a minimal code for testing:

import * as Web3 from "web3"

const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"))

const main = async () => {
  const blockNumber = await web3.eth.getBlockNumber()
  console.log({ blockNumber })
}

main().catch(err => console.error(err))

The module typings are wrong. If I try to compile it, there are some errors:

maxblock@mbp t10-web3-typescript *$ npm run build

> t10-web3-typescript@1.0.0 build /Users/maxblock/projects/test/t10-web3-typescript
> rimraf dist && tsc

../../../node_modules/web3/types.d.ts(1,27): error TS7016: Could not find a declaration file for module 'bn.js'. '/Users/maxblock/node_modules/bn.js/lib/bn.js' implicitly has an 'any' type.
  Try `npm install @types/bn.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'bn.js';`
../../../node_modules/web3/types.d.ts(2,21): error TS7016: Could not find a declaration file for module 'underscore'. '/Users/maxblock/node_modules/underscore/underscore.js' implicitly has an 'any' type.
  Try `npm install @types/underscore` if it exists or add a new declaration (.d.ts) file containing `declare module 'underscore';`
src/index.ts(3,14): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
src/index.ts(3,32): error TS2339: Property 'providers' does not exist on type 'typeof "/Users/maxblock/node_modules/web3/index"'.

OK. Next, I tried to override typings with my own. For this reason, I've created a file typings.d.ts with simple stub: declare module "web3".

There are fewer errors with my own typings, but anyway I can't compile it:

maxblock@mbp t10-web3-typescript *$ npm run build

> t10-web3-typescript@1.0.0 build /Users/maxblock/projects/test/t10-web3-typescript
> rimraf dist && rimraf node_modules/web3/index.d.ts && rimraf node_modules/web3/types.d.ts && tsc

../../../node_modules/web3/types.d.ts(1,27): error TS7016: Could not find a declaration file for module 'bn.js'. '/Users/maxblock/node_modules/bn.js/lib/bn.js' implicitly has an 'any' type.
  Try `npm install @types/bn.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'bn.js';`
../../../node_modules/web3/types.d.ts(2,21): error TS7016: Could not find a declaration file for module 'underscore'. '/Users/maxblock/node_modules/underscore/underscore.js' implicitly has an 'any' type.
  Try `npm install @types/underscore` if it exists or add a new declaration (.d.ts) file containing `declare module 'underscore';`

I've even tried deleting node_modules/web3/index.d.ts and node_modules/web3/types.d.ts files, but without success.

How do you work with web3.js + TypeScript?


texts: How to convert BigInteger balance from WEI to ETH in Objective-C?

texts:
I am using etherscan api to get balance using the address. But I am getting a response in wei. After some research, I got some WEI to eth converter methods.
WEI to eth
But I don't know which method will suitable for me and how I will convert this in Objective -c?

Thanks in advance.


texts: How to use OpenZepplin hooks to cancel transfer if condition is not met?

texts:
I am experimenting with OpenZepplin Hooks to modify ERC20 transfer functions in this way
contract IToken is ERC20 {
....
function _beforeTokenTransfer(address from, address to, uint256 amount)
    internal virtual override
{
    super._beforeTokenTransfer(from, to, amount);

    require(amount > 1, "ERC20: invalid transfer amount");
}

}
However if set amount = 0.5 tokens the transfer is still happening. Any idea what is the right way to make transfer fail if the condition is not met?


texts:
I am trying to track Solidity releases past, present and future.
Is there an official Solidity Releases road-map?


texts: Is Ethereum secure against an attack by quantum computers?

texts: Does Ethereum implement Post-quantum cryptography? Or will the network break once a malicious actor gains control of an effective quantum computer?


texts: How to identify submitted transaction to network?

texts:
I am developing an eCommerce application that has on-chain and off-chain components. The off-chain components focus on the compute and storage intensive operation while on-chain smartcontract ensure true decentralized ownership of assets through immutable ledger records.

My usual use-case will involve a browser frontend and offchain component interacting with users. Once the workflow comes to the appropriate juncture, I will call smartcontract function for updates or transfer.

I need to track the submitted transactions and match it against my offchain DB records. I understand submitted transactions may not get executed immediately because miner may not prioritise my transaction. While my offchain system is waiting for the smartcontract function to be executed and transaction to be confirmed, what if my system is shutdown. How do I find the transactions that I sent which may or may not be confirmed when my system is back online? I hope I don't need to scan all transactions for all new blocks.

Extending on this question, in the traditional enterprise system - there is always 2 phase-commit that ensure transaction integrity across multiple components. What is the best practice and design pattern if I want to implement something similar? I understand there is no way to rollback transaction in blockchain so we can forget about the rollback part in the 2 phase-commit, I just need to deal with out-of-sync system states and recover from it.


texts: what happens if I try to send my gdax btc to an eth address?

texts: My question is about transferring btc to and eth address by accident?


texts: Truffle Install // npm WARN and Vulnerabilities -- How i solve that issues?

texts:
I want to start working with Solidity in my Visual Studio Code so i installed Visuall Studio Code first, then nodejs and npm and in the end i try to install Truffles.
-I work on Window 10 OS
-Nodejs Version is v14.16.0
-npm Version is 7.6.3
I tried to install Truffle in my Windows PowerShell with the command npm install -g truffle
and it had that problems

Then i run npm audit fix
and showed this

How can i fix that issues?
Thanks in advance!
Update 1
Finally i run the command npm i --package-lock-only
and it showed me 0 vulnerabilities
but then i run truffle version and it showed me this

How i solve that?


texts:
pragma solidity ^0.4.23;

contract ApprovalContract {
address public sender;
address public receiver;

address public constant approver = 0x5AEDA56215b167893e80B4fE645BA6d5Bab767DE;

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

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

function viewRe() external pure returns(address){
    return(receiver);
}

function approve() external payable{
    require(msg.sender == approver);

    receiver.transfer(address(this).balance); // this line not working

}
}

I am getting transfer variable not visible.

  Member "transfer" not found or not visible after argument-dependent
  lookup in address.


texts: How to get only latest logged event via Web3 API?

texts: Is there a way to get only latest log for e.g myContractInstance.myEvent? Don't wanna rewind whole past. I know I can pass latest to a filter object, but that's not quite what I want. I'd like to get latest one from the past (no matter at which block it happened) and then continue listening for a new ones. Is this possible?


texts: Contract Polymorphism based on address type cast issue

texts:
I am new to solidity and having difficulty understanding polymorphism and address typecasting of contracts.
I am passing the address of child_1 contract to getChild2Value(address adr) which type cast address to child_2 contract. Should it not raise an error or exception as I am sending child_1 address and type casting it to child_2 but instead I am getting return from child_1 function.
Thanks.
pragma solidity ^0.8.0;
contract parent{

    function getValue(
    ) public view virtual returns(uint) {
        return 10;
    }
}

contract child is parent{

    function getValue(
    ) public view override returns(uint) {
        return 15;
    }
}

contract child_2 is parent{

    function getValue(
    ) public view override returns(uint) {
        return 20;
    }
}

contract ContractPolymorphism {
    function getChildValue(address adr) public view returns(uint){
        return child(adr).getValue();
    }
    function getChild2Value(address adr) public view returns(uint){
        return child_2(adr).getValue();
    }
}


texts: Withdrawing ether from crowdsale contract, issuing the right amount of tokens

texts:
I'm trying to create a crowd sale contract and have run into two issues that I can't resolve/find the answers to in the forums or documentation despite searching for the past two days. I imagine its simply because I don't know what to look for rather than it not being there.

Problem 1: My crowd sale sends the wrong amount of tokens in response to the ether contribution. Instead of providing 10000 tokens per ether it is providing the inverse to the contributors, 0.00001 tokens. I am using scientific notation so that the price is a portion of ether 1e-4 to be precise.

Problem 2: When the crowd sale ends the contract is funded with the ether contributed but it is not sent to the beneficiary address. How do I get the ether out of the contract so that it can be used by the beneficiary (DAO or otherwise).

My code below based on the Ethereum guidance on the main webpage:

pragma solidity ^0.4.16;

interface token {
    function transfer(address receiver, uint amount)public;
}

contract Crowdsale {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public deadline;
uint public price;
token public tokenReward;
mapping(address => uint256) public balanceOf;
bool fundingGoalReached = false;
bool crowdsaleClosed = false;

event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);

/**
 * Constrctor function
 *
 * Setup the owner
 */
function Crowdsale(
    address ifSuccessfulSendTo,
    uint fundingGoalInEthers,
    uint durationInMinutes,
    address addressOfTokenUsedAsReward
) public{
    beneficiary = ifSuccessfulSendTo;
    fundingGoal = fundingGoalInEthers * 1 ether;
    deadline = now + durationInMinutes * 1 minutes;
    price = 1e-4 * 1 ether;
    tokenReward = token(addressOfTokenUsedAsReward);
}

/**
 * Fallback function
 *
 * The function without name is the default function that is called whenever anyone sends funds to a contract
 */
function () payable public{
    require(!crowdsaleClosed);
    uint amount = msg.value;
    balanceOf[msg.sender] += amount;
    amountRaised += amount;
    tokenReward.transfer(msg.sender, amount / price);
    FundTransfer(msg.sender, amount, true);
}

modifier afterDeadline() { if (now >= deadline) _; }

/**
 * Check if goal was reached
 *
 * Checks if the goal or time limit has been reached and ends the campaign
 */
function checkGoalReached() afterDeadline public{
    if (amountRaised >= fundingGoal){
        fundingGoalReached = true;
        GoalReached(beneficiary, amountRaised);
    }
    crowdsaleClosed = true;
}

/**
 * Withdraw the funds
 *
 * Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
 * sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
 * the amount they contributed.
 */
function safeWithdrawal() afterDeadline public{
    if (!fundingGoalReached) {
        uint amount = balanceOf[msg.sender];
        balanceOf[msg.sender] = 0;
        if (amount > 0) {
            if (msg.sender.send(amount)) {
                FundTransfer(msg.sender, amount, false);
            } else {
                balanceOf[msg.sender] = amount;
            }
        }
    }

    if (fundingGoalReached && beneficiary == msg.sender) {
        if (beneficiary.send(amountRaised)) {
            FundTransfer(beneficiary, amountRaised, false);
        } else {
            //If we fail to send the funds to beneficiary, unlock funders balance
            fundingGoalReached = false;
        }
    }
}
}


texts: I created a token and crowd sale contract for that token together. But I have problems deploying it. When I wanted to deploy it, it gave me list of all the contracts in it and I didn't know which one to create... Should I deploy the crowd sale contract hoping it will also deploy the token too or am I to deploy each contracts one by one?


texts: How do I transfer from The DAO to an exchange using Linux and geth from the terminal?

texts: I don't want to use Mist to interact with the DAO. How do I do it from geth instead?


texts: Is Chainlink's price reference data free to consume?

texts:
I was looking at feeds.chain.link and it's not immediately obvious if anyone can tap into all these price feeds without incurring a cost:

For instance, I did find the ETH/USD aggregator contract, which has a "latestAnswer" property that anyone can access for free. At the time of posting this question, its value is 37867000000 (1 ETH = $378.67).
Is there an aggregator for all pairs listed on feeds.chain.link?


texts:
I'm playing with local Dapp for Parity.

When I'm trying to use query string in Dapp, I can't get it with js:

I see that iframe is used inside, but have no idea, how to add query string there.

Is any way to use query strings in Dapps for Parity to enable different logic of Dapp based on this query?


texts: What is Olympic, Frontier, Morden, Homestead and Ropsten Ethereum blockchain?

texts: I am studying Ethereum and have not been able to figure out the difference between Homestead and Morden. In some docs, it is written that Homestead uses a new algorithm which takes less time. I don't understand this. Is Morden for testing and Homestead for production?


texts: How would one find a list of transactions sent TO an address?

texts:
I am trying to write a script to audit the changing balance of an ETH address, but I cannot seem to figure out any way to find transactions where ETH has been sent to that address. I couldn't find an appropriate query in the Web3 docs and I couldn't find an appropriate endpoint on the Etherscan API. I would love to find out that I missed it though.

To be more precise, how could you find the transaction with hash 0x8c04e9c806fd7a3273d8a13b54239ab42a5f0b534520e760ccab920bc3d8d59c (https://etherscan.io/tx/0x8c04e9c806fd7a3273d8a13b54239ab42a5f0b534520e760ccab920bc3d8d59c) if you only had the recipient address 0xe81d6fce840ab873c7bccb6c2ab15e4b6daf92c7 and did not already have the transaction hash?

Note: I chose a plain ETH transfer transaction at random from the Etherscan homepage.

Ideally a solution wouldn't involve querying all transactions in a range and then filtering locally.

EDIT: this is slightly different from (How to get transactions by account using web3 js?) because I am OK with using tools outside of web3JS


texts: Getting a 403 Forbidden when trying to call MyEtherAPI with Nethereum

texts:
Don't know what's wrong. Here's the code:

let web3 = Web3("https://api.myetherapi.com:443")
let balanceTask = web3.Eth.GetBalance.SendRequestAsync(account.PublicAddress, 1)
balanceTask.Wait()
balanceTask.Result.ToString()

The API I'm using is https://www.myetherapi.com/ (it works with CURL!).

The exception is:

System.AggregateException: One or more errors occurred.
 ---> EdjCase.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s)
 ---> System.Net.Http.HttpRequestException:
Response status code does not indicate success: 403 (Forbidden).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at EdjCase.JsonRpc.Client.RpcClient.<SendAsync>d__23`2.MoveNext()
   --- End of inner exception stack trace ---
   at EdjCase.JsonRpc.Client.RpcClient.<SendAsync>d__23`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at EdjCase.JsonRpc.Client.RpcClient.<SendRequestAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Nethereum.JsonRpc.Client.RpcRequestResponseHandler`1.<SendRequestAsync>d__7.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at GWallet.Backend.AccountApi.GetBalance(Account account) in C:\Users\andre_000\Documents\Code\gwallet\src\GWallet.Backend\AccountApi.fs:line 19
---> (Inner Exception #0) EdjCase.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s) ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at EdjCase.JsonRpc.Client.RpcClient.<SendAsync>d__23`2.MoveNext()
   --- End of inner exception stack trace ---
   at EdjCase.JsonRpc.Client.RpcClient.<SendAsync>d__23`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at EdjCase.JsonRpc.Client.RpcClient.<SendRequestAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Nethereum.JsonRpc.Client.RpcRequestResponseHandler`1.<SendRequestAsync>d__7.MoveNext()<---


texts: require() statement to use for including Ganache GUI in the Dapp not Canache-cli

texts:
When using ganache-cli, we assign it using the require() statement. How do we do the same for ganache GUI? I don't want to use the ganache-cli for my app execution.
Also how do I assign the provider as in the 4th statement.
const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());


texts: EOS VS Ethereum : Is it logical not to charge any transaction fees in public blockchain?

texts:
Ethereum Operating System(EOS) is a platform which is more scalable than ethereum. To execute a transaction in the ethereum network one needs to spend some transaction fees, in EOS one don't need to spend transaction fees.
There are many platforms like EOS who don't charge any transaction fees.

With the help of transaction fees, one can ensure that a smart contract function won't get into infinite loop. If a platform doesn't charge transaction fees a programmer can write an infinite loop in smart contract function. That will not only increase the latency of mining a new block but also anyone in the blockchain network will be able to use computational resources without any restriction.

Is it logical not to charge any transaction fees in public blockchain?


texts: Can a smart contract read the gas cost of a transaction?

texts: If a transaction is sent to a smart contract, can the smart contract read the total gas cost?


texts: Which component sends a transaction and which component subscribes to an event?

texts:
I am working on an ethereum project but I have some doubts. I have a backend that connects to the blockchain via web3.js. To connect to the blockchain I use a geth node.
I understand that the sequence is this:
send transacrion

listen to events

my questions are:

What is the component sending the transaction? Is it the backend component or the geth node?
Then suppose that another smart contract in the network emits an event that I want to capture. What is the component that captures the event? Is it the backend component or the geth node?


texts: Transfer contract to address or adress to address

texts:
Good night, can anyone write an example contract that does ether transfer from contract to address?

Or preferably from address to address, but within the contract?

I have this:

function () payable {
   //
}

function withdraw () public {
    msg.sender.transfer (0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db);
}

function deposit (uint256 amount) payable public {
    require (msg.value == amount);
}


texts:
I am pretty new to the Ethereum and ERC20. I am willing to create an ERC20 token. I see that ERC 20 tokens can be transacted using the Ethereum addresses. However, I am wondering if it is possible to create an ERC20 token that is using custom address format. I basically have the idea to map user-recognisible names that can be mapped to actual addresses. So, for example jhonny333 maps to certain ethereum address. I guess that can be implemented on top of ERC20 token implementation, but then comes the question, where will the information of which address belongs to who be stored.

I am also wondering if there is a possibility to implement that address mapping directly in my token's smart contract. So, in other words as the title says: Is there a way to use Solidity to generate a token that uses custom addresses to send transactions?


texts: Getting garbage after calling property in another smart contract.

texts:
I'm using liquid democracy contract from  https://www.ethereum.org/dao

This is the relationship.

Shareholder Association has this definition when pointing to liquid democracy contract.

contract token {
    mapping (address => uint256) public voteWeight;
    uint public numberOfDelegationRounds;

    function balanceOf(address member) constant returns (uint256 balance) {
        if (numberOfDelegationRounds < 3)
            return 0;
        else
            return this.voteWeight(member);
    }
}

then liquid democracy contract points to token contract and defines its connection as this.

contract token {
    mapping (address => uint256) public balanceOf;
}

The line in Shareholder Association below returns garbage data.

uint voteWeight = sharesTokenAddress.balanceOf(v.voter);

something like this which is big number.

  76181730938387481504298103224485865201289833135200371729261377095349320967255

I had to combine logic from those contracts into one for it to work.
I'm not using token contract anymore for this though as my contracts use 1 token per user and I have just internally implemented it giving each user one vote.

Of course I would like to reuse the code and be able to execute this idea like shown on the Ethereum site.


texts: Is the execution of a smart contract performed by the miner or the blockchain?

texts: I would like to know whether the execution of a smart contract is done by the miner or by the blockchain system?


texts: When I send a transaction from remix, how does it set the gas price for the transaction (not gas cost / limit)?


texts: Ethereum Truffle init project gives error after 'truffle migrate' command

texts:
Issue

I want to create a default generated project working with Truffle. After running the commands truffle init, truffle compile and truffle migrate I got the error: Expected parameter 'from' not passed to function. The geth rpc is successfully running in the other window of Terminal so it's not the cause of the problem. I expect Truffle to start deploying migrations for the default Truffle project.

Actual Results

Using network 'development'.

/usr/local/lib/node_modules/truffle/build/cli.bundled.js:23538
        throw new Error("Expected parameter '" + key + "' not passed to function.");
        ^

Error: Expected parameter 'from' not passed to function.
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:23538:15
    at Array.forEach (<anonymous>)
    at Object.options (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:23536:19)
    at Object.run (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:66868:12)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:88946:23
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:67033:9
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:66861:7
    at done (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:155469:5)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:155526:11
    at FSReqWrap.oncomplete (fs.js:153:5)

Environment

Operating System: macOS Sierra
Truffle version: 3.4.9
Ethereum client: Geth 1.6.7
node version: 8.3.0
npm version: 5.3.0


texts: What were the password requirements for creating an account on Ethereum wallet?

texts:
Trying to migrate a wallet over to MyCrypto app from the Ethereum Wallet app (the one that used gest and that is on the same download page as mist).
Can't remember password. Would help if I knew the password requirements for setting up a wallet in the Ethereum Wallet app.
In order to remember the password, what were the password requirements for creating an account on Ethereum wallet?
Was it ... 10 chars min, mix ofuppercase,lowercase, number, symbol?
Or was it ... 8 chars min, mix of uppercase,lowercase, number, symbol?
Or something else?


texts: Bundling web3js does not seem to work (Metamask app)

texts:
(This is a follow-up question from here.)

From the Metamask developers faq it is stated to "bundle the version of web3 that is used during development".

So I downloaded a web3.min.js version 0.20.6 from GitHub and "bundled" it like in the code below. Then I log "web3.version.api" to the console.

Now, with or without the bundling, the console reports a version 0.20.3 after clicking the button.

I suspect this is due to the line

web3 = new Web3(web3.currentProvider);

which sets web3 to the injected code from my Metamask plugin, in which I am logged in, and it runs that code, not my "bundled" version ...

Question: How do I bundle my own version of web3?

<html>
  <body>

    <script type="text/javascript" src="scripts/web3.min.js"></script>

    <script type="text/javascript">

      window.addEventListener("load", function() {

        if (typeof web3 === "undefined") {
            console.log("No web3 provider found");
        } else {
            web3 = new Web3(web3.currentProvider);
            console.log("Using web wallet");
        }

      })  </script>

    <button id="buttonBalance">Click to report version to console</button>

    <script type="text/javascript">
      button = document.getElementById("buttonBalance")
      button.onclick = function tmp()
  {
    console.log("Version=" + web3.version.api);
      };
    </script>

  </body>
</html>

PS. I created the button to make sure the web3 call to "web.version.api" is done "outside adding the eventListener to window" as per the suggestion of @Kai Kälberer

Update: As suggested by @viz I downloaded the non-minified web3j version from GitHub and uncommented the line that avoids overriding the global web3 instance. Check this screenshot from my dev tools debugger:

Still I see that the console prints out the version 0.20.3 and not 0.20.6 as defined in the downloaded web3.js ... why?


texts: Error: Wallet has error: Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.0.17)

texts:
After enabling JWT token authentication on besu network, a connectionInfo with JWT token in headers is used to make connection to the network, instead of url.
import { ContractFactory, ethers } from "ethers";
let connectionInfo = {  //<<==connectionInfo may have problem. Used to use url and worked fine.
   url: GLOBAL.PROVIDER_URL, //<<=="http://my-ip:80"
   headers: {
     "Bearer": tokenBesu //<<==tokenBesu is validated on jwt.io and OKed with cUrl command querying the network
},

};
const provider = new ethers.providers.JsonRpcProvider(connectionInfo); //<<==used to be url
wallet = new ethers.Wallet(privateKeyBesu, provider); //<<== this line throws error

However querying network with cUrl (provided by Besu doc) in command line returns true.
$ curl -X POST -H 'Authorization: Bearer tokenBesu' -d '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":1}' http://my-ip:80
{
  "jsonrpc" : "2.0",
  "id" : 1,
  "result" : true
}

The network is running fine. What causes the no detection of network here?


texts: Deploying multiple contracts with different solc versions

texts: I have a few contracts that I deploy with my 1_initial_migration.js. However some of them are of different solc version than others. Is there a way to change it programmatically before compiling and then change it back for other contracts in the loop?


texts: The data type of the return value of the solidity function has changed

texts:
As you can see, I have designed a struct in the solidity.There is a function in the solidity with the return value type User
mapping(address => User) public _userInfoMap;
struct User{
        uint value;
        string email;
        string phoneNumber;
        string name;
        string idCard;
        Gender gender;
        int256 birthday;
        string province;
        string city;
        string area;
    }

function getUserInfoByAccount(address account) public view returns (User memory) {
    return _userInfoMap[account];
}

I use the web3js to call the function and get the return value:
let res = await this.userContract.methods.getUserInfoByAccount(account).call({from: this.admin});

And when I print the res, I find all the int type has been changed to string. The printed result is below.
area: "0xe984a299b5e58ebf"
birthday: "8161300000"
city: "0xe88e6988ce5b882"
email: "927694@qq.com"
gender: "0"
idCard: "41133428"
name: "0xe78e8be5a49ae9b1bc"
phoneNumber: "1871778"
province: "0xe6b3e58d97e79c81"
value: "0"

I don't know why all int variables become strings. I want to know if this is normal? Hope you can give me some help!


texts: Can Ethereum or Mist run on Raspberry Pi 1, 2, 3, or Zero?

texts:
Would an ethereum client or mist be able to run on a raspberry pi?

It's a simple yes or no question with an explanation. I don't want links to "light" versions of ethereum, as that's not what I'm asking for. And second of all they do not even exist yet.


texts:
I have a rpi3 and it have to be a node of a blockchain. I have a script python on raspberry, which gather data from an accelerometer. Checked some conditions,I should store these data,plus other strings(Gps coordinates and date)in a blockchain. I am using testrpc and I've installed web3.js.

I start my tester from cmd inserting "testrpc" and it shows me the available accounts with theirs private keys. Then to interact with it I have to open another cmd window,right?

To interact with a generic node I have to use web3 library,so from the second cmd window I should run a node.js script,which takes data from python script( with a socket for example) and use web3 function to interface with node. Something like this:

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

web3.isConnected();

Now,imaging I wanted to store on blockchain just some values written in node.js(and not the real data yet). I don't know. For example var x=5 e var y=10. What would be the complete code to do this?


texts: Token contract and crowdsale contract deploy

texts:
I am Testing with an Ethereum Based token contract and i would need some help  deploying the Token contract and Crowdsale contract.

I already have done this, deploying booth contracts and allocating tokens to the crowdsale contract from the token contract but when i send ether to the crowdsale contract i do not get sent back the tokens.

These are the Token contract and Crowdsale contract.


texts: Deploying custom bytecode on the blockchain

texts:
Say I have custom bytecode which I want to deploy to the blockchain, for example, 0x6009 (PUSH1 0x09) and I want to create a contract which executes exactly that bytecode when called. As far as I understand, I can send a transaction to the all zeros address (or rather, no specifying an address at all) to achieve this.

However in this contract-creating transaction, I have to send bytecode that returns the bytecode which I actually want to deploy. Are there any tools to create this bytecode? If not, how to I wrap given bytecode so that I can deploy it on the blockchain?


texts: Parity with Nodejs - Sending bulk transactions

texts:
I'm running a private testnet with Parity, and interacting with it using a nodejs cli. I have a script with which I trigger multiple transactions in quick succession for a smart contract that I have deployed:

function sendTransactions (amount, times){
    for(i=0; i<times; i++){
       smartContract.foo.sendTransaction({from: web3.eth.accounts[0], gas:100000, value: amount});
    }
}

If I submit a limited number of such transactions - say < 100 - all the transactions go through successfully. For a larger value, the nodejs cli suddenly gets disconnected after completing some initial number of transactions and displays the following error log:

Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8180.
at Object.module.exports.InvalidConnection (/home/euser/node_modules/web3/lib/web3/errors.js:28:16)
at HttpProvider.send (/home/euser/node_modules/web3/lib/web3/httpprovider.js:75:22)
at RequestManager.send (/home/euser/node_modules/web3/lib/web3/requestmanager.js:58:32)
at Eth.get [as accounts] (/home/euser/node_modules/web3/lib/web3/property.js:107:62)
at Object.exports.sendOneTransaction (/home/euser/parity/scripts.parity.js:10:51)
at Object.exports.sendTransactions (/home/euser/parity/scripts.parity.js:17:13)
at Object.<anonymous> (/home/euser/parity/scripts.parity.js:55:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

What can be the reason behind this behaviour?


texts: Adding Airdrop functionality to an already deployed erc20 smart contract

texts: How can you add airdrop functionality to an already deployed smart contract on the mist wallet?


texts:
Is it possible to write a multi line string in the solidity language on the same fashion as JavaScript allows us to do so by levering back-ticks?
I'd like to now an optimal way to save a long string in my smart contract that needs several line break without me having to escape with \n all over the place.
in essence this is doable in JavaScript using back-ticks
i.e.
const multiLine = `
line1

line2
line3
and so forth...
`

Is possible to do so in the Solidity language?


texts: Public function when called from another contract throws error "The called function should be payable if you send value"?

texts:
This is the contract I am calling from:
contract MultiTransfer {
    function multiTransfer(Marcelo token, address _addresses, uint256 amount) public {

            token.transfer(_addresses, amount);

    }
}

This the contract where the transfer function is:
contract Marcelo is ERC20Interface, Owned {
    using SafeMath for uint;

    string public symbol;
    string public  name;
    uint8 public decimals;
    uint public _totalSupply;

    mapping(address => uint) balances;
    mapping(address => mapping(address => uint)) allowed;

    // ------------------------------------------------------------------------
    // Constructor
    // ------------------------------------------------------------------------
    function Marcelo() public {
        symbol = "MRL";
        name = "Marcelo";
        decimals = 18;
        _totalSupply = 250000000 * 10**uint(decimals);
        balances[owner] = _totalSupply;
        Transfer(address(0), owner, _totalSupply);
    }

    // ------------------------------------------------------------------------
    // Total supply
    // ------------------------------------------------------------------------
    function totalSupply() public constant returns (uint) {
        return _totalSupply  - balances[address(0)];
    }

    // ------------------------------------------------------------------------
    // Get the token balance for account `tokenOwner`
    // ------------------------------------------------------------------------
    function balanceOf(address tokenOwner) public constant returns (uint balance) {
        return balances[tokenOwner];
    }

    // ------------------------------------------------------------------------
    // Transfer the balance from token owner's account to `to` account
    // - Owner's account must have sufficient balance to transfer
    // - 0 value transfers are allowed
    // ------------------------------------------------------------------------
    function transfer(address to, uint tokens) public returns (bool success) {
        balances[msg.sender] = balances[msg.sender].sub(tokens);
        balances[to] = balances[to].add(tokens);
        Transfer(msg.sender, to, tokens);
        return true;
    }
....
...

I am using remix to compile and deploy locally to test. When I pass arguments to transfer function in contract marcelo it works as expected but when I do so in contract  MultiTransfer for function multiTransfer it gives me an error and reverts back. transact to MultiTransfer.multiTransfer errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance.
Can someone please help me understand what am I doing wrong? There have been similar questions that have been asked but they have not been much of a use to me.


texts:
i am new to solidity....i was following a tutorial but this error DeclarationError: Identifier not found or not unique. --> MyContract.sol:9:27: | 9 | function get() public views returns(string) { | ^^^^^
the code i tried to compile is
pragma solidity ^0.8.1;

contract MyContract {

string value;

function get() public views returns(string) {

     return value;
}

}

can someone tell me why
thanks


texts: I am not quite sure whether this is right place to ask this question but let's carry it forward. I wanted to host Ethereum on Digital ocean. Has anyone ever tried that? Any HowTos on hosting ethereum on Digital ocean. I am more concerned about whether will I be able to access Mist(Ethereum Wallet) from there in same manner as I am using it on my local machine.


texts:
The following example does not hang.

$ cat main.js
#!/usr/bin/env node
// vim: set noexpandtab tabstop=2:

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.eth.getAccounts()
    .then((accounts) => {
        console.log(accounts);
    })

But the following code hangs. Does anybody know why?

$ cat main.js
#!/usr/bin/env node
// vim: set noexpandtab tabstop=2:

const web3 = new (require('web3'))("ws://localhost:8545");
web3.eth.getAccounts()
    .then((accounts) => {
        console.log(accounts);
    })


texts: Is it a mandatory to add payable keyword when using msg.value

texts:
Example :

pragma solidity ^0.4.8;

contract X{

    uint amount;

    function X() {
        amount = amount + msg.value;
    }
}

Here Constructor X() is not payable. Should I change it to payable because of using msg.value ?


texts: How can I link the serpent compiler to geth?

texts:
geth offers the function eth.compile.serpent. However, when I try to provide some source to the compiler, it returns The method eth_compileSerpent does not exist/is not available.

I wonder:

How can I link the serpent compiler with geth? I don't see something similar to eth.setSolc for the serpent compiler.
Do I also need to reformat serpent code to be on one line when submitting it to the compiler and how is then indentation handled?


texts:
I am new to Crypto. I made a new wallet on MyEtherWallet sometime ago. But, now i want to move that wallet to Mist.

One way to do this would be to just create a new mist wallet and transfer my ether from old wallet to new wallet. But, i was wondering if there is a way where i can actually move the wallet itself to Mist. So, end result would be that my new wallet in mist would have the same public address as my current wallet in MEW.

Can someone help out? Am i even thinking about it in the right way?


texts: Running a local development evm virtual machine

texts:
Is there a way to compile, run and debug a solidity class on my developpment computer.
I do not want to connect to an ethereum network.
I just want to debug my class
Thanks


texts:
I've got some ETH on an old XETH wallet from 5 years or so and I've never been able to retrieve it.  The ETH doesn't show up in the wallet and the sync bar is completely blank. Based on another troubleshooting guide, I downloaded Geth to update the blockchain. It seemed to be up to the latest block after last night so I opened the XETH wallet but I still don't see any change in the syncing.
EDIT - on Windows 10 - version 0.4-2 (BETA)  There is actually a sliver of a column on the left side of the sync bar
EDIT - Not sure if the Geth has completed.  It says INFO  processed 49,027,060, pending 38,568.  Although when it shows another line for the block it seems to be on the latest block.  Not sure if this is another "layer" it has to go through to reach the latest block on the INFO lines as well?
Thanks


texts: RPC 's SendRawTransaction(increased nonce) many times ,only the first transaction in block

texts:
I am using infura node (rinkeby), php.

There are 3 transactions I signed with custom nonce (like the solution here) then broadcasted them by sendRawTransaction and succeeded.

After above I get 3 transaction hashs.

Though, only the first transaction can be found in block.