texts: Need clarification regarding to transactions

texts:
Sorry if question is duplicate . I tried to find answers in google but I don't know \how to search really .
Here is my problem .
Basic Smart contract gives you some sort of API to communicate with blockchain , when using in it's method

 var MyContract = web3.eth.contract(abiArray);
var contractInstance = MyContract.new([contructorParam1] [, contructorParam2], {data: '0x12345...', from: myAccount, gas: 1000000});

After you can do smth like

contractInstance.methodWhichIsDescribedInContract(foo,bar)

So basically all erc20 standart contract must implements methods for sending and receiving tokens so far .
But if contract already has the interface why people use raw transactions ?

1) Is it possible to interact with blockchain without contract ?

2) Is it  the case for using raw transaction ?

3) If we have smart contract does it mean we don't need raw transactions?

Thanks

Edit 1
Example of raw transaction

var tx = new ethereumjs.Tx({
  nonce: nonce,
  gasPrice: web3.toHex(web3.toWei('20', 'gwei')),
  gasLimit: 100000,
  to: address,
  value: 0,
  data: data,
});
tx.sign(ethereumjs.Buffer.Buffer.from(privateKey, 'hex'));

var raw = '0x' + tx.serialize().toString('hex');
web3.eth.sendRawTransaction(raw, function (err, transactionHash) {
  console.log(transactionHash);
});


texts: How can I (efficiently) programatically see if I am on an ETH or ETC chain?

texts:
if i have 2 nodes, one ETH and one ETC, and I am writing a program to use these nodes, how can i determine which node I am using at any given time?

the best i can come up with is to check a known block after the fork and simply compare # of tx. I know how many tx are in that block on both chains, so i can differentiate that way.

this seems clunky. is there a better way to do this?

Edit: this is not a duplicate of "Does ETH and ETC uses the same network ID?" because i am not asking about the network id. i am asking about the network as a whole. eth/etc share a network id of 1 for the main network.


texts: Long term storage of ethereum in self-custodial hardware wallet

texts:
If there is an update of token standard (e.g ERC20 token), what need to be done to my ethereum (ether) in my self-custodial wallet and my hardware wallet?
My thought:
I do not need to do anything even if I leave my ethereum token unattended for ten or more years in a hardware wallet(which I do not update for ten or more years). I only need to keep the private key safe. Is my thought correct? Any help is appreciated. Thank you


texts: how estimate average time for transactions to smart contract

texts:
I have created a decentralized application on the Ethereum Blockchain network. This application receives data from different addresses on the blockchain network and saves this data in the blockchain network.
This data is sent as parameters, how do I calculate the response time for these transactions in milliseconds.
For example: Response time in milliseconds for reading data from the proposed smart contracts when the number of transactions = 1 and when the number of transactions is 100,200,300 and so on.


texts: Possession vs Title vs Ownership in NFTs

texts:
Is there a way to separate possession from title in an NFT smart contract? I'm not sure these are the best terms, but here are some examples:

Renting out NFTs, say for use in a game. The rental is fixed term, during which the renter wants full use of the token; and after which owner wants to know they'll get it back. And the game operator need to know whose signature to seek before allowing use of the NFT.

Putting up an NFTs as collateral for a loan, while continuing to use it. It's common for people to do this with a house or a car when borrowing from the bank, and they don't vacate the house or deliver the car to the bank, they maintain possession and the bank simply holds the title deed to the house or registration papers for the car.

ENS has a live example today with their concept of a "Controller: The account that may edit the records of a name", analogous to possession. This is distinct from the Registrant (owner, title holder). Either Registrant or Controller can change Controller, but only Registrant can change Registrant.

I am aware of the concepts of owner, approved address and operator in ERC721. These all have permission to transfer ownership but there is no narrower concept of possession, such as the Controller in ENS.
One solution would be to extend ERC721 to have a possessor, being an address that can make all changes other than transfer ownership. Some potential problems with this:

Unfair repossession during the term of a rental. This can be solved by locking ownership in a smart contract for the term.

What happens if the renter decides they want to rent the NFT out, like subletting with property? Does this concept need some kind of stack? I don't think so. That could hopefully be solved by wrapping the NFT in another NFT (and so on), but the this again depends on the innermost NFT having a concept of possession vs title.

All apps that look for a signature from the owner of a token now need to look for the possessor instead. This could be solved by considering the owner the possessor and introducing the the term titleholder which can override owner. In fact, the approved address could have this function, just disallow owner from calling transfer when an approved address is set and composability can do the rest. But this definitely abuses the terminology.

I'm sure this is a common problem so have looked around and found:

ERC-994 Delegated Non-Fungible Token Standard
ERC-998 Composable Non-Fungible Token Standard
EIP-2615 Non-Fungible Token with mortgage and rental functions

All  looks useful but very application specific. What minimal extension to ERC-721 or ERC-1155 might be enough that composition could do the rest?


texts: How to bundle own web3 version and using Metamask

texts:
I am a bit of a javascript noob and have some questions about using web3js and Metamask.

My objective (for now) is to display the ether balance as displayed on my Metamask (where I am logged in).

From the Metamask Developers FAQ I took a snipped of code and made some changes. I am able to get the correct address, but the balance is null.

Here is the complete code:

<html>
  <body>

    <button id="buttonBalance">Click to get balance</button>

    // Bundling my version of web3
    <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");

          console.log("address = " + web3.eth.coinbase);

          button = document.getElementById("buttonBalance")
          button.onclick = function tmp()
          {
              web3.eth.getBalance(
                  web3.eth.coinbase,
                  function tmp2 (balance)
                  {
                    console.log("balance=" + balance);
                  });
          };
      }

      })  </script>
  </body>
</html>

The above code shows in the console (after clicking the button):

Using web wallet
address = 0x4b6efab615a5e2c4002d23318b891d7bf673e1d34
balance=null

Question 1: Why does the above code not work? I get no syntax or "async" errors and Metamask shows my balance correctly ... ?

Question 2: From the best practices it is stated to "bundle the version of web3 that is used during development". So I downloaded web3.min.js and "bundled" it (see the comment in the code above). Now I am unsure if that implementation is actually used under the hood. Can I be sure, can I print out the web3 version or so?


texts:
I am following a course. I have loaded Geth and started it with the following

>"c:\program files\geth\geth" --testnet --syncmode fast --rpc --rpcapi db,eth,net,web3,personal --cache=1024 --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303"

Truffle is loaded and by executing

truffle(default)> web3.personal.newAccount('password')

I get back

'0x2fd8e5528d094dae7d068ff55587ea5b465a997f'

Executing

truffle(default)> web3.eth.getBalance('0x2fd8e5528d094dae7d068ff55587ea5b465a997f')

returns

{ [String: '0'] s: 1, e: 0, c: [ 0 ] }

Ethers was requested at

https://faucet.bitfwd.xyz/

using the '0x2fd8e5528d094dae7d068ff55587ea5b465a997f' code but executing getBalance(..) doesn't show any change. How do I get Ethers into that account?

EDIT:
Syncing has been running for 1 day now. I have checked the sync using this comment. The current results are

{
  currentBlock: 2659248,
  highestBlock: 2659378,
  knownStates: 10005763,
  pulledStates: 9998706,
  startingBlock: 3136
}

A new request for Ethers can be seen here.


texts:
Can A smart contract ownership be shared.

If No!, is the restriction imposed at the EVM level
Otherwise how can shared ownership be achieved.


texts: Truffle and contract with an Address type constructor parameter

texts:
When I add new contract (testrpc) with truffle with parameter of type "address" the reading value of this property seems wrong (always 0x0000000000000000000000000000000000000000), I do not find the cause of the problem

The Demo.sol contract:

pragma solidity ^0.4.2;

contract Demo
{
     address public test;
     function Demo(address test) payable
     {
        test = test;
     }
}

I add the new contract with truffle

Demo.new("0x9e99b1aaa2114fdae97c9ab2f20863dfde4659bd", {
    from: account,
    value: web3.toWei(0.1, 'ether')
}).then(function (instance) {
    return instance.test.call({from: account});
}).then(function(test) {
    console.log(test);
});

The expected result is 0x9e...9bd but the output is 0x00...000.

If necessary, I push the demo project on Github, Thank you for your help


texts:
When running geth --light the go-ethereum client somehow has to connect to full nodes to interact with.

Could geth connect to any full node on the network or does this require a special endpoint? How to run a "server" for light clients? And how do light clients discover my node?


texts: SendSignedTransaction returns txId but the tx seems to never be executed on Robsten

texts:
So lets start of with some code, let me start with explaining why I have two web3 instances. This is because one is just looking for events on the WS protocol and the other is using the HTTP protocol to send and call transactions. If I do the everything on the WS port it closes on me(any alternatives for this would be great).

let nonce;
            web3NoEvents.eth.getTransactionCount(account).then(_nonce => {
              nonce = _nonce + 1;
              const encoded_tx = contractNoEvents.methods.myMethod(n) + 1).encodeABI();
              const rawTx = {
                  nonce: nonce,
                  gasLimit: 3000000,
                  gasPrice: web3NoEvents.utils.toHex(utils.toWei('20', 'gwei')),
                  data: encoded_tx,
                  from: account,
                  to: contractAddress
              }

              let tx = new Tx(rawTx);
              tx.sign(pvtKey);
              let serializedTx = tx.serialize();
              web3NoEvents.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'), function(err, res){
                if(err) {
                  console.log(err);
                }
                console.log(res);
              })
              .on('receipt', function(res){
                console.log('signedTransaction res', res);
              })
              .on('error', function(err){
                console.log('signedTransactionErr', err);
              });
            }).catch((error) => {
              console.log(error);
            });;
          }

So the res gets logged in the sendSignedTransaction function and returns a txId like for example:

0x72501de41d3914e5fc78d4351ec24c0466182e533fa206656b440c7b2309ba52

The problem is that the .on receipt or .on error never get called, it seems like transaction gets initialzed but never actually gets broadcasted. If I search for the txId in the Ropsten block explorer it never finds it.

I just started working on the testnet and suspect that I might have to broadcast the transaction manually but am not sure if this is the case or otherwise how..


texts: What does mining software do when two tx are sent in one block with incremented nonces, but the second tx relies on the completion of the first?

texts:
If I call approve and transferFrom on an ERC20 token in two transactions, with the nonces being 1 and 2, respectively, how do the miners know which to accept first?

Do the miners choose the ordering of the transactions? If so, does it depend on the nonce or just the gasPrice? If they have the same gasPrice, is it random which one is included first? Does mining software look at the nonce? Can a miner include a t

Looking at Etherdelta, it seems like their interface sends both transactions, approve amd transferFrom in one block with an incremented Nonce. So is this possible?


texts:
I recently read that Ethereum will be switching from PoW to PoS soon, will this kill GPU mining? I'm asking since I'm looking to build myself a miner as both a summer project and a way to make some money, but is it still worth it at this point to invest in a mining setup?

Thank you in advance.
Joey


texts: Out of Gas exception on testnet but on JVM it works

texts:
I am trying to withdraw a contracts balance to the owner of that contracts account. It works perfectly on the JVM in solidity browser. But on TestRPC it has an out of gas exception.

The account has a lot of ether in it, more than enough to run the function to withdraw.

Any ideas why it only works on the JVM?

ADDED CODE BELOW:

contract SinglePatreon {
    bytes32 public name;
    uint public singleDonationAmount;
    uint public monthlyDonationAmount;
    address creator;
    uint contractNumber;

    modifier onlyCreator {if (msg.sender != creator) revert(); _; }
    modifier onlyPatreons {if (msg.sender == creator) revert(); _;}

    event LOG_SingleDonation (uint donationAmount, address donator);
    event LOG_Withdraw (uint emptyBalance);
    event LOG_creatorAddressAndSender (address factoryAddress, address creator);

    function SinglePatreon (bytes32 _name, uint _contractNumber) payable {
        contractNumber = _contractNumber;
        PatreonFactory pf = PatreonFactory(msg.sender);
        name = _name;
        creator = pf.getOriginalCreator(contractNumber);
        LOG_creatorAddressAndSender(msg.sender, creator);

    }

    function setOneTimeContribution(uint setAmountInWei) onlyCreator  returns(uint){
        singleDonationAmount = setAmountInWei;
        return singleDonationAmount;
    }

      function oneTimeContribution() payable onlyPatreons returns(uint){
        if (msg.value != singleDonationAmount) revert();
        LOG_SingleDonation(this.balance, msg.sender);
        return this.balance;
      }

    function creatorWithdrawFromContract() onlyCreator returns (uint) { //some reason it says oout of gas when i try to call this from creator .... hmmm
      //maybe it is beacuse the contract does not have any gas. and transferring takes a lot of gas. setOntTimeContribution works though!? i dont know :\
      LOG_Withdraw(creator.balance);
      creator.transfer(this.balance);
      LOG_Withdraw(creator.balance);

      return creator.balance;
  }}

Here is the error I am getting:

callback contain no result Error: Error: VM Exception while executing eth_estimateGas: out of gas
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59880:17
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88044:5
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11863:9
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8423:16
    at replenish (/home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8943:25)
    at iterateeCallback (/home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8933:17)
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8908:16
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11860:13
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88040:9
    at /home/davekaj/.nvm/versions/node/v7.9.0/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:73948:7


texts: Retrieving contract abstraction multiple times?

texts: In the Metacoin sample provided with Truffle webpack I see that in app.js the contract abstraction is retrieved in multiple functions using the .deployed() function.  Is there a reason I couldn't just get it once when the script starts and store it?  Why do we need to get it multiple times?


texts: How to make transactions using private key in web3?

texts: I have account private key, contract address and abi and I need to call contract function with this account. Is it possible?


texts: Does this function makes my contract weak?

texts:
Ive just published a contract to etherscan, but notice something that i miss.
One of my payable function (deposit()) is not set to be called only from owner.
Is it going to make me troubles and should I redeploy?

I was trying to do a transaction when the constructor is called. It was planned to be only once.

here is how it looks:

 event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

function SimpleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet, address _wallet2) public {
    require(_startTime >= now);
    require(_endTime >= _startTime);
    require(_rate > 0);
    require(_wallet != address(0));
    require(_wallet2!= address(0));

    startTime = _startTime;
    endTime = _endTime;
    rate = _rate;
    wallet = _wallet;
    token = new SimpleToken(TOKEN_SUPPLY);
    wallet= _wallet2;

    token.mint(_wallet2, DEPOSIT_TOKENS);
    deposit();
  }

  function deposit() public payable {
    TokenPurchase(msg.sender, wallet, msg.value, DEPOSIT_TOKENS);
  }


texts: Which doxygen tags are allowed for contracts?

texts:
Where can I find the list of doxygen tags that are allowed for contracts?

This documentation states:

  Additionally, there is another type of comment called a natspec comment, for which the documentation is not yet written. They are written with a triple slash (///) or a double asterisk block(/** ... */) and they should be used directly above function declarations or statements. You can use Doxygen-style tags inside these comments to document functions, annotate conditions for formal verification, and provide a confirmation text which is shown to users when they attempt to invoke a function.

then I tried some tags but got errors like this:

DocstringParsingError: Doc tag @tag not valid for contracts.
DocstringParsingError: Doc tag @section not valid for contracts.
DocstringParsingError: Doc tag @version not valid for contracts.

Before manually trying some more - is there a list somewhere that lists all allowed doxygen tags?


texts: calling simple function from another contract

texts:
I'm running into issues calling the function y() in the contract pullother. The input for the function y() is the output of the function g(). When I call y() using this input the output is blank ('' to be specific) rather than 15. I'm not exactly sure what I'm doing wrong here as this seems to align with the examples I see online of people successfully calling functions from other contracts.

The below is Untitled.sol

    pragma solidity ^0.4.6;

    contract helloworld {

    function f() returns (uint){
    return 15;
    }

    }

The below is the contract i would like to use to call the function f() in the contract helloworld.

pragma solidity ^0.4.6;

import "./Untitled.sol";

contract pullother {
address public hello;

function g() returns (address){
    hello = new helloworld();
    return hello;
}

function y(address contractadd) returns (uint){
    helloworld h = helloworld(contractadd);
    h.f();
}
}


texts: Can a smart contract transfer (steal) another contract's tokens?

texts:
Let's say I have an ETH address and that same address holds AAA, BBB and CCC tokens. Each token symbol is managed by a different contract (each contract was created by a different person/organization with different private keys).  However, the same ETH address was "registered" with each contract (e.g. ICO sale/airdrop/rewards/referral/profit shares).

Can one fraudulent contract steal tokens from the other? For example, let's say the CCC contract contains malicious code that could transfer (steal) AAA and BBB tokens because the owner of the ETH address was tricked into "registering" the public ETH address with the CCC contract (scam).  Is that possible or can each contract only access its own tokens?

Follow up question (if I am allowed to ask more than one question):

If it is possible, should an inexperience non-developer completely avoid all forms of contract invocations or is there a relatively easy way to determine what a contract can and cannot do with regards your other tokens/ETH?
If it is not possible (each contract can only control its own tokens), how do decentralized exchanges trade (transfer) tokens that they do not own?


texts:
How do I connect my web3 to ropsten network. I know how to pass the url of ropsten netwrok in web3 instance in my script tag but when i try to to console.log(web3.eth.defaultaccount) it gives me undefined in console and its not making calls to my contract which is already deployed on ropsten. Can anybody please help?

<!DOCTYPE html>

 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Lets Bid</title>

BIDDING WEBSITE

PRICE:600 $

        <form>
                First name:

                <input type="text" id="firstname">

                Bid:

                <input type="text" id="bid">

                <button id="sub" onclick="getuserdata();">Submit</button>

Highest Bid

                <button id="Sh" type="button" onclick="hibid(); return false;">Show</button>
              </form>


texts: Function to transfer tokens to a second address with fixed percentage

texts:
I'm trying to code a transfer function that automatically sends tokens to a second address taking a specific percentage from the original sent value.
What I wrote:

  address public _ExtAddress;

  function setExtAddress(address _address) onlyOwner public {
    _ExtAddress = _address;
  }

  function setPercentage(uint256 value) onlyOwner public {
    percentage = value;
  }

  function findPercentage(uint256 amount) public view returns (uint256) {
    uint256 percentValue = (amount / 100) * percentage;
    return percentValue;
  }

  function transfer(address to, uint256 value) public returns (bool) {
    require(value <= _balances[msg.sender]);

    uint256 tokensToAddress = findPercentage(value);
    uint256 tokensToTransfer = value.sub(tokensToAddress);

    _balances[msg.sender] = _balances[msg.sender].sub(value);
    _balances[to] = _balances[to].add(tokensToTransfer);

    emit Transfer(msg.sender, to, tokensToTransfer);
    emit Transfer(msg.sender, _ExtAddress, tokensToAddress);
    return true;
  }

Testing it in remix, the output is:

 status     0x1 Transaction mined and execution succeed
 transaction hash   0x7d19e3fac8581083c75b3d04b3448daa2ac7d8cb76de56d9aae5cb2e70418018
 from   0xca35b7d915458ef540ade6068dfe2f44e8fa733c
 to     Test.transfer(address,uint256) 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a
 gas    3000000 gas

 transaction cost   39344 gas
 execution cost     16344 gas
 hash   0x7d19e3fac8581083c75b3d04b3448daa2ac7d8cb76de56d9aae5cb2e70418018
 input  0xa90...5e100
 decoded input  {
    "address to": "0xdD870fA1b7C4700F2BD7f44238821C26f7392148",
    "uint256 value": {
        "_hex": "0x05f5e100"
    }
}
 decoded output     {
    "0": "bool: true"
}
 logs   [
    {
        "from": "0x692a70d2e424a56d2c6c27aa97d1a86395877b3a",
        "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "event": "Transfer",
        "args": {
            "0": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c",
            "1": "0xdD870fA1b7C4700F2BD7f44238821C26f7392148",
            "2": "99000000",
            "from": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c",
            "to": "0xdD870fA1b7C4700F2BD7f44238821C26f7392148",
            "value": "99000000",
            "length": 3
        }
    },
    {
        "from": "0x692a70d2e424a56d2c6c27aa97d1a86395877b3a",
        "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "event": "Transfer",
        "args": {
            "0": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c",
            "1": "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C",
            "2": "1000000",
            "from": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c",
            "to": "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C",
            "value": "1000000",
            "length": 3
        }
    }
]
 value  0 wei

As you can see in the output there are two different Transfer event; the percentage is set to 1% and the amount transferred is 100000000. The hardcoded address that should receive the percentage is 0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C, and in logs it is actually receiving the 1%, but if I call the balanceOf function in remix it says it has 0 tokens, while the other address 0xdD870fA1b7C4700F2BD7f44238821C26f7392148 has exactly 99000000 as it should have. What am I doing wrong? Why the transfer event occurs but there are no tokens transferred to the second address?
Thank you


texts: Truffle Migrations | Same contract deployed multiple times

texts:
I'm using truffle migrations a lot, and I would like to deploy a contract twice during my migrations. Is it possible?
Nowadays, I'm using migrations like

const MyContract = artifacts.require('MyContract')

module.exports = deployer => {
  deployer.deploy(MyContract)
}

Is there any way to do something like

const MyContract = artifacts.require('MyContract')

module.exports = deployer => {
  const firstDeploy = deployer.deploy(MyContract)
  const secondDeploy = deployer.deploy(MyContract)
}

And then to fetch them easily in the rest of my application?


texts: Can a transaction be cancelled before it is picked up by the network?

texts:
Say a transaction is time-sensitive and the user that submitted it knows the transaction expires at block number X. User submits the transaction at block number X-4, sees the transaction does not get confirmed in any of the remaining blocks, and then knows the transaction will be a waste of gas if a future block picks it up.

Can the user say "Hey, nevermind, don't submit this!" or is that impossible?


texts: How can the web3 library be imported in a web application?

texts:
During the compilation of my JS code I used the statement Web3 = require('web3') for importing the web3 library. But since the require function doesn't work in a web application, I would like to know how it can be done.
Link


texts: geth node not seeing pending transactions

texts:
I'm running a geth node locally on goerli network in sync mode. I use the following command to boot the node :
geth --goerli --syncmode "light"

My txpool never list pending transactions, but I can see activity in almost every block : goerli etherscan
What Am I missing ? I guess every new transaction are broadcasted to the network to get in the new mined block. Why is my node never seeing one ?
I tried to submit a transaction to the network through my node. This one appeared in my local txpool and was mined ...
Any help appreciated !


texts: Uncaught ReferenceError: TruffleContract is not defined

texts:
I am working on a smart contract. When I try to serve my smart contract via lite-server I see following error in the browser console

Here my app.js source code: https://pastebin.com/UjFuYCyQ

I have tried installing TruffleContract separately but no luck.

App.js Code :

    App = {
  web3Provider: null,
  contracts: {},
  account: 0x0,

  init: function() {
    return App.initWeb3();
  },

  initWeb3: function() {

    if (typeof web3 !== 'undefined') {
      App.web3Provider = web3.currentProvider;
    } else {

      App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
    }
    web3 = new Web3(App.web3Provider);
    App.displayAccountInfo();
    return App.initContract();
  },

  displayAccountInfo: function(){
    web3.eth.getCoinbase(function(err, account){
      if(err === null){
        App.account = account;
        $('#accountId').text(account);
      }
    });
    return App.initContract();
  },

  initContract: function() {
    $.getJSON('Voting.json', function(votingArtifact) {

      App.contracts.Voting = TruffleContract(votingArtifact);

      App.contracts.Voting.setProvider(App.web3Provider);

      return App.reloadVoters();
    });
  },

  reloadVoters: function() {

    App.displayAccountInfo();

  }
};

$(function() {
  $(window).load(function() {
    App.init();
  });
});


texts: Manually specify extra gas amount required in solidity for apps such as metamask

texts:
I've had an issue with my first solidity contract whereby sometimes transactions  will work and other times I'll get "out of gas" errors. I believe after much research I've pinpointed this problem to the contract making extensive use of block.timestamp and "now" for pseudo-RNG purposes (which I'm aware of the limitations). Such function calls I hear make the exact gas required highly unpredictable.

Unfortunately during my testing on Ropstein, Metamask seems to fail about 30% of the time in predicting the correct amount of gas, and I run out of gas. I get no such errors when testing on testrpc or JavaVM (since obviously gas isn't an issue here).

I've thought that if I could somehow code in solidity a way to tell metamask that it should send a fixed amount "extra" gas, or if I could even define the exact gas amount to send, that these issues might be avoidable. If this isn't possible, how do other dapps get around using block.timestamp and metamask without running into these out of gas errors sometimes?

It's absolutely NOT a solution that the client must manually change their gas for my contract, since the dapp is designed to work flawlessly for every user. A lot of consumer engagement will no doubt be lost if I require my users to specify the gas limit in metamask themselves.

Is there any way around this issue whereby the user doesn't have to do anything?


texts: Using the non-modified OpenZeppelin code to create a mintable and burnable ERC20 token and a crowdsale contract, once ownership of the token is transferred to the crowdsale contract, is it possible to transfer ownership of the token again? If not, will it be possible to ever mint new tokens in the future? I want to ensure that once token ownership is transferred to the crowdsale contract and the crowdsale ends, it will never be possible to mint new tokens. I looked through the related questions, but could not find a definite answer relating to a non-modified implementation of the OpenZeppelin code.


texts: Contract calls don't return values sent with contract executions in DevelopmentChain mode

texts:
I'm using parity 1.5.2 dev chain.

./parity --chain chain.json ui

where chain.json is from default configuration

Test contract is:

pragma solidity ^0.4.9;

contract Test {
  event Ev(string key);

  mapping(string => string) mapp;

  function setMapping(string key, string val) {
    mapp[key] = val;
    Ev(key);
  }

  function getMappingVal(string key) constant returns(string) {
    return mapp[key].val;
  }

}

setMapping tx is immediately mined every time.
But events aren't sent sometimes. And getMappingVal returns an empty string at the same time.

The same contract works fine for every tx, for example, with Ropsten chain (--testnet).

How to fix this behaviour in dev chain?


texts: Miner not updated to Muir Glacier. Coins now in Ice-Age-Chain(?)

texts:
What happens if a miner processes my transaction that has not updated to Muir Glacier? Is it possible that I loose coins because the miner is still on the old chain so that the coins are now on the chain that ends up in ice age?

I am worried because I sent coins from an exchange to my wallet a couple of blocks after the fork (around 9'200'010). Maybe it was too early because some miners or infrastructure providers weren't updated at that time. According to "https://ethernodes.org/muir_glacier" still a lot of miners haven't confirmed the update.

So in general: could someone loose coins when doing transactions closely around the hard fork block height?


texts: Retrieve public key and check the signature with web3

texts:
I create a transaction with signTransaction
and I have an output like this:

"signedTx": {
    "messageHash": "0x..",
    "v": "0x..",
    "r": "0x..",
    "s": "0x..",
    "rawTransaction": "0x....."
},

Now I want to retrieve public key using v r and s And verify the signature


texts: Is it possible to convert ERC20/223 tokens to "coins" on another blockchain autonomously, securely and scalably?

texts:
Assume the following:

ERC20/223 tokens were sold to fund the creation of a new block chain based network.
The new network is now fully operational, and token holders can "convert" tokens into "coins" on the new network.
Once a token has been "converted", it becomes non-transferable in the original contract.

Would it be possible to implement such a system in a way that doesn't require human intervention and is secure and scalable?

One idea, is to define a "sink address" for tokens on the contract, then have a "daemon" watch for token transactions to that address and credit the token owners address on the new network with "coins" accordingly. The token owner would add their address on the new network to the transfer transaction as a parameter.

However, this approach seems like it would have scaling and security issues , since it depends on the "daemon" as a single point of failure.

I feel like there has got to be a better way to do this.


texts: Geth Contract Deployment Error : Contract transaction couldn't be found after 50 blocks

texts:
I have created a private blockchain and tried to deploy a simple contract on blockchain. But the deployment throws the following error -

Error sending/minig the transaction: {
    "message": "Contract transaction couldn't be found after 50 blocks",
    "name": "Error"
}


texts: How does specifying job parameters on Chainlink work?

texts:
I am trying to understand Chainlink, and I am running into a wall. I found this tutorial, which explains how I can create a job spec using JSON.

The tutorial explains that you can specify the url, path and multiply value yourself, while the official Chainlink documentation places these in the JSON, and does not require these to be added in the smart contract code.

How does Chainlink decide which parameter to place where? What if you have multiple HTTPGet tasks that take parameters?


texts: Getting error as Member "balance" not found or not visible after argument-dependent lookup in contract Lottery

texts:
I am trying one Lottery contract in that I am using one function which give me error.

 function pickAWinner() public restricted {
    require(this.balance >= 10 ether);
    uint index = random() % players.length;
    players[index].transfer(this.balance);
    players = new address[](0);
  }

Getting below error, Below error I am getting other contract also as "Member "balance" not found or not visible after argument-dependent lookup in contract" I think there is issue with 'balance' keyword. however I Unable to fixed it.

  Error:-TypeError: Member "balance" not found or not visible after
  argument-dependent lookup in contract Lottery. Use
  "address(this).balance" to access this address member.
    require(this.balance >= 10 ether);
            ^----------^

How can I fixed it?


texts:
Currently I'm using Ganache desktop application for ether transactions and I'm able to view transaction log details in it. But I need to connect it with metamask so that while an ether is transferred, details could be seen account wise. I passed the url  and mnemonic.

Account address in metamask were same as it is in ganache desktop application. When ether is transferred, account balance is reduced but no details are shown.

I tried by importing account in metamask using private keys...still the same result...

Help will be greatly appreciated.


texts: How to debug this metamsk error ? - Error: [ethjs-rpc] rpc error with payload:

texts:
I have a DApp integrated with metamask and ganache, front-end built on react. I am getting this error when I interact with the smart contract from front-end, contract send calls. Smart contract compiles fine and all the test passes.
So, to check the validity of Metamask connection, I tried the truffle petshop DApp; the same error still persists. I tried resetting account, re-installing metamask, creating new accounts - still facing the same error.
Following are the versions
metamask version: 7.7.9
web3.js version:1.2.7
Node JS version: v10.15.3
truffle version: 5.1.34
os: macOS 10.15.4
browser: Google Chrome 83.0.4103.113
MetaMask - RPC Error: Error: [ethjs-rpc] rpc error with payload {"id":6876026167411,"jsonrpc":"2.0","params":["0xf873048504a817c80083014cdc94ede8c1a58f1210c2075faa916cea1fed41cf24228829a2241af62c000084d0febe4c822d45a086ac8d46d13dc5f2f6d0b168e3a24bc140015f6bc6164ef330f145c68566fe61a042b9f3da876f8625fa3c35df4b5b0b96db9659b477162f5f29313d2d6879fddb"],"method":"eth_sendRawTransaction"} [object Object] {code: -32603, message: "Error: [ethjs-rpc] rpc error with payload {"id":68…method":"eth_sendRawTransaction"} [object Object]", stack: "Error: Error: [ethjs-rpc] rpc error with payload {…method":"eth_sendRawTransaction"} [object Object]"}

To recreate the issue please follow steps below
find the codebase here: (https://drive.google.com/file/d/1e-5APvS5otuT5Lf3s8X_LXR1vSInfBa0/view?usp=sharing)
after unzipping:
install dependencies: npm install
compile contracts: truffle compile
migarte contracts: truffle migrate
run the front end browser: npm run dev
access the dapp from browser at localhost:3000


texts: Why does address.transfer(amount) cost the same when sent to a new or used address?

texts:
In the Ethereum yellow-paper, it's specified that creating a new account costs 25000 gas (Appendix G, entry for Gnewaccount).

We can see this if, for example, we call a function that makes a transfer:

function test (address receiver) public payable {
        receiver.transfer(msg.value);
}

It costs 30356 if sent to an existing address and 55356 if sent to a new address.

The question is, why don't we see the same behavior if we make a regular ether transaction? Just calling receiver.transfer(msg.value); costs always 21000 gas no matter if the transaction is to a new or old address.

A new account is created, the same way as the function call, since is storing a new account on chain, shouldn't the cost be 46000?


texts:
I have this smart contract:

contract Truerec {
    struct Certificate {
        address issuerAddress;
        string  identityType;
        string  identityHash;
        string  dataHash;
        bool   revoked;
    }

    mapping(bytes32 => Certificate) certificates;

    function issue(string _key,
        string _identityType,
        string _identityHash,
        string _dataHash) {
        certificates[sha3(_key)] = Certificate(
            msg.sender,
            _identityType,
            _identityHash,
            _dataHash,
            false
        );
    }
    ...
}

How can I check whether a mapping already exists and by using that make sure that if the key already exists, that the existing mapping will not be overwritten?

I need something like:

function issue(string _key,
    string _identityType,
    string _identityHash,
    string _dataHash) {

    require(!key_exists(sha3(_key, certificates)]

    certificates[sha3(_key)] = Certificate(
        msg.sender,
        _identityType,
        _identityHash,
        _dataHash,
        false
    );
}


texts: If SNARKs are able to prove computations of arbitrary complexity and difficulty were executed correctly, would it be possible to use them to create a Proof of Work system where ANY computation can be the “work”? If you are able to develop a SNARK system that can somehow “measure” how much computational effort went in to any arbitrary computation and thus allow any program or computation to be able to be used towards the same Proof of Work consensus method? This would take the idea of “Proof of Useful Work” to the ultimate end, where one would simply use ones computers to run the same computation one would use them for anyway but have these SNARKs working on all of the computations measuring them and contributing to the consensus method, and reaping miner rewards.


texts: What happens if the electricity/internet is cut off while I'm mining?

texts: I live in an area where power-cuts or internet disconnections of ~5 minutes duration are common every couple of week or so. I'm planning to get a 6 GPU (RX470) mining rig for ethereum. If the electricity or internet connection will go out for 2 to 5 minutes once in a week or so, how much can I expect to lose?


texts: is there a way to make a private precompiled contract charge same gas as if it was a normal contract?

texts: so to avoid solidity i wrote a precompiled contract in geth  but now i want to know how much it would cost gas if it was a normal EVM contract ,is there a way to do that ?


texts: Parity RPC Mode Compatible with Geth RPC?

texts:
I have a program interfacing with geth.  But now I have to move to a new server, and geth is taking too long to re-sync.

If I install Parity, will the program that interfaces with localhost:8545 work with no changes?


texts: Problem storing more than three variables in a mapped struct

texts:
I'm trying to store a dataset into a mapped struct. After adding more than 3 variables, seems type unspecific, the dataset is not stored anymore. I don't get any errors. Does this has to do something with memory? I'm using embark in a local testchain, so gas seems not to be the problem.
Here the sample code:

pragma solidity ^0.4.2;
contract test {

  struct Tree {
        int value1;
        int value2;
        int value3;
        int value4;
    }

  mapping(int => Tree) public dataItems;

  function addDataItem(int _value0,int _value1,int _value2,int _value3,int _value4) external {
        dataItems[_value0].value1= _value1;
        dataItems[_value0].value2= _value2;
        dataItems[_value0].value3= _value3;
        dataItems[_value0].value4= _value4;
    }

    function getvalue1(int _number) constant returns (int) {
        return dataItems[_number].value1;
    }
    }

When value4 is removed everything seems to work. Is there a right / other way to do this?

solc --version
solc, the solidity compiler commandline interface
Version: 0.4.4+commit.4633f3de.Darwin.appleclang
Geth
Version: 1.5.3-stable
Git Commit: 978737f5d51ee4e60c00afb0c4ac8784b2faa059
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.7.3
OS: darwin
GOPATH=
GOROOT=/usr/local/Cellar/go/1.7.3/libexec

Edit: This is a running out of gas problem as suggested by @BokkyPooBah. Adding additional gas in embark can be done like this:

test.addDataItem(1,1,1,1,1,{gas:150000})


texts: Why 51% hash power require to control the network?

texts: Why 51% is explicitly mentioned to get control over the network?. Why not 50 or lesser ?. Anyway there is no central authority to decide, whether 51% is attained or not?.


texts: Gas cost for Ether transfer to Smart Contract from EOA

texts:
It is pretty clear that Ether transfer between accounts is 21,000 gas. Does the same apply for transferring Ether to Smart contract address, or does transfer from EOA to Smartcontract cost more gas?
I tried to transfer Ether from an EOA to a Smartcontract with 21,000 gas and its failing with out of gas exception.


texts: eth.blockNumber does not match any network's current block

texts:
I set up a geth full node on Rinkeby with the following command: /usr/bin/geth --syncmode fast --nousb --cache 3072 --trie-cache-gens 1024 --rpc --rpcaddr 127.0.0.1 --rpcport 8545 --networkid 4 2>&1

(Geth is version 1.8.12)

This should be Rinkeby, although when I get the current block:

> eth.blockNumber
3922099

This doesn't seem to match what's on Etherscan, where the most recently mined block as of this posting was 2601444 for Rinkeby, 3596981 for Ropsten, 5930232 for mainnet.

> eth.syncing
{
  currentBlock: 3922035,
  highestBlock: 3922099,
  knownStates: 11714163,
  pulledStates: 11714163,
  startingBlock: 0
}

In addition, Rinkeby's ChainData size should by ~50GB if I'm not mistaken, and:

$ du -sh chaindata
13G chaindata

So I'm scratching my head a bit: what accounts or the discrepancies in blockNumber and ChainData size?

Any thoughts are greatly appreciated!


texts: When storing values in mappings in solidity, will it take the same storage size for uint8 and uint16? I.E all uint's take up the same storage space?


texts:
I know how to create wallet manually, however I would not like to take my clients out of website (I doubt anyone would) and would rather do their wallet creation behind the scenes when they register on website.

At first I was thinking of building wallet creation myself, but then it hit me that everyone who is trying to build a system for non technical users will try to do the same - generate wallet behind the scenes... and that someone very likely has built an API to do this already...

Is there an API to create Ether wallet?


texts:
I'm struggling to retrieve my current ETC balance using geth.

For mining I'm running:

ethminer -F http://etc-eu1.nanopool.org:18888/<ADDRESS>/<NAME> -G

Syncing the blockchain with geth:

geth --rpc

The first ~0.2 ETC have been transferred from Nanopool which I can see in the transaction history.

geth attach
> eth.getBalance(eth.accounts[0])
> 0

I'm guessing this actually returns the ETH balance and not the ETC balance but I'm lost how to retrieve the latter and subsequently transfer ETC to one of the exchanges.

Any help is much appreciated.


texts: Do i need to be synchronized to blockchain when creating DAG for mining on pool?

texts: When mining for pool, the DAG has to be created. Before starting mining and DAG creation do i need to be synced to blockchain?


texts: Issue with sendRawTransaction for contract Function calls

texts:
I have created a sample token contract (https://www.ethereum.org/token#minimum-viable-token) with balanceOf and transfer functions. When I use eth.sendTransaction to transfer tokens from one account to another, everything works as expected. When I use eth.sendRawTransaction (by signing offline with private key of sender) for the same transaction, the transaction gets mined but surprisingly the tokens are not transferred.

I have logged both the transactions using eth.getTransaction(), I am unable to find the issue.


texts: How it is possible to keep multiple copies of same transaction data at multiple nodes forever?

texts:
I have read about DApp "decentralized applications" & Blockchain but still I am unable to understand how multiple nodes can keep whole history of all transactions forever?

After some time when there will be lot of transactions, will not it slow down the whole system & create following problems?

Huge Calculation & Processing Requirements
Huge Storage Requirements

What is the current strategy to handle these challenges in future?


texts: Is it possible to sign transactions offline in Mist?

texts:
is this planned to be implemented? Would be great to be able to sign transactions securely on an air-gapped machine.

I understand that IceBox has offline signing, but they don't support contracts/multisig and custom tokens.


texts: Quick question: can a function send multiple tokens?

texts: And by the question I mean if I can send a couple of few different ERC20's or let's say even 1 ERC20 + some amount of ether in one function?


texts: Can I generate multiple wallet addresses using one keystore?

texts:
I am trying to generate multiple wallet addresses using single keystore file. Can someone please advise me if it is possible? OR one keystore can only have one wallet address?

I generate keystore and account simply by using following code

ks      := keystore.NewKeyStore("./dir", keystore.StandardScryptN, keystore.StandardScryptP)

// Create a new account with the specified encryption passphrase
newAcc, err     := ks.NewAccount(password)

// Return address & array
return newAcc.Address.String(), err

Issue that I am facing is that each time a new file is created due to function NewKeyStore. I am unable to find a suitable function in keystore.go that takes filename as path

Please help.

Thanks


texts: How long can I expect to wait for a 20 gwei ERC20 launch?

texts:
Here's the transaction: https://etherscan.io/tx/0x9e34257bbb18e565a2154eb522085a30720e327b065342b5708c089d23e190cb
I'm spending 20 gwei per unit of gas. This is all I could afford, I only have 10 dollars in ether. How long will it take for this token to launch? I'm new to crypto, so will I have to pay this much every time I transfer crypto? Thanks!
Edit: Thanks for the response, I put in bold the most important part of the question. also, I was just wondering if 20gwei was reasonable, or it would be worth the money to increase the gas price.


texts: If the execution of a smart contract requires sending ether to some account, do all full nodes do so when validating a mined block with that contract?

texts:
I am a bit confused by one aspect regarding all full nodes validating a mined block. The descriptions say that the EVM in each full node runs any contracts contained within that block so that they all reach the same end state.

If I have a contract which pays out ether to a certain party, does it mean that all the nodes pay out ether to that party during the process of validation?

This seems unlikely; so who does the actual payout required by the contract? Is it only done once during the process of mining?

And, if so, what do the full nodes do when they reach the payout step in the code that they also run during validation?

Thanks in advance for your help explaining this to a newbie.


texts:
How can I compare two arrays in Solidity (with Truffle test framework)?

MyContract.sol --

pragma solidity 0.4.19;

contract MyContract {
  uint[] public myArr;

  MyContract(uint[] _initArr) public {
    for (uint i=0; i < _initArr.length; i++) {
      myArr.push(_initArr[i]);
    }
  }

  function getMyArr public constant returns (uint[]) {
    return myArr;
  }
}

In Truffle test/TestMyContract.sol

pragma solidity 0.4.19;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/MyContract.sol";

contract TestMyContract {
  function testMyContract() public {
    uint[] storage expectedArr;
    expectedArr.push(0);
    expectedArr.push(1);
    expectedArr.push(2);

    MyContract myContract = new MyContract(expectedArr);

    Assert.equal(myContract.getMyArr(), expectedArr, "pass");
  }
}

"truffle test" gives error --

TypeError: Member "equal" is not available in type(library Assert) outside of storage.
        Assert.equal(myContract.getMyArr(), expectedArr, "pass");
        ^----------^

Is there a way to write unit test for Solidity arrays?


texts: Can a smart contract set a variable from an other known smart contract?

texts:
I have the following setup here, simplified, but still demonstrates my problem.

Let's assume I have a UserA and UserB which have a wallet and a smart contract respectively. Each User deploy his own smart contract.

UserA.sol

pragma solidity ^0.4.2;

contract UserA {

  address public owner;
  address public user;
  address public SCAddress; //address where UserB has mined his contract

 function UserA(string _provider,address _user,address _scaddress) {
        owner = msg.sender;
        user = _user;
        SCAddress = _scaddress;
    }

  function setColor(string c) { //want to set the color of UserB from here
    if (msg.sender == user) { // check if it is userA
             color = c;
        }
    }

UserB.sol:

pragma solidity ^0.4.2;

contract UserB {

  address public owner;
  address public user; //userA wallet address
  string public color;

 function UserB(address _user) {
        owner = msg.sender;
        user = user;
}

function chooseColor(int number) constant returns (string color) {
            if(number == 1){ return "red";}
            else if(number == 2){ return "blue";}
            else if(number == 3){ return "green";}
    }
}

UserB.js

var Web3 = require('web3');

//connect to testRPC / Geth locally
if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    // set the provider you want from Web3.providers
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

// Checking Ethereum connection status
if (!web3.isConnected()) {
    console.error("Ethereum - no conection to RPC server");
} else {
    console.log("Ethereum - connected to RPC server");
}

var userbABI = ;// lets assume I have it
var userbAddress = ;// lets assume I have it

var userbContract = web3.eth.contract(userbABI);
var userbSC = docContract.at(userbAddress);

var result = userbSC.chooseColor.call(1); //red
//Now I want to save this result with UserA calling setColor()
userA.setColor(result);

My constrains:

Only UserA is allowed to modify color.
Only UserB is allowed to call setcolor() trough UserA ABI.

My questions:

Can a smart contract set a variable from an other smart-contract?
Is my idea feasible or is it completely unrealistic?

I know right now, that UserB is not allowed to call setColor() since msg.owner =/= UserB but to UserA.

Thank you for your valuable time and help.


texts: Is there any lifespan of data on Rinkeby testnet?

texts:
I read that there are pre-autorized nodes which creates blocks on rinkeby testnet.
If developers keep publishing smart contract and do transactions for testing purpose isn't the size of testnet will be huge after a time?
My question is for all testnet.
Is there any lifespan of data that after some time data will delete automatically?


texts: explanation of appending .selector in solidity smart contracts

texts: I'm trying to understand what .selector means when appended to logic wrapped up inside of functions definitions. I've tried to read the section in soliditydocs, but it doesn't seem to answer my question?


texts: During the POW/POS transition, why would a POW miner choose to mine on the chain with the POS consensus algorithm?

texts:
As the title says, what incentive does a POW miner have to mine on the hybrid POS chain? They would, effectively, be removing their own economic incentive from the consensus mechanism. I understand the long term benefits of a POS consensus mechanism, but a miner has no incentive to want to switch until the last possible moment, or when POW simply cannot keep up with the needs of the network.

Might this cause a fork where one chain remains 100% POW and the other chain has a hybrid POW/POS model?


texts: Can I get from a transaction to contract state changes using RPC API

texts:
If I'm talking to geth using the JSON RPC API, I've found a transaction I'm interested in and I can see that it is calling a contract (data in the 'input' part of the transaction object.)

Can I then figure out what changes to balances are as a result of this invocation? I don't see anything on the TransactionReceipt object.


texts: Convert from ether to wei using go-ethereum

texts:
Is there any function in go-ethereum, which can convert values from ether to wei and vice-versa?

I should notice, that I'm not using geth as standalone app, I'm using go-ethereum as imported libraries to my golang app, so using console is not an option

I want to ask if go-etherum has some converter function inside it, or, probably, someone know other non-official library at go, which can convert Ethereum values.


texts: How does Etherscan.io get all the transaction records for an address?

texts: From my understanding, to get all the transaction records related to a certain address, you have to scan the whole blockchain and examine every transaction, which could take a loooong time. However it seems Etherscan.io can show all the transaction records related to an address almost instantly. So how did they accomplish that? Did they scan and store the transaction records in a centralized database? Does that mean the transaction records shown in Etherscan.io are not fetched in real-time from the blockchain, thus not really reliable (as centralized database is susceptible to hacks and abuse, which is exactly what blockchain tries to avoid)?


texts: I'm trying to create an app that allows people to exchange ether between themselves but I have the error: "web3.eth.transact is not a function"

texts:
<!DOCTYPE html>

    <meta charset="utf-8">

    <title>dEnergy</title>

    Power you generated
    <input id="Power_generated" type="text">
    Trade ether
    <input id="value" type="text" value="Enter amount">
    <input id="recipient"type="text" name="" value="Enter recipient">
    <button id="etherSend"type="button" name="button" value="Send"></button>
    <button id="setYourPower"type="button" name="button"></button>
    Browse


texts: How to get ETHER off the chain and into account?

texts:
I did a test and sent ETH (6) to my ETH account, but they dont show up in the account balance, however ETH and ETC both show on the etherscan.io
 how do I get them in the account and I never set up a wallet because it says I need to have a balance before I can make that contract... so I could goto myetherwallet and make a seperate wallet for free by following instructions/zip offline etc. but I still dont know how to take my ETH and ETC off the chain, I have a bit of ETH on coinbase but no address to send it to yet...besides the one i cant get off da chain...


texts: The below code gets compiled but when foo is called invalid opcode error is thrown

texts:
pragma solidity >=0.5.0 <0.7.0;
contract Mycontract{
    uint256 a;
    struct User
    {  string name; }
    User[] users;
    function foo() public{
      User storage user=users[0];
      user.name="hey";
    }
    function get() public view returns(string memory)
    {   return users[0].name; }
}


texts:
I've $15 in one wallet and $2 in another. I've used smart contract to transfer the funds.
Now, the problem is that - on Etherscan, there's "Write Contract" method and under that - cast method.
Cast method is asking for - Cast, Targets address, Datas Bytes and Origin.
I have the authority over the smart contract, so how can I interact with it properly?
Thanks


texts: Specify an alternative node (IP:Port) for Drizzle, if there is no MetaMask or Web3-enabled browser

texts:
Drizzle will automatically use the injected Web3 object. But if there is now Web3 object, Drizzle will try to connect to ws://127.0.0.1:8545'.

How to configure Drizzle to connect to Infura.io for example?


texts: is data structures necessary for a blockchain developer?

texts: I want to know if i had to study data structures and algorithms for being a blockchain developer or a smart contract developer


texts: Nesting Design Pattern given Solidity Limitation

texts:
What I have so far

I have a Validator contract that is supposed to insert a key-value pair in the database contingently on a particular invariant being satisfied.

contract Validator
{
   DataBase dataBase;
   Aggregator aggregator;

   function Validator(
       DataBase _database,
       Aggregator _aggregator
   )
   {
      database = _database;
      aggregator = _aggregator;
   }

   function insert(uint key, uint value)
   {
     dataBase.insert(key, value);
     assert(aggregator.ComplexFunction() > 0);
   }
}

I have a contract Aggregator (with various internal functions used as subroutines) which computes a complex function that necessitates informations from the DataBase and from an ExtraInfoProvider (which is a preexisting contract that I did not write).

contract Aggregator
    {
        DataBase database;
        ExtraInfoProvider extraInfoProvider;

        function Aggregator(DataBase _database, ExtraInfoProvider _extrainfoProvider)
        {
           database = _database;
           extraInfoProvider = _extraInfoProvider;
        }

        function ComplexFunction()
        {
          // Compute complex function which involves iterating over
          // all of the key-value pair in the database and consulting
          // the ExtraInfoProvider

        }
    }

Finally I have a DataBase which supports iterating over the keys: note the use of getKeyCount and getKey to get around the impossibility of returning dynamically sized array in Solidity; (experienced solidity programmers are probably very familiar with this)

contract DataBase
{
    function getKeyCount() returns (uint keyCount);

    function getKey(uint index) returns (uint key);

    function get(uint key) returns value;

    function insert(key, value)
}

The problem with this organization is the complex nesting between the classes, which is reflected by the impossibility of creating clean unit-tests.

I would like to be able to create a MockDataBase and a MockAggregator in order to be able to cleanly UnitTest my Validator class without having to pass an instance of MockDataBase to the MockAggregator

What I would like to have

In an ideal world where Solidity supports passing  dynamic arrays AND structures between contracts you could do something as follow:

struct KeyValuePair
{
    uint key;
    uint value;
}

contract Validator
{
   DataBase dataBase;
   Aggregator aggregator;

   function Validator(
      DataBase _database,
      Aggregator _aggregator
   )
   {
      database = _database;
      aggregator = _aggregator;
   }

   function insert(uint key, uint value)
   {
     dataBase.insert(key, value);

     KeyValuePair[] pairs = database.getAllKeyValuePairs();
     assert(aggregator.ComplexFunction(pairs) > 0);
   }
}

This would allow me to cleanly mock the Aggregator and the Database.

How could I achieve this result given the constraint present in Solidity?

(I could collect keys and values and create 2 dynamic arrays in the Validator and pass them to the Aggregator, but I do not like the idea of passing two arrays which are supposed to by in sync).

This is not entirely about testing

I don't intend to start an argument between Classicists and UnitTester: I perform both UnitTest and organic tests with real objects on my contracts.
This is not entirely about testing: I am concerned about the pattern above as a general code smell.

I don't like the necessity for synchronization between the Aggregator and the Database: for example, if I want to augment my system to allow contracts upgrades, it would be way easier to substitute my Aggregator and my DataBase independently if they did not have mutual dependencies.


texts: TheGraph with Compound v2 is returning my mainet wallet address as null

texts:
When querying the following with the thegraph playground (compound v2)
    {
  account(id: "address here") {
   id
    totalBorrowValueInEth
  }
}

returns
{
  "data": {
    "account": null
  }
}

but my wallet is connected with compound.finance app, what am i missing?


texts: What are "if" and "this" in this function?

texts:
function() public {
  if(delegate.delegatecall(msg.data)) {
    this;

What are the requirements for "if" to execute "this" and what does "this" refer to in this function?


texts: Error while retrieving transaction count

texts:
I am trying to retrieve the total transaction count of an address using java, web3j and Infura as the Ethereum client. My code is as below:

EthGetTransactionCount txnCount = web3j.ethGetTransactionCount(infuraAccessToken
            ,DefaultBlockParameterName.LATEST).sendAsync().get();
    BigInteger nonce = txnCount.getTransactionCount();
    System.out.println("Transaction Count "+ nonce);

But I keep getting the following error:

    Exception in thread "main" org.web3j.exceptions.MessageDecodingException: Value must be in format 0x[1-9]+[0-9]* or 0x0
    at org.web3j.utils.Numeric.decodeQuantity(Numeric.java:32)
    at org.web3j.protocol.core.methods.response.EthGetTransactionCount.getTransactionCount(EthGetTransactionCount.java:13)
    at com.mycompany.hellospring.NewClass.main(NewClass.java:46)

I am unable to find any solution related to this till now.


texts:
I have defined a fallback function to accept ethers, so that anybody can send ether's simply with send. But this is not working, if anybody send ether's to my contract, Transaction goes successful but account balance remains same, no deduction of gas fee. So contract does not receive any ether's.
Code of fallback Function:

function () payable {
        PayableCalled(true)   //event registered to ensure that function was called
        if (crowdsaleClosed) throw;
        uint amount = msg.value;
        balanceOf[msg.sender] = amount;
        amountRaised += amount;
        Transaction(msg.sender,msg.value,amountRaised)
        tokenReward.transfer(msg.sender, amount / price);
        FundTransfer(msg.sender, amount, true);
    }

while trying to debug this issue, I have made sure that there is only one fallback function, I also increased gas. I have also checked there are no pendingTransactions. In transaction data field is also nil. How can I solve this issue? why fallback is not accessible?
Network:
Private network, geth v 1.6

Updated:
Contract:
First of all I deployed contract for custom token and saved its address for sharing with crowdfunding contract in future. Next I deployed contract for crowdfunding. Whose payable is not working. I have also added contract address to custom token allowance list. Custom token contract is working.


texts:
I'm trying to invoke a function by interacting 2 contracts. I defined 2 contracts ArrayTes and  CallFunction within same file. CallFunction is calling a function secfun from contract ArrayTes

Intercontract.sol

pragma solidity ^0.4.23;

contract ArrayTes {

    uint256 public l;

    function secfun(uint256 a) public view returns(uint256) {

        l = l+a;
        return l;
    }
}

contract CallFunction {

    ArrayTes at;

    function CallFunction(address _t) {
        at = ArrayTes(_t);
    }

    function thirdfun(uint256 a) public view returns(uint256 c) {

        c = at.secfun(a);
        return c;
    }

}

But c is always returned as zero. I tried defining contracts on seperate file and importing it.

ArrayTes.sol

pragma solidity ^0.4.23;

contract ArrayTes {

    uint256 public l;

    function secfun(uint256 a) public view returns(uint256) {

        l = l + a;
        return l;
    }
}

CallFunction.sol

pragma solidity ^0.4.23;

import "./ArrayTes.sol";

contract CallFunction {

    address useraddress;
    constructor(address _t) public {

        useraddress = _t;
    }

    function thirdfun(uint256 a) public view returns(uint256 c) {

        ArrayTes instanceuser = ArrayTes(useraddress);
        c = instanceuser.secfun(a);
        return c;
    }

}

2_deploy_contracts.js

var ArrayTes = artifacts.require("./ArrayTes.sol");
var CallFunction = artifacts.require("./CallFunction.sol");

module.exports = function(deployer) {

    deployer.deploy(ArrayTes).then(function() {

        return deployer.deploy(CallFunction, ArrayTes.address);
    });
};

Still c value is returned zero. useraddress from CallFunction is returned as '0x'. When I commented code lines c = instanceuser.secfun(a);from CallFunction correct contract address ie; useraddress was returned.  This code worked for me around 6 months back. Now its not working. I can't figure out the issue.Help will be appreciated :)


texts: How to interact with the functions of my smart contract in Hardhat?

texts:
I am learning to program in Solidity and have followed a basic tutorial on creating a smart contract from a number counter. The tutorial was followed by using Remix and I was very clear about the structure of the code, the deployment and most importantly the interaction with the functions of my contract through this part of REMIX (next image)

In this section I can interact with the reading and writing functions of my contract.
Now I am trying to perform the same exercise using Hardhat, as I want to know better the whole process of developing a smart contract. I have been able to create my project as well as write the code of my contract again and compile the contract using the command npx hardhat compile but I do not understand how to perform the deployment (in the blockchain that comes with hardat) and more importantly see the part where I can test the functions that my contract has.
From what I have read so far, the process in Hardhat would be to create a test within which I define the calls to my functions and display the results using console.log () - this would be correct, some example link would be appreciated.


texts: How to Accept/Issue varying Ether/token amounts in token contract?

texts:
I am trying to create an erc827token contract that accepts varying amounts of ether (0 for airdrop,   0.001, 0.002       >>    for donations.

code::

contract Airdrop coin is ERC827Token, Ownable {
  string public constant name = "SimpleToken"; // solium-disable-line uppercase
  string public constant symbol = "SIM"; // solium-disable-line uppercase
  uint8 public constant decimals = 18; // solium-disable-line uppercase

  uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));

  /**
   * @dev Constructor that gives msg.sender all of existing tokens.
   */
  constructor() public {
    totalSupply_ = INITIAL_SUPPLY;

  }

  function getAirdrop() external payable {
    if (msg.value < 0.005 ether) {
       balances[msg.sender] += 4000;
      } else if ( (msg.value >= 0.005 ether) && (msg.value < 0.008)) {
          balances[msg.sender] += 9000;
       } else if ( (msg.value >= 0.008 ether) && (msg.value < 0.016)) {
          balances[msg.sender] += 13000;
       } else balances[msg.sender] += 25000;
}

problem::

Deploying this contract works, but tokens don't get credited to addresses that send ether to the token contract.

How do I amend the contract to produce expected behavior and how do I forward recieved eth to an external wallet ( i.e implementing something like function withdraw() public onlyowner{})?


texts: Securing --rpcaddr endpoint on Go Ethereum node

texts:
I have been connecting nodes to a PoA blockchain based server and the only way I could get it to work was to specify the server address in the geth connection string as follows -

 --rpcaddr xx.xxx.xx.x

I understand this allows anyone to access the node. It is a private network and it seems to me I have now created a security hole.

Is there a way to actually allow access from my own server but deny access to others? So I want in effect a server IP list and to allow the approving server for new nodes to restrict access to just those IPs.


texts: Getting an error in attempting to write a withdrawAll function to remove any tokens that get sent to a contract

texts:
I am using remix: I have this function in my contract:
contract Control {
address public owner;
address public newOwner;

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

function Owned() public {
    owner = msg.sender;
}

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

function withdrawAll() public payable onlyOwner {
    require(payable(msg.sender).send(address(this).balance));
}

}

But I'm getting this error with the withdrawAll function:
test token V2.sol:84:17: ParserError: Expected primary expression.
require(payable(msg.sender).send(address(this).balance)); ^-----^

did i forget a varible or is this just a syntax error? The script works, but this function I just want to be able to call to withdraw anything that gets stuck at this address.


texts: Getting "TypeError: Name has to refer to a struct, enum or contract." when importing contracts

texts:
I have a contract Example, which imports another contract Another. When I try to import the contract and declare it in the code like this:

import './Another.sol'

contract Example {

    Another Another;

}

I get the above type error. The contract definitely exists, and I've done this pattern before, why am I getting this type error?


texts: full stack dapp clone example elastic supply algorithmic stablecoin

texts:
I'm new to vyper (but have some python experience), I would like to clone a very simple dapp to have a look at the full stack of an ethereum dapp from back end (write compile and deploy a simple contract) to an internet site as a front end facing the internet. where to find an example to have a look at all the details, to better understand all the components involved in the pipeline, and how they interact?
(if this is not the right place to ask, where should i ask?)
(I have a preference for elastic supply algorithmic stable coins as example)


texts:
Yesterday evening, an individual(at a french meetup haha) asked me what ethereum was and kept asking me if there was something similar to MIME types on Ethereum. I did not know what MIME types were and so asked and he said 'It's part of a specification that standardizes the nature and format of a document).

The reason for this question was, if someone were to say, scan through the blockchain running any code that looks familiar(say, starts with html) but was malicious, there would be no way of knowing.

Is there any reason to be concerned about this? Is there a way this can/is already circumvented?(I'm thinking an EIP)

He also mentioned NATSPEC's efforts in trying to do something similar for browsers


texts:
Currently, i am using web.utils.isAddress function to check whether ETH Address is valid or not. Is it right?

Thanks in advanced.


texts:
Let's say I want to facilitate transactions between two parties, and if there is one user who gives payment information, such as their bank account in USD, I'd like to exchange that into ETH automatically, then proceed with the transaction. 2 Questions:

How can my dapp automatically (within a few minutes) perform the exchange?
Can I use the same method solving question 1 to payout an ETH transaction as USD to someones account?


texts: Are balances of all accounts in memory or disk (storage)?

texts:
I simulated two contracts that sending balance to another and simply setting value of a variable(var a = 5;). In contrast my expectation, {var a = 5;} contract consumed more gas than the other.
 In my understanding, balance of accounts are stored in another place(i guess in memory), but general state(such as var a) are stored in disk(storage). Is it right? Or the other factor affected this results?


texts: How to send ether to a contract in truffle test?

texts:
For some reason I cant figure out how to send ether to a contract when testing in truffle. This is my attempt:

 await myContract.send(10, {from: accounts[0]});

the error message is:

 Error: VM Exception while processing transaction: revert

I get the same error message if I try:

 let txHash = await web3.eth.sendTransaction({from: accounts[0], to: myContract.address, value: 10 });

Any idea how to get this to work?

Thanks!


texts: As seen as a label for EIPs (Ethereum Improvement Proposals): https://github.com/ethereum/EIPs/labels/ERC


texts: How to find out how events are implemented in Solidity (event TokenPurchase)?

texts:
https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/crowdsale/Crowdsale.sol

I am trying to implement a presale contract, I saw the above link. I am confused by this line -

 event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

I cannot find TokenPurchase coded anywhere except here -

   TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

I cannot find where TokenPurchase is implemented. Has anyone any ideas?


texts:
I am using geth client (VERSION: 1.4.12-stable-421df866)
to sync to the Ethereum testnet. To check the status of the sync, I ran web3.eth.syncing in the geth console. This is the output I see:

{
    currentBlock: 1743872,
    highestBlock: 1744966,
    knownStates: 1193229,
    pulledStates: 1143482,
    startingBlock: 1732018
}

Every time I check the status, knownStates value keeps going up.

What does knownStates mean in the above output?
How do I find out how far I am from being completely in sync with the testnet blockchain?


texts: Why did Ethereum opt for Solidity instead of SDKs for popular languages?

texts:
It seems to me like creating and maintaining a new language would be much harder than creating and maintaining one or a few SDKs.

And judging from what people write about it and the exploit used to rob the DAO they have far to go to make it easy to develop secure applications in Solidity.


texts:
Why throw is deprecated in solidity?

Is there any drawbacks?

I also found below on Github

Even if we remove throw as a feature, the keyword should be kept. We might be able to introduce something in the future.

So what type of implementation will be done by throw in future? Is there any proposal set for this yet? Is there any documentation where I can find details related to this?


texts: contract has not been deployed to detected network (network/artifact mismatch)

texts:
Why can't deployed contract be found?

My node:

admin.nodeInfo
{
  ...,
  protocols: {
    eth: {
      difficulty: 36521801351,
      genesis: "...",
      head: "...",
      network: 3
    }
  }
}

network 3 from truffle networks:

Network: development (id: 3)
  Migrations: 0xfa79df82dce04e1a894df648f4f20af5a59f42f8
  WhaleNetworkV2: 0x93e21793323f9d3053b6a2bd2ab4234948aec210

in compiled contracts json file:

"networks": {
    "3": {
      "events": {},
      "links": {},
      "address": "0x93e21793323f9d3053b6a2bd2ab4234948aec210"
    }
  }

The code from which this error comes from:

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

console.log("provider", web3.currentProvider);

whaleNetworkV2 = contract(WhaleNetwork);
whaleNetworkV2.setProvider(web3.currentProvider);

whaleRewardsV2 = contract(WhaleRewards);
whaleRewardsV2.setProvider(web3.currentProvider);

let whaleNetworkContract;
let whaleRewardContract;

web3.eth.getAccounts((err, accounts) => {
    if (err != null) {
        console.log("There was an error fetching your accounts.");
        return;
    }

    if (accounts.length == 0) {
        console.log("Couldn't get any accounts! Make sure your Ethereum client is configured correctly.");
        return;
    }

    whaleRewardsV2.deployed().then((result) => {
        console.log(result);
    }).catch((error) => {
        console.log("whaleRewardsV2", error);
    });
});

The above code outputs:

  provider HttpProvider {host: "http://localhost:8545", timeout: 0,
  connected: false} contracts.js:38 whaleRewardsV2 Error: WhaleRewardsV2
  has not been deployed to detected network (network/artifact mismatch)
      at modules.js?hash=d495843d4bdb24e9ee23d52d143d36f9c62487b7:14057
      at meteor.js?hash=cbcc712d51de4298c275e8dcf25c66c29914f19a:1167
      at

Happens on both server and client.


texts: automate geth setup: automate addition of enodeInfo url of other peers

texts:
I am trying to setup multiple geth nodes on multiple docker containers. I am using a script that can initialize a genesis json file and start geth. After that, I am doing the following manually (and I want to automate them via a JS script which I can call while starting geth):

creating and unlocking user account.
adding other peers. Here, can I have a customer admin.eNodeInfo URL generated for each node? That way, I can automate the way I add the other nodes.Ex: if I hardcode node1's URL to
"enode://abcdef@ip:port"

and node2's URL to "enode://lmnopq@ip:port"

then I could have my script automatically setup node1 and node2 as peers. Else, I need to create node 1 and then manually update the JS script of node2 to pick up node1's enodeURL

I know I can use --bootnodes option, but that will only ensure that we tell geth at startup itself to connect to the other peers by providing the enodeURL of the other peers.

Please let me know.


texts:
I have a contract with a mapping inside a struct
contract Voting {
 struct voter {
   address voterAddress;
   uint256 tokensBought;
   mapping (bytes32 => uint256) tokensUsed;
 }
 mapping (address => voter) public voterInfo;
}

I want a function that returns voter information given an address. I found out I can not have a function return a Struct. So, I tried writing a function which returns tokensBought and tokensUsed like below:
function voterDetails(address user) returns (uint256, mapping (bytes32 => uint256)) {
  return (voterInfo[user].tokensBought, voterInfo[user].tokensUsed);
}

When I try to compile this code, I get the following errors:

Error: Type is required to live outside storage.
Error: Internal type is not allowed for public or external functions

Looks like I can't return mapping type in a function. How do I write a function that returns all the voter information?


texts: How could Banks or Accounting Firms use Smart Contracts?

texts:
I keep reading how banks and accounting firms are researching into blockchain tech specifically smart contracts, but I don't quite understand how a company will apply them to current work. One way I can think of is securing documents via cloud storage micropayment.

Can anyone explain how these firms plan on using smart contracts?


texts: What is the networkid and chain id of truffle cli?

texts:
I am using truffle console to deploy contracts and using Nodejs/web3js to interact with it.  I wanted to use ethereumjs-tx for signing transactions, here is the reference link. I am not sure how can I find the chain id and network id of the local blockchain for which I need to create rawtransaction. i.e

const customCommon = Common.forCustomChain(
  'randomchainNmae',
  {
    name: 'my-network',
    networkId: ???,
    chainId: ???,
  },
  'petersburg',
)


texts: Adding funds to multiple array addresses at once

texts:
pragma solidity 0.6.6;

import "./XYZToken.sol";
import "./SafeMath.sol";

contract Distribute is xyzToken {
    using SafeMath for uint;

    address[] addresses;
    mapping(address => uint256) public balOf;

    function addAddress() public {
        addresses.push(msg.sender);
    }

    function distributeTokens(uint amount) public  {
        totalSupply = totalSupply.add(amount);
        // Below this line is where I'm not sure how to add funs to each array address
        balOf(addresses[]).add(amount.div(addresses.length));
    }
}

So I'm trying to add funds to each array address at once. Say there were 10 addresses in the array. How would I be able "x" amount of tokens distributed to each address in the array all at once?


texts: Deploying a contract from Remix IDE, using from Truffle

texts:
As I understand, if I compile a contract via truffle compile to have the Contract.json, and then deploy the contract from Remix IDE to, say, Ropsten, the dapp should work via MetaMask pointed to Ropsten, no? But, for some reason, this is not working.

At the end of the day, I want to be able to deploy a contract to MainNet from Remix IDE, and then use Truffle as the UI to work with the dapp. Is there a way to do this?


texts: GETH configuration - what is the difference between '--testnet' and '--network 3'?

texts:
I'm reading GETH Command-Line Options Guide, which says:

--testnet            Ropsten network: pre-configured proof-of-work test network
--networkid value    Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, ...)

What exactly is the difference between --testnet and --network 3?

Do I have to use both, or can I use either one?

Thank you!


texts:
Some guy on reddit found an address with 235 ETH in his wallet. He was confused about how he managed to get so much ETH. Commentators told him that it is the global registrar object.

Here is an interesting snippet of his command line output:

namereg: {
    address: "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
    AuctionEnded: function(),
    Changed: function(),
    NewBid: function(),
    PrimaryChanged: function(),
    Registrar: function(),
    addr: function(),
    allEvents: function(),
    content: function(),
    disown: function(),
    name: function(),
    owner: function(),
    reserve: function(),
    setAddress: function(),
    setContent: function(),
    setSubRegistrar: function(),
    subRegistrar: function(),
    transfer: function()
}

What is namereg? What is the global registrar?


texts: How to preallocate multiple accounts with ether for geth --dev chain?

texts:
I'm trying to set up a private chain with geth using --dev that has several accounts with lots of ether. It seems unclear if this is possible anymore according to this.

Here's what I tried on geth 1.4.x and 1.5:

geth --datadir data --dev --password <(echo -n foobar) account new
geth --datadir data --dev --password <(echo -n foobar) account new
geth --datadir data --dev --password <(echo -n foobar) account new

Then init like so:

geth --datadir data --dev --password <(echo -n foobar) init custom.json

Then running geth with mine:

geth --datadir data --dev --password <(echo -n foobar) \
  --unlock 0,1,2 \
  --verbosity 6 \
  --rpc --rpcaddr "0.0.0.0" --rpccorsdomain '"*"' --nodiscover \
  --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" \
  --mine --minerthreads 1 --gasprice 0

Then I use curl to check the balance of the accounts. Result is 0x0.

If I remove the --dev option there is balance, but it takes forever as it then uses the real DAG. I don't want that as this if for testing.

How to best get multiple preallocated accounts with lots of ether for a private dev chain?

Thanks!


texts: How do I move an existing wallet into Parity?

texts:
My Ethereum wallet is malfunctioning and I want to move the Ethers into Parity. Not sure how though. I have the backup keys etc. of my existing wallet (Etherli).

Can anyone help?


texts: Unable to deploy my smart contracts on testnet (Ropsten) with ethereumwallet or with web3

texts:
I developed my smart contract using tesrpc. Now I want to deploy them on the testnet. But I am not able to deploy them either with EtherWallet (I have the error "No data is deployed in the contract address", even if I maxed the fees) or with a JS script using the web3 api where i set Gas to 4700000. But i have no smart contract address back.

My smart contract code is:

pragma solidity ^ 0.4.2;

contract Color {

address public contracts;
string public color;

function Color(address _c, string _color) {
    contracts = _c;
    color = _color;
}

function getContracts() constant returns(address contractAddress) {
    return contracts;
}

function getColor() constant returns(string color) {
    return color;
}

function setlastDirAddress(address c) {
        contracts = c;
    }

function setColor(string clr) {
        color= clr;

}

}

EDIT: Here is my JS script:

    var Web3 = require('web3');
var solc = require('solc');
const fs = require('fs');

//Globals
var colorContract = {
    abi: null,
    address: null
};

//connect to testRPC / Geth locally
if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    // set the provider you want from Web3.providers
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

// Checking Ethereum connection status
if (!web3.isConnected()) {
    console.error("Ethereum - no conection to RPC server");
} else {
    console.log("Ethereum - connected to RPC server");
}

//Setting up the account
web3.eth.defaultAccount = web3.eth.accounts[0];
var account = web3.eth.accounts[0];

function compileAndDeployColorContract() {

    var contractAddress = process.argv[2];
    var color = process.argv[3];

    let source = fs.readFileSync('./color.sol', 'utf8');
    let compiledContract = solc.compile(source, 1);
    let abi = compiledContract.contracts['Color'].interface;
    fs.writeFile('./colorABI.js', abi, (err) => {
  if (err) throw err;
  console.log('colorABI.js saved!');
});
    let bytecode = compiledContract.contracts['Color'].bytecode;
    let gasEstimate = web3.eth.estimateGas({
        data: bytecode
    });
    //run out of gas when using this
    let colorContract = web3.eth.contract(JSON.parse(abi));

    //Contract Object parameters
    var deployContractObject = {
        from: account,
        data: bytecode,
        gas: '4700000'
    };

    var colorSC = colorContract.new(contractAddress, color, deployContractObject, function(err, colorSC) {
        if (!err) {
            // NOTE: The callback will fire twice!
            // Once the contract has the transactionHash property set and once its deployed on an address.

            // e.g. check tx hash on the first call (transaction send)
            if (!colorSC.address) {
                console.log('ColorTransaction Hash: ' + colorSC.transactionHash) // The hash of the transaction, which deploys the contract

                // check address on the second call (contract deployed)
            } else {
                console.log('ColorContract Mined! address: ' + colorSC.address) // the contract address

            }

            // Note that the returned "myContractReturned" === "myContract",
            // so the returned "myContractReturned" object will also get the address set.
        }
        else { console.log(err);}
    });
}

compileAndDeployColorContract();

I already had a look here, here and here.

Thanks for your answers,


texts: Why txHash in sendSignedTransaction giving Undefined value on sending on rinkeby testnet

texts:
let Tx= require('ethereumjs-tx').Transaction;
const Web3= require('web3');
const url='https://rinkeby.infura.io/v3/d4dbc79ea192404fb42689cc55ce2fc0';
const web3 =new Web3(url);

const account1= '0x0B872d2A7F3Ca3bD24Ab1A9fe8FBC8059Ec32b5F';
const account2='0x20107D4a4e8BB5D50800288029ad58cE929D2c56';

//web3.eth.getBalance(account1,(err,bal)=>{ console.log(web3.utils.fromWei(bal,"ether"))});

//web3.eth.getBalance(account2,(err,bal)=>{ console.log(web3.utils.fromWei(bal,"ether"))});

const privatekey1 = new Buffer('A337E5C704CF4187C0CECF4A6E38AD42182B4D038EB8615E239216C5164FEB40','hex');
//const privatekey2 = Buffer.from(process.env.PRIVATE_KEY_2,'hex');

web3.eth.getTransactionCount(account1,async (err,txCount)=>{

//console.log(txCount);

//Build the transaction

const txObject ={
    nonce:web3.utils.toHex(txCount+1),
    to:account2,
    value:web3.utils.toHex(web3.utils.toWei('1',"ether")),
    gasLimit:web3.utils.toHex(210000),
    gasPrice:web3.utils.toHex(web3.utils.toWei('10',"gwei"))
}

//console.log(txObject);

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

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

web3.eth.sendSignedTransaction(raw,(err,txHash)=>{
  console.log(txHash);
})


texts: Can not convert real to uint in solidity (bug?)

texts:
I'm trying do do that:

uint teamRewardInTokens = uint((totalSupply / 85.0) * 15.0);
balances[teamRewardAccount] += teamRewardInTokens;
totalSupply += teamRewardInTokens;

before this code - totalSupply and balances are uint numbers.
But unfortunately after that -> teamRewardInTokens is a real number (i.e. 12.323232).

Can you please explain what is happening?
Thank you!


texts: Import unencrypted private key into ethereum wallet

texts:
I have an ETH adress.
I have an unencrypted private key.

How to import these in MyEtherWallet? Or another Desktop Ether wallet?

Don't answer with an howto for Mist or Geth, because I use MyEtherWallet, and I do not see any import function.


texts: Differences between nameFunction.value and address.transfer

texts:
What is the difference between using nameFunction.value(n)(parameters of nameFunction) and address.transfer(10)?

I know that in the case of address.transfer, I'll send the amount to the fallback function so that the contract has that amount in it. But in the first case, where is the amount sent?

And, as last thing, is nameFunction.value susceptible of reentrancy attack as address.call.value()()?

I am a little bit confused about this. Thank you.


texts: What is the point of this empty token contract?

texts:
I'm a little bit confused by the following code. Specifically, what the empty token contract does, and why it helps to create it. Is there no way to create an instance of a contract just by giving an address and then using the functions of that contract? Why do you need to create this empty code?

contract token { function give(address giveToAddress, uint amount) {} }

contract CrowdFund{

    token public rewardToken;

    function CrowdFund (
        string _name,
        address _sendTo,
        uint _durationInHours,
        uint _priceInEther,
        uint _minimum,
        token _rewardToken
    ){
        startTime = now;
        endTime = now + _durationInHours*60 minutes;
        name = _name;
        destination = _sendTo;
        tokenPriceInEther = _priceInEther*1 ether;
        minimum = minimumSend;
        rewardToken = _rewardToken;
    }

}


texts: How do I find the transaction success from a receipt?


texts: How can I delete values from nested mapping after a sum

texts:
I'm making an staking contract in solidity and i have used structs and nested mapping for saving users staking amount and its staking time,
At the time of calling unstake function msg.sender will withdraw his certain amount of deposited tokens.
for example:
a user has object of amount of tokens and its time of deposit.
amount : timestamp
[{100, 156354536}, {200, 156354537}, {300, 156354536}]
Now i want to withdraw or unstake 450 tokens and rest should be on their indexs.
Here's my code:
 struct Staking {
    uint value;
    uint stakingTime;
    uint reward;
}

mapping(address => Staking[]) public stakingInfo;

    // Unstaking Tokens (Withdraw)
   function unstakeTokens(uint _withdrawAmount) public {
       uint balance;
       uint internalWithdrawAmount;

     // Fetch staking balance
    for (uint i = 0; i < stakingInfo[msg.sender].length; i++) {
        balance = balance + stakingInfo[msg.sender][i].value;
    }

    // Require amount greater than 0
    require(balance > 0, "staking balance cannot be 0");

         // Fetch staking balance
    for (uint i = 0; i < stakingInfo[msg.sender].length; i++) {

            delete stakingInfo[msg.sender][i];
        }

    }

    // Transfer Mock Dai tokens to this contract for staking
    daiToken.transfer(msg.sender, balance);

    // Reset staking balance
    stakingBalance[msg.sender] = 0;

    // Update staking status
    isStaking[msg.sender] = false;
}


texts: Is geth --rpc --support-dao-fork still valid

texts:
I have the blockchain synced, and then tried to run  geth --rpc --support-dao-fork. I got a message saying that --support-dao-fork is unsupported command.
So I have run geth --rpc --syncmode "fast" --verbosity 3 --cache=1024 and then
Running etherminer -G from cpp-etherum it downloads the DAG and starts to mine.
geth is committing the work to the blockchain.

Has the --support option been depreciated or am I mining ETC instead of post fork Eth by default?


texts: Getting data from outside source during a transaction once per day

texts: Is it possible for a token contract to call an oracle to fetch data once every so many hours?  Let's say the token was going to use a random number for some decision it was going to make in its execution and that random number needed updated once a day.  Calling the Chainlink VRF to get the random number is easy enough, but is it possible that call only happens once a day?


texts: Explain Natspec comment usage in a DAPP developent?

texts:
Why do we need Napspec comments. How can we use that Natspec comments during development of DAPP ?

Or Else the Natspec comments only for Ethereum Clients.


texts:
Mining using claymores miner, amd rx400 series.
Most activity appears to be on the CPU and disk. Periodic spike on GPU graph.
I know it works, eth being deposited in wallet.
Is this normal?

Info comes from Task Manager, performance tab.
Is there a better way to see GPU activity?


texts:
Scenario - need to store on blockchain specific data related to users.

potentially very large number of users
data should not be changed in the future, and that's the whole point to make it immutable
smart contract should have ability to check it for any user at any time
data size to store per user is small
the data should not be easy to find or interpret on blockchain for general public

From my understanding there are 2 ways:

Store in transaction's data

cheaper to store
if user personal information is stored in a offchain database, the data on blockchain can reference it by primary key. Database can
store all transactions for specific user for fast search

Questions

Does having part of data stored offchain beat the purpose of using
blockchain in terms of if database is somehow lost/corrupt then data
stored in a contract becomes useless?
Is there a point of using Swarm/IPFS instead of regular database? what benefits it would have?
Can a smart contract easily access a transaction's data? is it free or not?

Store in smart contract's data

expensive to store
info is easy to find within contract's data structures

Questions

Since contract's data can be modified, it looses the immutability benefit? can the changes to contract's data be tracked on blockchain?