texts: What is the difference between receipts and transactions？

texts: The data structure of receipts are no big difference from transactions. So why block headers have the receipts tree root? Is it unnecessary？


texts: Does the EVM have an opcode to check private key signatures?

texts:
I have plain and simple desire. I want my dapp users to be able to generate some data payload, sign it with their private key, and send it using any external channel (eg JSON between apps) to a recipient, who can then post a transaction to the blockchain, which will include this data as part of the “data” field. Now here is the key:
I want to verify the signature given the ethereum address or public key sent, and the payload, which is a substring of the data field, and get a boolean true or false
Is there a built-in opcode to do this?
I would use it to eg generate and pre-sign “capabilities” or “transaction templates” that have parameters with ranges that can be filled in by the user, and present this capability as a payload.
What I don’t want is to waste gas on elaborate algorithms to check private key signatures. Also, is any of this quantum resistant?
PS: Perhaps a workaround is for party A to generate and sign a transaction, and send it to party B to post at any time that is allowed by first transaction... thereby A paying the gas fees and B can even be a totally new wallet user with zero balance? But then IS THERE ANY MECHANISM for the second party B indicate any additional information (such as their own wallet address) without having to sign it with A’s key?? I guess if B had gas, they can execute some transaction to change some variable and then A’s transaction will refer to it.


texts: The default output of the function. Solidity

texts:
This is simple smart contract for election of two candidates :

pragma solidity 0.4.24;

contract Election {
    //Model a candidate
    struct Candidate{
        uint id;
        string name;
        uint voteCount;
    }
    //Store Candidates
    //Fetch Candidate
    mapping(uint=>Candidate)public candidates;
    //Store Candidates Count
    uint public candidateCount;
    function election()public{
        addCandidate("Donald Trump");
        addCandidate("Barak Obama");
    }

    function addCandidate(string memory _name)private{
        candidateCount++;
        candidates[candidateCount] = Candidate(candidateCount,_name,0);
    }
}

Why the output is the default output ? Is the value that i'm passing is invalid ?


texts: Integrating Ethereum to facilitate transactions

texts:
I’m kind of lost on where to start with Ethereum.

I would like an easy way to integrate Ethereum with my app. My main goal is to facilitate trades between users.

There are 2 ways of doing this, transfer all of the Ethereum to 1 account take my fee and then I transfer to the destination account.

Or I can write a smart contract which will take a fee and transfer to the destination account.

I’m looking at the Coinbase api, which doesn’t really like smart contracts, transferring to my account and then back to the destination will cost a 4% fee and then another 4% fee.

Is there a simple api which I can use to transfer Ethereum without doubling my transaction fees?


texts: What are the options for deploying a contract?

texts:
If I have a contract code (written in Solidity), I guess I can just compile it with whatever compiler and then I need to deploy it.

What are the options for deploying it? Geth seems to be the most common option but it seems quite complicated. Is it not possible to just enter the compiled code somewhere with whatever parameters and press 'Deploy' (for example from a wallet so I can pay for the gas)? Do I have to have a full node synced? I was looking at www.myetherwallet.com contracts section but couldn't figure out how to deploy even from there.

I guess the methods are the same for testnet and main net?


texts: v0.4.22 solc compile failing - not predictable behavior

texts:
Error:

 Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
  function CappedCrowdsale(uint256 _cap) public {
  ^ (Relevant source part starts here and spans across multiple lines).
 not valid for functions.oc tag @dev
Compilation failed. See above.

I got this same exact error when my token contract was not using the new constructor() convention.

What is odd, is after I switch the token contract to the new convention, the compiler was happy. The next day it did the same thing, broke and complained about my crowdsale contract not using the new convention. (weird it didn't complain about this the day before) This was last week. I resolved the issue by switching to constructor().

Now I did a git pull on my laptop to continue work today, and now it's not happy with the constructor call made to the inherited contract, CappedCrowdsale.

function CappedCrowdsale(uint256 _cap) public { ^ (Relevant source part
starts here and spans across multiple lines).
    not valid for functions.oc tag @dev

Googling has not turned up anything helpful. And troubleshooting on my own has not turned up any positive outcomes. I'm not 100% sure the constructor convention causing this error as it's only deprecated. But perhaps something related around that?

not valid for functions.oc tag @dev
Compilation failed. See above. - leaves me clueless

Edit: I've restarted my computer and now compile doesn't give any warning about the constructor convention. Only the 1 liner error above. Last week this occurred on my desktop. Today is on my laptop.

Edit x2: Narrow down the issue to the laptop. Same code base is working without issue on my desktop. Perhaps something needs updated/reinstalled? Will update when I figure it out. The warnings are separate, nonrelated, to the compile failure.


texts: pywallet: Which is the private key of child wallet?

texts:
Using pywallet, I have developed ethereum wallet under following code.

  seed = wallet.generate_mnemonic()
  wallet_info = wallet.create_wallet(network=network, seed=seed, children=0)

In this case wallet info is as follow.

 {
  "coin": "BTC",
  "seed": "guess tiny intact poet process segment pelican bright assume avocado view lazy",
  "address": "1HwPm2tcdakwkTTWU286crWQqTnbEkD7av",
  "xprivate_key": "xprv9s21ZrQH143K2Dizn667UCo9oYPdTPSMWq7D5t929aXf1kfnmW79CryavzBxqbWfrYzw8jbyTKvsiuFNwr1JL2qfrUy2Kbwq4WbBPfxYGbg",
  "xpublic_key": "xpub661MyMwAqRbcEhoTt7d7qLjtMaE7rrACt42otGYdhv4dtYzwK3RPkfJ4nEjpFQDdT8JjT3VwQ3ZKjJaeuEdpWmyw16sY9SsoY68PoXaJvfU",
  "wif": "L1EnVJviG6jR2oovFbfxZoMp1JknTACKLzsTKqDNUwATCWpY1Fp4",
  "children": []
}

Here exists private key.
But when I create a child wallet, there has no private key.
If so, which private key can I use to send transaction from child wallet?
Help!!!!!

{
  wallet_path: m/12341234/1,
  bip32_path: m/44'/60'/0'/12341234/1,
  address: MYADDRESS
}


texts: callback vs on function in sendsignedtransaction

texts:
I am deploying a smart contract using web3js and it works perfectly. But i was made aware of my incorrect use of callbacks. I got some basic understanding of promievents from https://web3js.readthedocs.io/en/v1.2.1/callbacks-promises-events.html and rewrote my code as below based on the samples here : https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sendsignedtransaction :

web3.eth.getTransactionCount(account, (err, txCount) => {
    if (err!=null) {console.log('error executing web3.eth.getTransactionCount: ', err)}
    else{
        console.log('txCount: ',txCount)

        const txObject = {
            nonce: web3.utils.toHex(txCount),
            gasLimit: web3.utils.toHex(1000000),
            gasPrice: web3.utils.toHex(web3.utils.toWei('0', 'gWei')),
            data: contractByteCode
        }

        const tx = new EthereumTx(txObject,{common: customCommon})

        tx.sign(privateKey)

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

        web3.eth.sendSignedTransaction(raw)
        .on('transactionHash',(hash) => {
            console.log('txHash:', hash)
        })
        .on('receipt',(receipt) => {
            console.log('receipt', receipt)
        })
        .on('error', console.error)
    }

})

I did this based on the principle that the callback in getTransactionCount() might execute at any future time, so i should use the return value txCount only within the callback. That is why the entire code is inside the callback function.

But i am not sure about the sendsignedtransaction part. I am assuming that the ".on('transactionHash')" function will execute whenever a transactionHash event is emitted by the sendsignedtransaction function. Similarly the ".on('receipt')" function will execute whenever a receipt event is emitted by the sendsignedtransaction function. And the ".on('error')" function will execute whenever a error event is emitted by the sendsignedtransaction function. So everything works asynchronously without blocking my thread.

If my understanding is correct, then i am confused why this code just hangs in node when i intentionally put in an bug(by removing the "{common: customCommon}" parameter). Shouldn't it return immediately and do "console.error" ?


texts: Colored coin in Ethereum to differentiate the wallet ether balance

texts:
I have heard of the concept of colored coin in bitcoin , is there anything similar in Ethereum?

  I want to have a single wallet which maintains two types of ether

.
lets say one coming from me adding ether and other earning from playing games
.
i want to use these two ethers separately in a single wallet.
is there anything for this?

thank you :)


texts: Staticcall on external function works only, when there is one function's argument

texts:
I'm trying to call external function in contract B from contract A using staticcall.
Here is code for contract A:

contract A {
    address public addr;
    bool public success;
    bytes public result;

function setAddr(address _addr) public {
    addr = _addr;
}

function callB(uint256 arg1, uint256 arg2) public {
    (success, result) = addr.staticcall(abi.encodeWithSignature("funcB(uint256, uint256)", arg1, arg2));
}

}

and here is contract B:

contract B {

  function funcB(uint256 arg1, uint256 arg2) public pure returns(bool) {
    if (arg1 > 10 && arg2 > 90) {
        return true;
    } else {
        return false;
    }
  }
}

but this doesn't work. Public bool "success" after calling callB still got  value "false", and there is no data in "result".

But when there is only one argument like here:

contract A {
    address public addr;
    bool public success;
    bytes public result;

function setAddr(address _addr) public {
    addr = _addr;
}

function callB(uint256 arg1) public {
    (success, result) = addr.staticcall(abi.encodeWithSignature("funcB(uint256)", arg1));
}

}

and here:

contract B {

  function funcB(uint256 arg1) public pure returns(bool) {
    if (arg1 > 10) {
        return true;
    } else {
        return false;
    }
  }
}

everything works fine. I've got "true" in "success" and received data in "result" bytes.

What I'm missing here?


texts: Can you activate Contract Functions just by receiving Ether alone?

texts:
Noob Question here. I have a Dapp that has no actual need of a web interface. What is the best way to activate functions if someone did something as simple as send Ether to an address it controls from a basic wallet?

Do i need to do something complex such as regularly ping it from Ethereum Alarm Clock or can a smart contract activate itself upon receiving a basic Ether transaction.

Plan is to just attach a human readable ENS name to the contract. People would send Ether to it like they would normally to any other address and it would automatically activate a function to re route it.


texts:
I've got nodes running on VMs on Azure etc. Upon which I deploy stuff like blockchain explorers. The thing is that all these tools run  client side via js, and they call the rpc endpoint via

http://127.0.0.1:8545

8545 however is completely closed.

How can i make use of tools such as block explorer without getting

Allow Access to Geth and Refresh the Page
geth --rpc --rpccorsdomain "http://127.0.0.1:8000"


texts:
How to install Ganache UI on windows 8.1 ?
I downloaded from Official website but after downloading i am unable to install it on my machine.

I tried to install it through power shell but facing following error :

Please provide a step to step guide if anyone knows.
Thanks


texts: How to store ERC-20 tokens on MyEtherWallet

texts:
I have VeChain tokens that I want to store onto paper wallet created with MEW. This is my first attempt moving tokens/coin from exchange to a wallet.

I am confused as to how the fee will be calculated. Will it be a certain amount of VEN that I have, or ETH, which I don't have?

Also, can I store different ERC-20 tokens and Ether all in the same wallet?

Thanks.


texts: " VM Exception while processing transaction: invalid opcode" when deploying contract

texts:
I am getting the following error when deploying with web3js a smart contract based on Open Zeppelin:

Uncaught (in promise) Error: VM Exception while processing transaction: invalid opcode
    at Object.InvalidResponse (errors.js:35)
    at requestmanager.js:86
    at XMLHttpRequest.request.onreadystatechange (httpprovider.js:122)

where the contract code is

pragma solidity ^0.4.15;

import "./libs/zeppelin/crowdsale/CappedCrowdsale.sol";
import "./libs/zeppelin/crowdsale/FinalizableCrowdsale.sol";
import './TestToken.sol';

contract SampleCrowdsale is CappedCrowdsale, FinalizableCrowdsale {

    TestToken public testToken ;

  function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet, address _tokenContractAddress)
    CappedCrowdsale(_cap)
    FinalizableCrowdsale()
    Crowdsale(_startTime, _endTime, _rate, _wallet)
  {

    testToken = TestToken(_tokenContractAddress);
  }

  function createTokenContract() internal returns (MintableToken) {
    return testToken;
  }

}

However everything works when I change FinalizableCrowdsale to RefundableCrowdsale:

pragma solidity ^0.4.15;

import "./libs/zeppelin/crowdsale/CappedCrowdsale.sol";
import "./libs/zeppelin/crowdsale/RefundableCrowdsale.sol";
import './TestToken.sol';

contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {

    TestToken public testToken ;

  function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet, address _tokenContractAddress)
    CappedCrowdsale(_cap)
    FinalizableCrowdsale()
    Crowdsale(_startTime, _endTime, _rate, _wallet)
  {
    require(_goal <= _cap);
    testToken = TestToken(_tokenContractAddress);
  }

  function createTokenContract() internal returns (MintableToken) {
    return testToken;
  }

}

Question: Can anyone please explain to me why the first contract that uses FinalizableCrowdsale is throwing that error? RefundableCrowdsale inherits FinalizableCrowdsale but isnt giving any errors...

Related Files:

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


texts: Algebra symbology guidance for Ethereum Yellow Paper

texts:
There are numerate people who have limited experience in interpreting the algebra used in computer science papers. Therefore, it would be most useful if there were a list of all algebraic symbols used in the Yellow Paper, along with their definition as applied in the paper.

There is of couse this guide, however, for some of the symbols, there are multiple interpretaions.

Please list the symbols used and define their meaning.  My understanding is as in my answer below. I've used bold italics where I'm particularly unsure. Please point out where I am wrong.

EDIT - I've posted the list as a community wiki.


texts:
I saw an example about this, while was searching it on the internet.
I want to deploy a new contract which is ProjectContract. However, I could not get contract address as below. I think this is for old version.
address newProjectAddress = new ProjectContract(name, description, requiredPrice, msg.sender);

And the error message is:

How can I do that for the new versions?


texts: How to change name of token on etherscan?

texts:
How do I update the name of my token SHNZ? Currently on etherscan, it's showing

Erc20 (SHNZ)
https://etherscan.io/address/0x7968ca1f368098784fc651277bfd29f610cf91f7#tokentxns

How do I update it so it displays with the token symbol: http://www.shizzlenizzle.com/SHNZ_28x28.png

to the left of the token name SHNZ

I already submitted the information and the icon at: https://etherscan.io/contactus


texts: Is the uint "ID" in this function saved in storage?

texts:
I am a bit confused about the uint "id" in the start function.

I understand that the uint "nextCampaignId" is a global variable, and so changes made to it will be saved in storage; which means that with each new campaign created, "nextCampaignId" will be incremented, and so cannot be used to determine ID numbers of previously created campaigns.  Hence, we need to assign its value to a new uint "id" within the function.

However, I thought integers declared within functions do not get saved in storage.  Wouldn't this ID number be lost once the function is terminated?  Does the function simply return the ID (to the UI) and then forgets it? But then how can we retrieve specific campaign data later?

uint nextCampaignId;
mapping(uint256 => CampaignData) campaigns;

// Start a new campaign.
function start(address recipient, uint256 goal, uint256 deadline) returns
(uint id) {
    var campaign = campaigns[nextCampaignId];
    campaign.recipient = recipient;
    campaign.goal = goal;
    campaign.deadline = deadline;
    nextCampaignId ++;
    id = nextCampaignId;
}


texts: Issues connecting Web3js to local testnet

texts:
I am trying to connect web3 to a testnet running locally. I am using the following code

    var web3 = new Web3(Web3.givenProvider || "ws://localhost:8546");

    var account = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e';
    web3.eth.getBalance(account, (err, bal) => {balance = bal});
    console.log(balance);

But I get the folowing error in the browser window:

    web3.min.js:1 Uncaught TypeError: this.provider.sendAsync is not a function
        at n.sendAsync (web3.min.js:1)
        at l.t [as getBalance] (web3.min.js:1)
        at index.html:41

Any ideas on what I am doing wrong?


texts:
I am trying to do a fast sync using geth --fast but I am getting this message:

  blockchain not empty, fast sync disabled

How can I empty the blockchain to allow for fast sync?


texts:
Ethminer says:

JSON-RPC problem. Probably couldn't connect. Retrying in 1...
  m  10:47:22|ethminer  Getting work package...
  ✘  10:47:32|ethminer  Failed to submit hashrate.
  ✘  10:47:32|ethminer  Dynamic exception type: jsonrpc::JsonRpcException
std::exception::what: Exception -32003 : Client connector error: libcurl error: 28 -> Operation timed out

Ethminer was run with following options:

ethminer -G --opencl-device 0 -F http://127.0.0.1:8545

I've got a quadcore machine with 8Gig of RAM.
I'm sure that RPC is started:

> admin.startRPC("127.0.0.1",8545,"web3,net,eth,miner")
true

I tried to observe the traffic with tcptump, but is shows only SYNC packets from ethminer to geth. Looks like geth does not respond.

Some geth info:

> admin.chainSyncStatus
undefined

> web3.eth.syncing
{
  currentBlock: 3990980,
  highestBlock: 3991101,
  knownStates: 8721073,
  pulledStates: 8714457,
  startingBlock: 3989781
}

Software:

Geth -- instance: Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.3

Ethminer -- Genoil's ethminer 0.9.41-genoil-1.1.7


texts:
Would it be possible to create a smart contract that would have restrictions on token transfers?  Say if I wanted to issue token(s) to an ETH address but to only allow that token to be transferred one time (different ETH address) and back to the contract and burned.  If it is transferred more than once it would be invalidated and be made available for someone else.

Doable?


texts: Web3J - how to perform two identical transactions in a row?

texts:
I have a contract being an ERC-20 token. I want to perform two idendical transfers (sender, receiver and amounts are the same).

I am using the contract objects from Web3j:

MyToken token = MyToken.load(tokenAddress, web3j, credentials, DefaultGasProvider()));
token.transfer(recipient, amount).send();
token.transfer(recipient, amount).send();

However, the secont transaction fails with "Known transaction" error. How can I make this work and successfully perform two distinct, but identical transactions?


texts:
I read from this question How to concatenate a bytes32[] array to a string?(the first answer) that the agrument can be bytes32[] type, but when I try myself sending transactions using mist setting the argument to be

[7bb8b6ec123302e43ad88384158e2347efcfef19600b821431e8e09504046595,1f57c6ad7358ac73b73730eabb54b1bea7b785df2e4502291ed99b08af625def], it can not work, why?


texts:
I am running a phoenix miner for solo mining in my private network. I want to understand the logs of the miner. Can any one help me to understand the following more in depth especially the shares and time? What every term means?
Eth speed: 7.264 MH/s, shares: 383/0/0, time: 18:37


texts: Validate additional data in contract code or not?

texts: Is it better and more friendly in terms of gas and other resources to perform transaction data validation using web3 externally or to perform it in smart contract?


texts: How to assign an event output to a variable?

texts:
I'd like to get the event result in my UI.

Here is my contract

pragma solidity ^0.4.4;

 contract T2{
 uint public k;
 event CheckVal(uint val);
 function Test() returns (uint){
  var temp=441;
  CheckVal(temp);
  k=32;
  return temp;
   }
}

and in the console I have this:

var eve=instance.CheckVal();
eve.watch(function(error, result){console.log(
result.args.val.toNumber());});

Every time I run

    instance.Test({from:eth.accounts[0],gass:4200000})

441 appears in the console, which is right. But I want to get the value (i.e. 441) in my UI, so I want to assign it to a variable.

Question: How to assign the output of event log to a variable?


texts: Truffle console call contract without ABI (Ganache Forked BSC)

texts: So I started Ganache-cli with -f option to fork the BSC (ETH FORK), and in the truffle console I want to interact with some smart contracts that are not mine nor I deployed them, how can I interact with them without having the ABI of the given contract?


texts: truffle pet shop example - metamask connects but adopt button not working

texts:
I am having some trouble with getting the adopt button to work in the truffle pet shop tutorial:

https://truffleframework.com/tutorials/pet-shop

I have worked through the truffle petshop example twice from scratch and I have also looked at the proposed solution here:

Truffle Tutorial pet-shop with test-rpc adopt button doesn't work

However, I find that metamask is connecting to my petshop application but the adopt button is not doing anything. I've hosted the app here for now:

http://www.snipperly.com:3000/

To avoid typos, I have copied and pasted code from the truffle site into my files. May I ask how this could be resolved?


texts:
I have set up a JavaScript file that takes in my contract and executes the various functions and then returns the correct events. The file runs through 'truffle exec'.

I am using the following line to get my events to return:

      let myEvent = contract.ThisEvent({}, {fromBlock: 0, toBlock: 'latest'});
  myEvent.get((error, logs) => {
    logs.forEach(log => console.log(
      'Message: ' + log.args.message
    ))
  });

The problem I am facing is that I have a variety of events with the same name but that return different messages. The idea is for each event to be returned in a specific order (as set up in the function). But when I try to execute them in the JS file they end up being returned in the terminal in the wrong order.

I'm not sure how to get it to return the events in the correct order. Can I maybe change the fromBlock/toBlock to make this happen? And if yes is there a way to figure out in advance in which block which event is going to be in?

Thanks!


texts:
Suppose we have the following contract in solidity:

contract C {

event EventAdd_One(int a, int b);

event EventAdd_Two(int a, int b);

function add(int a, int b) returns (int) {

    // This fires every time
    EventAdd_One(a, b);

    if (a > 0 && b > 0) {
        return a + b;
        // Does this fire every time?
        EventAdd_Two(a, b);
    } else return 0;
}

}

Does the second event fire regardless if a and b are positive?


texts:
I am developing a simulation that will be made millions of transactions, studying Ethereum, I realized that it would not be worth storing these transactions in the ethereum platform due to the cost of the transactions. In this way I realized that it would be more feasible to use a sidechain to perform the transactions, and to use the blockchain of the ethereum to store only the hash of the sidechain blocks.

Could you give me examples of sidechain clients that can be used in conjunction with the ethereum platform?

Is the idea of storing only the hash of the sidechain blocks on the ethereum platform valid?


texts: Race conditions when calling remote contracts

texts:
Below I extracted the logic which calls a remote contract to calculate the amount of tokens to withdraw funds.

contact Example {

  mapping (address => uint256) balances;
  ERC20 token = ...; // remote token contract
  uint256 contract_eth_value = ...;

  ...

  function () payable {
    // User's address.
    address user = msg.sender;
    // Retrieve current token balance of contract.
    // HERE !!!!!!!!!!!!!!!!!!!!!!!!!
    uint256 contract_token_balance = token.balanceOf(address(this));
    // Disallow token withdrawals if there are no tokens to withdraw.
    uint256 tokens_to_withdraw = (balances[user] * contract_token_balance) / contract_eth_value;
    // Update the value of tokens currently held by the contract.
    contract_eth_value -= balances[user];
    // Update the user's balance prior to sending to prevent recursive call.
    balances[user] = 0;
    // Send the funds.  Throws on failure to prevent loss of funds.
    if(!token.transfer(user, tokens_to_withdraw)) throw;
  }
}

I've searched solidity documentation for an answer but with no success. What I'm wondering or better what I'm afraid about is that when a call to a remote contract is executed, the contract function looses atomicity. If what I'm saying is true then the call above could lead to race conditions and thus unexpected results. This case would certainly be non-atomic in  some distributed databases but I'm not sure if that also stands for Ethereum-based applications (contracts).

I would appreciate if an expert could take some time and explain this situation in details. A link to the official documentation/statement on that is also welcome.

UPDATE:
I found a similar debate here


texts: I'm trying to create a function in my smart contract that will invoke a payment from the user, for example when a button is clicked metamask will ask to confirm the 0.10 ETH payment to my contract, I understand payable functions and have tested this in remix and can pay my contract but I want to know how to 'invoke' a payment with a predefined amount of Ether and request it from the user. Thanks


texts: Get current metamask account method not working anymore

texts:
I was using the following method to access the selected account on metamask through web3 v1:
  //metamask method that refresh the active account in the web
    this.web3.currentProvider.publicConfigStore.on('update',async function(event){
      this.setState({
        account: event.selectedAddress.toLowerCase()
      },()=>{
        this.load();
      });
    }.bind(this));

And everything was working fine, it seems that a new update happened and this is no longer available. Any suggestions?
Thanks


texts: Error while supplying test assets to the compound protocol using infura project, ganache-cli and web3.js

texts:
I'm trying to supply assets to the compound protocol using this guide: Supplying Assets to the Compound Protocol.

I created account at https://infura.io/ and got my ProjectID.
I cloned https://github.com/compound-developers/compound-supply-examples
Then i ran blockchain with this command with my infura ProjectID:

ganache-cli \
-f https://mainnet.infura.io/v3/<YOUR INFURA API KEY HERE> \
-m "clutch captain shoe salt awake harvest setup primary inmate ugly among become" \
-i 1 \
-u 0x9759A6Ac90977b93B58547b4A71c78317f391A28

After that, i ran node web3-js-examples/supply-eth-via-web3.js with generated privateKey for address on previous step supply-eth-via-web3.js.

And i got an error:
My wallet's ETH balance: 100
Supplying ETH to the Compound Protocol...
cETH "Mint" operation successful.
Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, o
r querying a node which is not fully synced.
    at ABICoder.decodeParameters (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\web3-eth-abi\lib\index.js:288:15)
    at Contract._decodeMethodReturn (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\web3-eth-contract\lib\index.js:470:22)
    at Method.outputFormatter (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\web3-eth-contract\lib\index.js:760:42)
    at Method.formatOutput (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\web3-core-method\lib\index.js:147:54)
    at sendTxCallback (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\web3-core-method\lib\index.js:523:33)
    at C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\web3-core-requestmanager\lib\index.js:293:9
    at XMLHttpRequest.request.onreadystatechange (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\web3-providers-http\lib\index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\xhr2-cookies\dist\xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (C:\Users\adel1\PhpstormProjects\compound-supply-examples\node_modules\xhr2-cookies\dist\xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

Seems to be the method cEthContract.methods.mint().send() executing correctly and balance of ETH wallet is changing. But after that all other methods returning same error (see above).
After running the script node web3-js-examples/supply-eth-via-web3.js, I see this in the console:
eth_getBalance
eth_chainId
eth_getTransactionCount
eth_sendRawTransaction

  Transaction: 0xb88879e6aff2b0431d21f12a53c4bd2d2ffc09b7cf8df2a7fb6d74ca29231d5c
  Gas usage: 21064
  Block Number: 1
  Block Time: Thu May 27 2021 10:31:22 GMT+0700 (GMT+07:00)

eth_getTransactionReceipt
eth_call

P.S.: And one more thing - i don't see any request in my infura project dashboard requests after i ran a script.


texts:
So, ERC20 tokens are bought depositing equivalent Price = amount to be bought*price of tokens) in eth to the smart contract eth address.
So lets talk about BAT ERC20 token:
If I am verified BAT blogger publisher. Someone sees it and decides to reward me BAT token. Would not it be simple if my eth address be put on end of article. And my audience rewards me in eth to that eth reward portal button. However, I know One advantage of bat token is: it is convenient to reward say 2 BAT token instead of say 0.002 eth.  What is another advantage?
Lets consider another scenario. OXT token is for paying vpn privacy. Wouldnt it be simple if they just put eth payment button to sell VPN service?
Are tokens needed because if I pay in OXT token, then automatically all those VPN services would be triggered open to service my browser.

To better clarify my question, I would ask the question sense in real life scenario:
So why would anyone build different token to grant access to ,say, magic fair or build different token to grant access to some video game machine.
I completely know why tokens are needed but why the need for different tokens?
PS: the tokens mentioned above are about utility tokens, NOT governance tokens or other types.


texts: How can I keep nodejs running even after crash on Ubuntu

texts: Is there any way I can run the nodejs program app.js always in the server even it crash? So I do not need to keep restarting node app.js by nohup


texts: Fail with error 'TransferHelper: TRANSFER_FROM_FAILED' Although approved

texts:
I'm trying to make a swap programmatically, I did the following approvals using ethers.js:
token0.approve(wallet.address, amount);
token1.approve(wallet.address, amount);
token0.approve(UNISWAP_ROUTER_ADDRESS, amount);
token1.approve(UNISWAP_ROUTER_ADDRESS, amount);

Then I calculate the amounts and minimum just fine and submit my transaction,
but although the approvals go through and everything is fine my transaction fails with the following error: Fail with error 'TransferHelper: TRANSFER_FROM_FAILED'.
Should I approve something else also, what am I missing? (sry but I'm new into this)
tx hash on rinkeby: https://rinkeby.etherscan.io/tx/0xa172511c960e67abb1a8e8bb90241048fd4d393113976052f2e6d7f6c63e048a
sample coin on rinkeby:
https://rinkeby.etherscan.io/token/0xf2f0f119f819c457a8b8230306396985dff06082
PS1: Using another wallet I submit my coin to my local uniswap installation which is connected to rinkeby and a pool is created. However if I interact with uniswap with my other wallet (that is used programmatically) then the issue above doesnt happen anymore...
PS2: The error originates from UniswapRouter02 right here but my solidity knowledge is limited.
function safeTransferFrom(address token, address from, address to, uint value) internal {
    // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
    (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
    require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
}


texts:
I've been following Ethereum since it was announced and I remember that the appeal was that it was "Bitcoin 2.0". While email replaced the post and Bitcoin replaced fiat, Ethereum would replace legal papers (wills, birth certificates, etc).

I'm learning that Ethereum is a "World Computer" and decentralized apps (DApps) are simply applications, much like Facebook, Instagram, Google Drive, and so on. In order for someone to use the apps, they need to pay Ether. They can earn Ether by commissioning their personal machine to work a day job and help manage the whole World Computer with everyone else. Is this right so far?

My main confusion is: if Ethereum is a new "World Computer," it's basically a new internet, right? But on the current internet?

What happens to the internet of today? I've read HTML, CSS, JS are still utilized in Ethereum, but how? Do I point my browser to a web App/DApp? Or will there be special Ethereum browsers? I think that's essentially what Mist is, right?

I'm really interested in what Ethereum could mean for computing and the Internet of Things in the coming decade, but that's based on what I imagine the system to be. Any clarification is appreciated!


texts:
First of all, excuse me if this is not the section to ask.
I'm trying to find out what information can be encrypted inside the blockchain, i.e. should all the information written in the blocks be (compulsorily) unencrypted? I've read some research articles about frameworks that allow to encrypt information, so I deduce that certain information can be encrypted. Is there anyone who can help me on this topic or do you know where I could look for more reliable information?
In short: can information be encrypted? If so, which part can be encrypted?


texts: Why addresses from the exchanges do not show on Etherscan?

texts:
I have some ether in an exchange but when I searched it on etherscan.io it is showing

There are no matching entries

there I got to know exchanges have the balances on their own wallet address, but if my address(from exchange account) is not there on blockchain how I am able to send ether from outside my exchange account to the address?


texts: Could we run `Parity` where we could have access to web3.debug on javaScript console?

texts:
Parity does not return anything for web3.debug on java script console.

The way I run Parity:

parity --chain parity.json --network-id 23422 --reserved-peers myPrivateNetwork.txt --jsonrpc-apis web3,eth,net,parity,parity_accounts,traces,rpc,parity_set,personal-ludp=debug,tcp=debug,sync=debug --author "0x75a4c787c5c18c587b284a904165ff06a269b48c"

When I run --jsonrpc-apis with debug it gives following error:

Unknown api: debug

[Q] Could we run Parity where we could have access to web3.debug?

This works for when I use geth. For geth based on following answer I have followed: https://github.com/tjade273/web3_ipc/blob/master/README.md


texts: I have use my PC to manage MetaMask (ie. chrome extend). compound.finance also connect to my metamask wallet. I want to  manage my account by mobile and at PC that I install metamask mobile in andriod. But the mobile version create a new wallet to me. How to use mobile to manage my previous wallet ?  Will the compound finance cannot connect my wallet after use mobile version ?  Thank you.


texts: Metamask is not defined when it's connected to local network

texts: I have Metamask connected to the local Ganache network, but I am getting the "No web3? You should consider trying MetaMask!" message, so apparently Metamask isn't being used. How would I get it to use Metamask?


texts: Attempts to transfer ETH from my Ether.li wallet appear OK, but the ETH never arrives at the destination

texts:
I've tried many times to transfer my ETH from my Ether.li wallet to another wallet and everything appears good, but nothing actually happens. The latest transaction says:

Withdrawal request - 97 ETH to 0xf7a1b79bfc55f2cfc315599ea5428225f3548217
Approved at 2/12/17 9:55 PM

Why?


texts: Why block with txs interrupt the empty block when ethereum source code worker.go

texts:
When I watch the ethereum file work.go ,the method commitNewWork, fragments as follows:

if !noempty {
            // Create an empty block based on temporary copied state for sealing in advance without waiting block
            // execution finished.
            w.commit(uncles, nil, false, tstart)
        }

    // Fill the block with all available pending transactions.
    pending, err := w.eth.TxPool().Pending()
    if err != nil {
        log.Error("Failed to fetch pending transactions", "err", err)
        return
    }
    // Short circuit if there is no available pending transactions
    if len(pending) == 0 {
        w.updateSnapshot()
        return
    }
    // Split the pending transactions into locals and remotes
    localTxs, remoteTxs := make(map[common.Address]types.Transactions), pending
    for _, account := range w.eth.TxPool().Locals() {
        if txs := remoteTxs[account]; len(txs) > 0 {
            delete(remoteTxs, account)
            localTxs[account] = txs
        }
    }
    if len(localTxs) > 0 {
        txs := types.NewTransactionsByPriceAndNonce(w.current.signer, localTxs)
        if w.commitTransactions(txs, w.coinbase, interrupt) {
            return
        }
    }
    if len(remoteTxs) > 0 {
        txs := types.NewTransactionsByPriceAndNonce(w.current.signer, remoteTxs)
        if w.commitTransactions(txs, w.coinbase, interrupt) {
            return
        }
    }
    w.commit(uncles, w.fullTaskHook, true, tstart)

Why block with txs interrupt the empty block?
in my opinion, commit the block with txs first, then  commit empty if no block with txs,
so the code should be transfer to the function defer , and the empty could not interrupt the block with txs when same block num .

emptyFun := func() {
        if !noempty {
            // Create an empty block based on temporary copied state for sealing in advance without waiting block
            // execution finished.
            w.commit(uncles, nil, false, tstart)
        }
    }
defer emptyFun()

same question ,visit github question


texts: Does bloom filter library for use in Solidity exist?

texts: Since there are strict storage and computational limits forced by a VM some operations for enterprise-level contracts are impossible. Is there some Bloom filter implementation available in existing library for use in Solidity? It could be used to optimise some algorithms. I do not feel ready for porting some algorithm myself :(


texts: Is it possible to connect to the testnet by mobile using Nethereum?

texts: Yesterday I start with smart contracts and deploy a simple one at the testnet. Only downloaded latest version of the wallet and clicked button to upload the smart contract. Is it possible to reach it by the mobile using nethereum or have I to run a private testnet where I have to set RPC while running geth?


texts: How to get a return value of a solidty function in javascript using web3?

texts:
My contract is:

   contract changeName{
    string customerName;

    function changeName(string _customerName)
       {
          customerName=_customerName;
       }

    function getName() returns(string)
       {

         return customerName;
       }
    }

In Javascript(meteor.js):

//contractAddress= block address where contract is deployed
//AbiArray : When contract is compiled
var myContract= web3.eth.contract(AbiArray).at(contractAddress);

myContract.getName(function(err,res)
{
alert(res);
//getting block address here
//How to get function return value

});


texts: Are there any limitations/regulations to be followed while wallet-wallet transfering?

texts:
Technical limitations similar to the ones which developers need to respect while crawling sites?

And can automated scripts be written with the limitations in mind?  What are the possible bottlenecks for such operations?


texts: My contract will run out of gas and will not be executed. why?

texts:
Very very new to this.

You send 1 ether to the contract:

It rejects it if it's not one ether exactly
If it is, adds the address to a mapping
If there are 5 mappings, it chooses an address at random and sends the 5 ethers, and resets the counter

Why will the contract not execute?

Thanks

pragma solidity ^0.4.11;

contract BasicLottery {

        // A mapping to store ethereum addresses
            mapping(uint => address) public gamblers;

            uint public my_length; //*to keep track of the length.
            uint public random; //random number

            function BasicLottery(){
                my_length == 0;
            }
        // function when someone sends an ether
        // stores the address, and if there are 5 participants,
        // chooses a winner and gives the money

        function bet() payable {

        // If the bet is not 1 ether, send the
        // money back.
        require(msg.value == 1);

        my_length +=1;

        gamblers[my_length] = msg.sender;

        if (my_length == 5) {
            // pick a random number between 1 and 5
            random = uint(block.blockhash(block.number-1))%5 + 1;
            gamblers[random].transfer(5);
            my_length == 0;

        }
    }
}


texts: how to resolve return argument implicitly convertible to expected type address

texts:
function getFrom(bytes32 transferId)public returns (address ) {
    Transfer memory transfer = transfers[transferId];
    if (msg.sender != transfer.to && msg.sender != transfer.from)  return 0x0;
    return transfer.from;
}
function getTo(bytes32 transferId)public returns (address) {
    Transfer memory transfer = transfers[transferId];
 if (msg.sender != transfer .to && msg.sender != transfer .from) return 0x0;
    return transfer.to;
}

I am getting error like this
TypeError: Return argument type int_const 0 is not implicitly convertible to expected type (type of first return variable) address. if (msg.sender != transfer.to && msg.sender != transfer.from) return 0x0; ^-^

how to resolve this issue?
thank you in advance


texts: How do I find my particular ethereum address and is it safe to give out? I need a very simplified version of how all this works. The research I’ve encountered so far is not helpful because I’m not a technical type.


texts: Compile Solidity to assembly keeping a correspondence with the source code

texts:
I would like to compile a contract written in Solidity (or even just the part relating to a single method) to study it and understand if I can optimize it.
I already managed to get the bytecode as binary or in its assembly representation using solc but I would prefer to keep the original source in the assembly like comments, line per line, similar to what happens with gcc -S.
Moreover, I can't understand if the solc compiler uses the Yul language as intermediate representation between Solidity and assembly during the compilation, in case it did, how can I view this representation?


texts: Lower than expected hashrates with HD7990

texts:
According to mininghwcomparison.com I should be mining at around 44MHs with my HD7990 card (bought used very recently),  however I'm only getting between 10-15 (Genoils Ethminer). Is this expected? Is the data out of date on the above site?

I did notice on one other miner (Claymore) I tried that my card was reporting back as two 280x GPUs. Is this normal behaviour for this card, or has someone potentially been mod-ing it?


texts:
My understanding of light nodes is they need PoW in the block headers. That PoW proves that $x amount of energy has gone into securing that chain.

With PoS, the proof that $y is securing the chain requires knowledge of blockchain state, namely account balances. Does this mean SPV nodes cannot function with Casper?


texts: Flow of Transactions and following State Changes (in respect to the blockchain)

texts:
Something rather basic I am not getting - Say I lay a transaction aimed to change the state of a smart contract, which in turn will interact with other contracts etc. until it reaches a halt. Obviously my transaction has to be put in a block.

Question is - WHEN exactly are all the state changing going to happen?

a) Is it only after the transaction was put into a finalized block?
In this case it will be required for a change in states to be put again in the later blocks.

b) Are they happening the minute the transaction is sent? If that holds then if my transaction was rejected by the miners (for too-low gas price for example) then the changes happened without a valid transaction.

Adding to the second option, if in this case the states changes are reverted, doesn't this opens a door to a DDoS attack on the network, simply make the network calculate a bunch of things subjected to a transaction (or many) that will not go through.

c) Another option I'm thinking of is that the transaction and all subsequent transaction are 'packed' together and have to be put to the same block.
Thing here, from what I understand from the EVM mechanism, the nodes are not reading from the blockchain's history, but doing the calculations once a contract was activated.

It could be that I missed some basic point regarding the networks architecture, if so, I'll be glad if you could point it out to me. (And I'm not a programmer, so please be gentle with using code citations :) )


texts:
As far as I know, Geth stores pending items in their Txpool.

Does "broadcast" means polling again and again to each peer clients until get processed?

What's exact name of the function that broadcasts transaction on source code?

And, with picture below, the number 5, what places do miners seeks to choose which transactions to execute?


texts: Fatal: Unable to attach to remote geth: dial unix /home/deus/.ethereum/geth.ipc: connect: connection refused

texts:
I am getting this error. Geth is already running.
Please help.


texts: Get lastest input transaction of the account

texts:
I am trying to get the recent IN transaction of the account
while i try

web3.eth.getTransactionCount("0xF092966e7bcc2b5646e0F0c20A715584DB37cd4B").then(function(trans){
    console.log(trans);
});

This returns account transactions count.

I refer web3 documentation and refer net i found the script getTransactionsByAccount Common useful JavaScript snippets for geth

Is any another way to find IN transaction  of the account using web3.js . Lastest last IN transaction is enough .


texts: simple dapp with React "issues with solidity"

texts:
i am trying to build a simple app (will improve once i get the simple one to work)I created a new Reactapp, added both the contracts and migrations directories and i use ganache and metamaks.
I have truffle installed. and i can successfully compile and migrate my contact on ganache

The Dapp has an input field that takes a string and save in bolckchain and then fetch it back and diplay that on screen.

I get an error form this part.

import SimpleStorageContract from '../build/contracts/SimpleStorage.json'

/src/App.js

  Module not found: You attempted to import ../build/contracts/SimpleStorage.json which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/.

And if i move build/contracts directory into src i get the following error

  TypeError: Cannot read property 'set' of undefined

full code:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
//import SimpleStorageContract from '../build/contracts/SimpleStorage.json'
import SimpleStorageContract from './build/contracts/SimpleStorage.json'
import getWeb3 from './utils/getWeb3'
import truffleContract from "truffle-contract";
class App extends Component {

    constructor(props) {
        super(props)

        this.state = {
            account: null,
            web3: null,
            firstName:null,
            fName:null,
        }
    }

    componentWillMount() {

    getWeb3.then(results => {
    this.setState({ web3: results.web3

    })

        this.instantiateContract()
    })
        .catch(() => {
    console.log('Error finding web3.')
        })
    }

    instantiateContract() {
    /*
     * SMART CONTRACT EXAMPLE
     *
     * Normally these functions would be called in the context of a
     * state management library, but for convenience I've placed them here.
     */

    const contract = require(truffleContract)
    const simpleStorage = contract(SimpleStorageContract)
    simpleStorage.setProvider(this.state.web3.currentProvider)

    // Get accounts.
    this.state.web3.eth.getAccounts((error, accounts) => {
        simpleStorage.deployed().then((instance) => {
            this.simpleStorageInstance = instance;
            this.setState({ account: accounts[0] });
            // Get the value from the contract to prove it worked.
            return this.simpleStorageInstance.get.call(accounts[0])
        })
    })
}
      handleSubmit = ()=> {

          const response = this.simpleStorageInstance.get().call();
          this.setState({fName: response.c[0]});
      }

    handleChange = (event)=> {
        const value = event.target.value;

        this.simpleStorageInstance.set(value , {from: this.state.account}).then((r) => {
            return this.setState({ firstName: value })
    })
    }

    render() {
    return (

Welcome to React

                  <form onSubmit= {this.handleSubmit}>
                  <input type="text" onChange={this.handleChange}/>
                  <input type="submit"/>

              </form>

{this.state.firstName}

{this.state.fName}

    );
  }
}

export default App;

SimpleStorage.sol

pragma solidity 0.4.24;

contract SimpleStorage {
    string firstName;

    function set(string x) public {
        firstName = x;
    }

    function get() public view returns (string) {
        return firstName;
    }
}


texts: Why most of the tokens on BSC have the IERC20 interface implemented and not the BEP20 interface?

texts:
I am getting started in solidity and this confuses me. I managed to deploy some tokens using BEP20 interface on the BSC testnet and it worked fine, but as I see, most of the tokens use IERC20 interface. I tried to deploy a token with the IERC20 interface and I couldn't interact with it's functions in bscscan.
Can anybody explain me this? Thanks a lot!


texts: What is the duty of a Notary in interaction between chains ? (Updated)

texts:
What is the precise definition of "Notary" entity?
Is the definition of "Notary" the same in "interoperability between different blockchains" AND "cross-shard transaction in a shared chain"? Or do we have different types of "Notary" ?
What is the duty of a Notary? attesting "availability of a block" ? or "validity of state" ? Which one ?

References:

Link
Link
Link (Page 9: Notary schemes)
Link (Page 3)
Link (Page 18)
Link (Page 5)


texts: Set contract storage directly at deployment

texts:
Is there a way to pre-define a contracts storage when deploying it?

Say I want a mapping to be filled with 1000 entries but want to avoid having to pay gas for adding every entry on its own.

Since storage is just a key-value map, I was wondering if can't just hardcode its initial state.


texts: Private network establishment with static nodes using geth client

texts:
I am setting up a private network using geth by the method static- nodes. I have created the static nodes.json file with 4 enodes and put it in the /usr/local/cellar/test2/geth/static-nodes.json. In terminal when I'm running the console command I getting an error:

ERROR[11-06|10:11:33] Can't load node file /usr/local/Cellar/test2/geth/static-nodes.json: JSON syntax error at /usr/local/Cellar/test2/geth/static-nodes.json:4: invalid character '\n' in string literal.

Plz find me a path to setup the permanent peers to setup private network
My static-nodes.json is

[
"enode://dc3e4f23315f90bb62c9096df01b7f07c4040a8520f046801e2fa6812aa4402d70f6073f6226779a9183137cb789e98492d197db1380784fd0d213c30e9651ec@192.168.1.139:30331",
"enode://1c745b2459129ca07b1345487fedda6b8516194a4208d93bd696f3684b44cbf16a5cdddb99cc1753b1ba43884d93c5d27403dce0c6638787f74a40428a7c9543@192.168.1.117:30332”,
"enode://be0c22a7a8451766c2894cd11143bc3128d5840cca161ad91b2bd9078d1dde56ddc19d0258e86e51cf7b7e9cda43b900a20ef392925ae8a19ab24c4cf016d69c@192.168.1.121:30333”,
"enode://1e07a29f0c94617d045dcf4f0d8597fd07757cbf8e48f66e78b72b142bf9b61d0d7bcce8fe21479ad0bd02bff945a8c062f2af03c0e1be670e1452b845fa420e@192.168.1.102:30334"
]


texts:
browser/ballot.sol:61:13: Warning: Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member.
    require(this.balance >= 1000000000000000);

What does it mean "convert the contract to address" type? How do I get the address of this?

I got this error in 0.4.21 of Solidity through Remix browser.


texts:
Mist is an interesting wallet. I want to know all messages that Mist sends to geth, and receives from geth. Because to sniff the messages between Mist and geth is too inconvenient, my idea is to modify the source code of Mist, and then compiles/runs it.

How can I modify the source code of Mist to dump all messages communicated with geth?

Is it possible to give a parameter to enable Mist to dump all messages communicated with geth?


texts: What is SMTChecker used for in Solidity?

texts:
From the solidity docs:

  If you use pragma experimental SMTChecker;, then you get additional safety warnings which are obtained by querying an SMT solver. The component does not yet support all features of the Solidity language and likely outputs many warnings. In case it reports unsupported features, the analysis may not be fully sound.

I understand that SMT comes from "Satisfiability Modulo Theory", but could someone explain how does the concept apply to Solidity? Is it some sort of formal verification?


texts:
TL;DR
I'm very confused by the Contract API in web3: https://web3js.readthedocs.io/en/v1.2.6/web3-eth-contract.html

myContract.methods not available in geth console either with Geth 1.9.11-stable and 1.9.12-unstable on Ubuntu 16.0.4 (fast sync'd)

Is that a version issue? Do I have to come back to a previous version to have this feature?

IN MORE DETAIL
I'm currently trying to use this API from my geth console to retrieve the encoded transaction string, to be signed and submitted

When I use on Remix (remix.ethereum.org), after I've compiled the SimpleStorage contract and deployed to Ropsten, I can access the methods as below

On Remix console:

> abi = [{"constant": false,"inputs": [{"name": "x","type": "uint256"}],"name": "set","outputs": [],"payable": false,"stateMutability": "nonpayable","type": "function"},{"constant": true,"inputs": [],"name": "get","outputs": [{"name": "","type": "uint256"}],"payable": false,"stateMutability": "view","type": "function"}]

> mySimpleStorage = new web3.eth.Contract(abi)

> mySimpleStorage.methods
{
  "set": "function () { [native code] }",
  "0x60fe47b1": "function () { [native code] }",
  "set(uint256)": "function () { [native code] }",
  "get": "function () { [native code] }",
  "0x6d4ce63c": "function () { [native code] }",
  "get()": "function () { [native code] }"
}

> tx = mySimpleStorage.methods.set("x")

> tx.encodeABI()
0x60fe47b10000000000000000000000000000000000000000000000000000000000000005

That is what I expect based on documentation

With Geth console:

The web3.eth.Contract (uppercase) don't even exist:

> mySimpleStorage = new web3.eth.Contract(abi)
TypeError: Value is not an object: undefined
        at <eval>:1:19(5)

I've to use web3.eth.contract (lowercase):

> mySimpleStorage = new web3.eth.contract(abi)
{
  abi: [{
      constant: false,
      inputs: [{...}],
      name: "set",
      outputs: [],
      payable: false,
      stateMutability: "nonpayable",
      type: "function"
  }, {
      constant: true,
      inputs: [],
      name: "get",
      outputs: [{...}],
      payable: false,
      stateMutability: "view",
      type: "function"
  }],
  eth: {},
  at: function(address, callback),
  getData: function(),
  new: function()
}

Anyway the methods property is missing and it is impossible to call encodeABI()

> tx = mySimpleStorage.methods
Undefined
> tx
undefined


texts: Run geth in the --testnet mode using only the toml config file

texts:
I am using Geth configuration files (*.toml) to manage configurations of my private network nodes. The command geth --config=config/<config-name>.toml is used to run nodes on each stack (dev, prod, etc.)

The prod stack is running against the Main Ethereum network, and in this case, the toml configuration is obvious (mostly, the default). However, for the dev stack, I need to provide a configuration that would run geth in the --testnet mode.

Which toml configuration should I give to run the node as if it was run with the --testnet flag?

I tried running geth --testnet dumpconfig but the only difference was really the network id, but it's not sufficient for running against Ropsten. Any pointers on how to define the testnet configuration in a TOML file? Thank you.


texts: Traded like 12$ of ethereum for husky at like 6 GWEI how long do those trades usually take?

texts:
I tried using "UniSwap" but 40$ prices for a 12$ trade seemed ridiculously high so I just went on a random site which allowed me to change "gwei" and I put it to 6 I think, I also heard u lose your "gwei" when u cancel the trade so how long should I expect it to be on average? weeks, months?
edit: ok i dont think its gonna go through like ever still want your opinion tho, and am i losing my gwei when i cancel the trades


texts:
Beginner in ethereum i started a private network using the following command

sudo geth --fast --cache 512 --ipcpath ~/Library/Ethereum/geth.ipc --networkid 1234 --rpcport "8081"  --datadir ~/.ethereum_private  console[![enter image description here][1]][1]

in my node js application

var Web3 = require('web3');

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(web3.isConnected());

web3.isConnected() return always false


texts: Calculating cost in dollars for smart contract deployment

texts:
I am calculating amount of dollars needed to deploy one of my smart contract.
Gas used for the transaction is 1922666. My calculation is as below. Is it correct ? I feel this is huge amount in dollars.

Ethers per gas - 0.0000001

Total ethers needed for my transaction is - 1922666 * .0000001 = 0.1922666

When I was doing the calculation 1 ether was 648 dollars so

.192666 ether = 124.5887568 dollars.

Is this correct ? 124 dollars is to high cost right for just deploying one smart contract. Am I doing anything wrong ?

When I checked the same in gas station I get only around 1 dollar. Please check the attached screen shot.


texts: Is there any efficient way to compute the exponentiation of a fraction and an integer?

texts:
Mind the following JavaScript operation:

function exp(n){
    return Math.floor(Math.pow(1.01, n));
}

Where r is a fraction (such as 1.01) and n is an integer. Is there any efficient way to emulate that operation efficiently on Ethereum? That is, a function:

function exp(uint n) returns (uint) {
    return ...
}

Which returns similar values to the former? Such a function would have many use cases; for example, computing compound interest rates.


texts: How does reputation work in the Ethereum P2P network?

texts:
Nodes in the Ethereum P2P network assign their peers reputation in order to keep track of how well they behaved in the past and evaluate whether it would be preferable to disconnect from them.

What are the exact rules applied by Geth, Parity, and/or other clients to determine a peer's reputation? In particular, is being honest sufficient to get a good or even optimal reputation or is usefulness required for this as well?

Under what condition do peers disconnect? Is reputation remembered beyond the lifetime of a connection and used for peer selection (for instance in order to prevent immediate reconnects by bad peers)?

The only piece of documentation on that topic that I was able to find is this excerpt from the documentation of the NewBlockHashes message type:

  Including hashes that the sending peer could reasonably be considered to know (due to the fact they were previously informed of because that node has itself advertised knowledge of the hashes through NewBlockHashes) is considered Bad Form, and may reduce the reputation of the sending node.


texts:
on my Ethereum wallet I've created a contract based wallet (as it was recommended in guides to see details about all my transactions) and I was useing this wallet as my main pay address. Everything was OK untill april 13. After this day my wallet stoped to recive any transactions, it seems like all Ethereum that was send to my contract based wallet just disappeared, cause multiple transactions were made from different services on this address, but I didn't get any of them.

Then I tried to make a transaction on my base wallet and it worked.

So I can't get what's wrong. What may be the problem?

Sry for bad englando.


texts: How to use web3.eth.getTransaction() with infura, or is there any alternative to replace infura?

texts:
I tried to deploy my contract on Ropsten TestNet with infura and web3.js, however when I used some functions it returned 405 error.
I notice that maybe I could not use web3.eth.getTransaction() when infura, however when I use following script

    <script src="./node_modules/web3/dist/web3.min.js"></script>

this function is called several times.

How can Iavoid the error, do I need to modity web3.min.js (https://github.com/ethereum/web3.js/blob/develop/dist/web3.min.js)?
Or is there any way to replace infura?


texts: Remix Solidity Parsererror expected Identifier but got 'string literal" string public

texts:
Any help much appreciated!

getting error on "string public "Test Token";" line

pragma solidity ^0.4.16;

interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }

contract TokenERC20 {
    // Public variables of the token
    string public "Test Token";
    string public "TEST";
    uint8 public decimals = 18;
    // 18 decimals is the strongly suggested default, avoid changing it
    uint256 public 100000000;


texts: Warning! Error encountered during contract execution [execution reverted]

texts:
I have an ERC20 Mintable+Burnable Token created on solidity 6.11 and a sale contract on solidity 5.0
I am getting error when i send ETH to the sale contract.
https://rinkeby.etherscan.io/tx/0xb793a7b7f3d5667a2ad5c38ecae273bd4c2fb7d627aa0383da7ab25a2ee71510
I have given minter role to sale contract.
This is the sale contract code:
pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v2.5.1/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v2.5.1/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v2.5.1/contracts/crowdsale/Crowdsale.sol";

contract BotSale is Crowdsale, MintedCrowdsale, CappedCrowdsale {
constructor (
uint256 rate,
address payable wallet,
IERC20 token,
uint256 cap
)
MintedCrowdsale()
Crowdsale(rate, wallet, token)
CappedCrowdsale(cap)
public
{
// solhint-disable-previous-line no-empty-blocks
    }
}

I have set Rate: 1000000000000000000
and Cap to: 9600000000000000000000000
Just incase if that helps. Though i want to ask, this cap is of tokens or ETH? and should i add decimals to cap?
Also i have read on openzeppelin docs to set rate as 1 if i want to give 1 token in exchange of 1 ETH. So should i add decimals in rate or not?


texts: Web3 - Assign nonce to smart contract transact

texts:
I have a smart contract.
I want to execute one of its state modifying functions.

This is the code:

const result = await smartContractObject.methods
    .addSomething(_valueToAdd)
    .send( { gas: '5000000', from:masterAccount });

How can I manually assign a nonce to this transaction?

Do I need to create a raw_tx?


texts: I would like to know  about the development phase after successful ICO. Let's say I have an idea regarding a Defi Project but don’t have enough capital to implement it. So I launched an ICO using simple “ECR20 Tokens creation” contract and raise enough Capital to Hire a team.  My question is how New Team will Implement or start a defi project. Will there be new smart contracts by the new team that could freely interact with the initial  “ECR20 Tokens creation” contract or do I need to specify every single detail regarding the upcoming Defi Project in the very first  “ECR20 Tokens creation” contract ? OR  write code inside the “ECR20 Tokens creation” contract  so that other future defi contracts could interact with it initial contract. Thanks


texts: Shop platform, load 10 articles every second

texts:
I have a website where users can sell articles which will be saved into the ethereum blockchain. On that website the top looks as following:

The contract includes following (I wrote just the important parts):

struct Article {
    address seller;
    uint bid;
    uint bidder;
}

Article[] articles;

function getArticle(uint _id) returns(address seller, uint bid, uint bidder){
    return(articles[_id].seller,articles[_id].bid,articles[_id].bidder);
}

function getArticlesAmount() returns(uint amount) {
    return articles.length;
}

The javascript code:

function initiateArticles() {
    contract.getArticleAmount({from: web3.eth.accounts[0]},function(error, result)
    {
        if(!error)
        {
            i = 0;
            while(i <= result) {
                getArticle(i)
                i++;
            }
        }
        else {
            console.log(error);
        }
    });
}

function getArticle(id) {
    contract.getArticle(id, {from: web3.eth.accounts[0]},function(error, result)
    {
        if(!error)
        {
            document.getElementById("recentArticles").innerHTML = document.getElementById("recentArticles").innerHTML + result[0] + result[1]...;
            ## This is not the finished code. Here I need help.
        }
        else {
            console.log(error);
        }
    });
}

document.onload = initiateArticles();

Now I want the following:
When a user visits the website, it should make a call to the contract to load the 10 recent articles and show them into the div "recentArticles". That's easy and I did that successfully. But now comes the part where I need help.

I want, that every second another call is made to the contract to get the latest values of the 10 called articles.

Example:
User comes to the site and views it. It loaded the last 10 articles. Someone bidded on an article. The article in the div should now show the new bid.

Whats the best way to make a function that makes a call every second for each article? I would need 10 "updaters/countdowns".

Thank you very much for answers.


texts: Why download from Ethereum Swarm too low?

texts:
I have two 100mbps servers.

On server #1 I execute: swarm up 50mb.testfile

On server #2 I execute: wget -O 50mb.testfile http://localhost:8500/bzz:/.../

I see download speed 70KB/s

In swarm log I see

  WARN [10-28|12:09:46.765] ChunkStore.Get can not retrieve chunk
  err="context deadline exceeded"

Why download speed so low?


texts: Purpose of mist wallet browser . Why doesnt Etheruem supports normal browser

texts: I still don't understand the need for a dedicated browser  like Mist. What are the challenges involved in using a normal browser for decentralized apps ?


texts: How to set allowUnlimitedContractSize in Ganache V2.1.0 with windows 10

texts:
while following this or this solution I found nowhere any file to make change for
allowUnlimitedContractSize = true so my problem is same as in link but how I can change this in Ganache v 2.1.0


texts: Is it possible to regenerate my seed phrase if I have my private key?

texts: The thing is I lost my seed phrase for MetaMask wallet. Luckily I had also backed up my private key. Is it possible to regenerate my "seed phrase" from my private key? It would be great if I could do it offline on my local computer because I don't want to share my private key on any online website.


texts:
I am trying to run a JS test script with truffles but I can not seem to find the right place to store the assertRevert file so that the module can be found by the script when I try to run the test.

const { assertRevert } = require('assertRevert');

Is that the top of my script.

The Error I am getting is Cannot find module 'assertRevert'

Thanks in advance !


texts:
I am creating a record of people and have created a structure
struct asset{
    uint assetId;
    string hash;
    address creatorAddress;
    uint cost;
    uint soldCount;
}

struct person{
    uint personId;
    address personAddress;
    uint earning;
    uint tokenCount;
    uint[] assetsUploaded;
    uint[] assetsBought;
    bool initialized;
}

mapping (uint => asset) public assets;
mapping (uint => person) public persons;

I am creating a new person as
        persons[personCount].personAddress = _sender;
        persons[personCount].earning= 0;
        persons[personCount].tokenCount = 0 ;
        persons[personCount].initialized = true;
        persons[personCount].assetsUploaded = new uint[](0);
        persons[personCount].assetsBought = new uint[](0);```

after doing all this i am unable to know whether the array is created or not because it is not showing up in remix.

**REMIX OUTPUT**
0:
uint256: personId 0
1:
address: personAddress 0x0000000000000000000000000000000000000000
2:
uint256: earning 0
3:
uint256: tokenCount 0
4:
bool: initialized false

assetsUploaded and assetsBought are missing here in the remix output

I am adding assets in assetsUploaded but am unable to see them. Is there any issue in the code which i need to fix?


texts: Truffle Setup Fails for some Truffle commands

texts:
I'm new to truffle and I have been following this tutorial below to set up the sample pet shop project:

http://truffleframework.com/tutorials/pet-shop

I have all the stuff that is required to set this example on my Mac. But when I give the truffle develop command, I get the following error:

Joe-MacBook-Pro:pet-shop-tutorial joe$ truffle develop
Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)

Here is my truffle.js:

module.exports = {
   networks: {
      development: {
        host: "localhost",
        port: 8545,
        network_id: "*" // Match any network id
      }
   }
};

What is the problem now with what I'm doing?

I'm using truffle version:

Joes-MacBook-Pro:pet-shop-tutorial joe$ truffle version
Truffle v3.4.11 (core: 3.4.11)
Solidity v0.4.15 (solc-js)


texts: Verifying ethash output Ethereum block hash

texts:
On the Ethash wiki, it mentions that a 16MB verification cache can be used to verify block hashes without generating the full DAG, but there are no further details on how this is done.

What's the verification algorithm?

EDIT: I'm not looking for a solution in Solidity where the blockhash is accessible. I'm looking for a way to validate that an Ethash output is valid off-chain.


texts: Can older motherboards be the reason for the drop of mining speed?

texts:
I have set up this small rig but I'm getting only half of the mining speed that these cards are able to generate. I checked these cards one by one on other boards and they tend to give ~21MH/s.

But when I combine them on this new motherboard (which is in fact pretty old and uses DDR2 RAM), the mining rate drops to half of that, individually and collectively, on x16 and x1, on board and via USB-risers.

Do you think that's the motherboard's fault? Or could it be the older Catalysts drivers that I installed for 7950? (7950 showed the same behavior)

Is there a way to generate full speed using the same motherboard by tweaking some setting or changing any of the hardware components? Otherwise, I'm only left with the option to replace it with some expensive one.

Brief Specs:

Bord: Gigabyte P35-DS3P
CPU: Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz
RAM: 4GB DDR2
GPU: 4x R9 280x (1x MSI @ x16_1.1, 1x Gigabyte @ x1_1.1, 2x Sapphire dual-x @ x1_1.1)

not crossfired
GPU-Z shows 98% load on each card when running
list-devices show all 4 cards
collective rate: ~44MH/s

PSU: CM 1000W Platinum (using SATA to 6pin/8pin extensions to power one of the cards)
Storage: SSD Samsung 850 Pro 120GB

See this for full Specs: CPU-Z & GPU-Z reports, Screenshots.


texts: Can't change a structs member value in a mapping?

texts:
I'm having an issue where when I try to change a struct objects value that is stored in my mapping, it doesn't permanently / globally change it, it only appears to change it locally.

In my example code below, I have a struct 'Test', a mapping 'testMap' of uint => 'Test' and 2 methods. I first call setMap(), where I put a mapping key of 1 to and set the nmbr member of the 'Test' struct to 4. I then call checkMap() and basically check what that member 'nmbr' is equal too.

The first time I call checkMap() (after calling setMap()), it returns 5 which indicates it went into the first if statement as it should, and set the 'nmbr' member to '5' as it should. When I call it checkMap() the second time 'nmbr' should now be equal to '5' therefore the first 'if' should evaluate to false, and the 'else if' should evaluate to true and return 34. However it still returns '5' meaning it never entered the second 'if' statement.

My question is why/how to get this desired functionality to work. Are mappings somewhat read-only after the values are set? I say somewhat because it lets me change the value locally in the function (because it returns '5' not '4') but doesn't appear to actually change the value.

Thanks in advance for any help ! Please let me know if you need anymore information for this question.

 struct Test {
   uint nmbr;
 }

 mapping(uint => Test) testMap;

 function setMap() public payable {

   testMap[1].nmbr = 4;

 }

 uint theResult = 99;

 function checkMap() public returns (uint) {

   if(testMap[1].nmbr == 4) {
       testMap[1].nmbr = 5;
       theResult = testMap[1].nmbr;
   } else if(testMap[1].nmbr == 5) {
       theResult = 34;
   }

   return theResult;
}


texts: MetaMask - RPC Error: Internal JSON-RPC error

texts:
I am getting this error when i trying to use metamask on my local for a simple transaction from one account(say A) to another (say B).

  code: -32603
  data: {originalError: {…}}
  message: "Internal JSON-RPC error."
  stack: "Error: WalletMiddleware - Invalid "from" address.↵    at h (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background.js:1:1226252)↵    at async chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background.js:1:1224243"
  proto: Object

Solutions I tried on my own(which didn't work ofc):
1. Downgrading my web3.js to beta 33,35 and 37 release. Currently, I am using 1.2.0 version.
2. Changing my metamask to mainnet and then back to local test net, which I am running on port:9545

Below is my smart contract:

contract ApprovalContract {
    address payable public sender;
    address payable public receiver;
    address public constant approver = <some account address>;

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

}

And below is my custom js (using web3.js)

var web3 = new Web3(Web3.givenProvider || "ws://localhost:9545");

var contractAddress = <contractAddress>;

var ApprovalContract = new web3.eth.Contract(ABI, contractAddress);

$('#contract-form').submit(function() {
  event.preventDefault();
  var fromAddress = $('#fromAddress').val();
  var toAddress = $('#toAddress').val();
  var amount = $('#amount').val();

  ApprovalContract.methods.deposit(toAddress).send({"from": fromAddress, "value": web3.utils.toWei(amount,'ether')},
    function(error, result) {
      if (error) {
        console.log('error: ' + error);
          $('#deposit-result').html('Error: ' + error);
      } else {
        $('#deposit-result').html('Success TX: <b>' + result + '</b>');
      }
    });
});

The flow is going into the last function and displaying the error as below:

error: Error: Internal JSON-RPC error.
{
  "originalError": {}
}

Expectation: Since my account A, is the account[0] of Metamask where is logging in to, I am expecting the Metamask pop up to show to confirm the transaction but instead I am getting this "Internal JSON RPC errror."

Any ideas ???

Thanks in advance!!!


texts:
I wonder what is the purpose of these functions? could you please provide me with some examples.

function burn(uint256 _value) returns (bool success) {
        if (balanceOf[msg.sender] < _value) throw;            // Check if the sender has enough
        if (_value <= 0) throw;
        balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);                      // Subtract from the sender
        totalSupply = SafeMath.safeSub(totalSupply,_value);                                // Updates totalSupply
        Burn(msg.sender, _value);
        return true;
    }

function freeze(uint256 _value) returns (bool success) {
    if (balanceOf[msg.sender] < _value) throw;            // Check if the sender has enough
    if (_value <= 0) throw;
    balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);                      // Subtract from the sender
    freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value);                                // Updates totalSupply
    Freeze(msg.sender, _value);
    return true;
}

function unfreeze(uint256 _value) returns (bool success) {
    if (freezeOf[msg.sender] < _value) throw;            // Check if the sender has enough
    if (_value <= 0) throw;
    freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value);                      // Subtract from the sender
    balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
    Unfreeze(msg.sender, _value);
    return true;
}


texts: Can private call increase the call stack count in Ethereum?

texts: I know that max call stack depth is 1024. I want to know that if calling private function can increase the depth.


texts: web3.eth.sign vs web3.eth.signTransaction, different or the same?

texts:
Does web3.eth.sign do the same thing as web3.eth.signTransaction?
For instance, could I sign a transaction with web3.eth.sign?

What is happening under the hood with those two methods?


texts: Is there any solidity IDE where we can break and check variable in VB style

texts: I am looking for a solidity IDE where I can break code execution in the middle and see variables value using mouse over the variable-text as in visual basic


texts:
Gnosis wallet is the golden standard of Ethereum multisig wallets:

https://wallet.gnosis.pm/

To minimize the security risks, does Gnosis wallet have a static HTML ZIP distribution? (Install once, run locally with Parity/Geth). I remember that I saw a download link somewhere, but I cannot no longer find it.


texts: Getting a weird error trying to verify a smart contract through hardhat

texts:
I am trying to verify on hardhat this nft-tutorial by chainlink https://blog.chain.link/build-deploy-and-sell-your-own-dynamic-nft/ but am unable to. What might be the problem? is it my syntax? Or just an issue with the libraries? (The contract address on Rinkeby is 0xA4630A1f2DaC2474d7397E7e8F3A41Bd574C1f9d). Addresses for the other constructor arguments are
RINKEBY_VRF_COORDINATOR = "0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B"
RINKEBY_LINKTOKEN = "0x01BE23585060835E02B77ef475b0Cc51aA1e0709"
RINKEBY_KEYHASH =   "0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311"

If you want to give it a shot, here is the github repo with my contract https://github.com/VictorOmbui/chainlink-nft. You can download and try to verify
Here is what I get from the console


texts: How to authorize multiple contracts issue the same ERC20 token?

texts:
I have a physical product to sell. I want to have a digital asset representing each unit of my physical asset. I have created an ERC20 token contract and each token represents a unique instance of the product that I manufacture and want to sell. A new token is minted when a new product comes out of assembly line.

Note: I have selected a fungible token because the lifetime value of each unit of the product remains equal. This also enables trading of my ERC20 token, and by extension, my product, on the open market, as the value of each will be the same forever.

The problem is most of my business logic ended up in the main ERC20 contract. I want to keep the ERC20 token contract as lean as possible. If my business logic changes, I don't want to pause the token and create a new contract. The token should remain the same. To achieve this I want a way that an authorized contract (s) or me as the owner, should be able to call, for e.g. an issueToken function from my main ERC20. Think of having multiple storefronts and sales channels taking orders and on determining a valid order, fulfill it and issue the token to the buyer. This will also help me keep orders, the physical product data and associated metadata, separate from my main ERC20. However, I do want a one-to-one mapping of a unique product with a unique ERC20 token.

How can I best structure this behavior?


texts: What are the advantages of creating a dapp over a normal web application?

texts: A lot of dapps seem like nothing new to me and the added benefit of creating a dapp seems very minimal besides decentralization.


texts:
Is it possible that Array.push to fail?

I noticed we never check whether it fails or not and thought it can be a vulnerability if an adversary makes it fail.


texts: Truffle Console error : invalid number value. Value must be an integer, while executing commands from a tutorial

texts:
I am trying to execute commands from the following tutorial:
medium Dev Tutorial
I am getting an integer error while executing a command:
truffle(ganache)> balanceInEth = address => web3.utils.fromWei(getBalance(address).toString(), 'wei')

[Function: balanceInEth]
truffle(ganache)> balanceInEth(victim.address)

/usr/local/lib/node_modules/truffle/build/cli.bundled.js:57187   throw
new Error('[number-to-bn] while converting number ' +
JSON.stringify(arg) + ' to BN.js instance, error: invalid number
value. Value must be an integer, hex string, BN or BigNumber instance.
Note, decimals are not supported.');

Somebody please guide me.
Zulfi.


texts: Can I track received payments to smart contract on a block explorer or do I need to run a contract method for this? I need the amount and payment identification information (I need to identify the payer somehow - probably he will send some kind of tracking code as payload). Is the answer different for ETH and ERC20 tokens?


texts: Guarantee of good's delivery via Smart contract

texts:
Assume Client A wants to sell a package to client B.

How should I write down a smart contract that prevents from B to receive the package while being refuse to pay in a claim that he isn't receive anything? (B is cheating)

In another word, How can I link with the action of a real(physical) transfer of item\package, and digital transfer of money? (Does it must rely on a physical sensor of the delivery?)

A good contract reference/solutions would be appreciated.


texts:
My solidity function emits an event with a uint256 of: 5060584000000000000000000
The problem is on the truffle side in my javascript test.
Here is the code:
const { BN, expectEvent, constants } = require('@openzeppelin/test-helpers');
const amount = new BN('100);
const price = new BN('5060584000');
const decimalsA = new BN ('5');
const decimalsB = new BN ('18');
const baseTen = new BN('10');
var totalValue = amount * price;
totalValue = totalValue * (baseTen ** (decimalsB - decimalsA));

The totalValue var always incorrectly returns 5060584000000000291504128 in the javascript test but the event correctly gives me 5060584000000000000000000.
This causes my test to fail of course. What am I doing wrong? (assuming something with big number precision?)


texts: Using two solc versions within the same truffle project

texts:
I am creating an app that has various imports that require two different versions of solidity. AragonOS(0.4.x) and openzeppelin(0.5.x)

Of course, there are breaking changes in 0.5.x so my question is this. Is it possible to tell truffle to compile some contracts with a different compiler than others within the same project? If not how could I get around this problem


texts: does the smart contract have something similar to the locktime in bitcoin?

texts: I want to develop a multi step gambling game with the contract, does the smart contract have something similar to the locktime in bitcoin to make the transactions can not be processed before certain time point


texts: How to connecting the nodes when Parity starting

texts:
I follow this tutorial to run the PoA demo on Parity.

And when I try to connect the nodes. I found that should do everytime after Parity started.

Can I connect them when I starting Parity? I found that the enode seems change everytime when I start the Parity...

By the way, the PoA will create block continuously though I don't send any transaction? I don't know clearly about it... Thanks a lot~ :)


texts:
can the owner of a contract actually take tokens from you if it's written like that in a contract? How come such contracts are actually allowed to be lsited on exchange sites.

How could you actually prevent being scammed?

An example in a code i've seen:

/* administrative functions */

/**
 * @dev Change owner.
 * @param _who The address of new owner.
 */
function changeOwner(address _who) external onlyOwner {
    assert(_who != address(0));
    commitDividend(msg.sender);
    commitDividend(_who);
    owner = _who;

}

And other similiar functions.
As said in the comments, how could i actually check that the source code matches on the actual contract?


texts: Starting ethpool / ethermine using ethminer on ubuntu

texts:
I am trying the below and they don't work for me :

ethminer --farm-recheck 200 -G -F eu1.ethermine.org:4444/0x<Your_Ethereum_Address>.<RigName>

ethminer --farm-recheck 200 -G -F eu1.ethpool.org:3333/0x<Your_Ethereum_Address>.<RigName>

And I am getting JSON RPC Error - Probably cannot connect

Why is that? Also what is the -S argument ( something about Stratum ?? what is that?) This doesn't work as well.


texts: Opening Smart Contracts on Quorum via json rpc api eth_sendtransaction for Integration Purposes

texts: if I wish to integrate quorum blockchain with other platforms via the json rpc api eth_sendtransaction method, what other implications can there be? Assuming the smart contract built is secured and that it performs the necessary checks (require, assert, etc)


texts: Mist : Getting error Couldn't connect to node? See the logs for more:

texts:
First I started the private network and connected with 2 node . After I opened another terminal and used the command to open the mist:

  open -a /Applications/Mist.app --args --rpc /usr/local/Cellar/test5/geth.ipc

but it shows an error :

  Couldn't connect to node? See the logs for more

and when I click ok button it shows


texts: Move Ethereum from my contract to a new wallet on Ledger S (using MyCrypto?)

texts:
A few years ago, I bought 10 ETH and had it set up on a laptop using the standard software at the time, which I think was Mist. I then moved 1 ETH to a new contract that I set up within Mist, not really knowing or understanding what I was doing.
I'm now trying to move my Ethereum off the laptop on on to a Ledger Nano S. I tried to download Mist and saw it was discontinued. They recommended MyCrypto (https://medium.com/@wolovim/mist-migration-patterns-6bcf066ac383) as an alternative which I downloaded.
I've imported my key file into MyCrypto and managed to transfer the 9 ETH in the wallet over to my new Ledger Nano S. However, I haven't a clue how to get the remaining 1 ETH that is locked up in the contract. I clicked on the contract tab in MyCrypto but it doesn't seem to be able to show my balance or allow me to send the ETH to my new account on the Ledger.
I tried downloading Mist anyway, and after some issues with Geth not getting unpacked correctly got it to start up, but it just hangs on a spinner and doesn't actually open.
Any help greatly appreciated!


texts: Calling a function doesn't take effect if I update two mappings

texts:
I'm testing a very simple example

contract MyNewTest {

Student[] students;
mapping (string => uint) nametonumber;
mapping (uint => string) numbertoname;
uint counter;

struct Student
{
    string name;
    uint num;
}

function addStudent(string _name)
{
    uint _id;
    _id = students.length++;
    students[_id].name = _name;
    students[_id].num = _id;
    numbertoname[_id] = _name;
    nametonumber[_name] = _id;
}

function getLength() constant
returns (uint)
{
    return students.length;
}

function getStudentNumber(string name) constant
returns (uint)
{
    return nametonumber[name];
}

function getStudentName(uint number) constant
returns (string)
{
    return numbertoname[number];
}

function getStudentAtPosition(uint x) constant
returns (string)
{
    return students[x].name;
}

function getStudentNumberAtPosition(uint x) constant
returns (uint)
{
    return students[x].num;
}
}

Am running a private local blockchain with mining turned on.

I tried to call

mynewtest.addStudent("Joe")

then

mynewtest.getLength()

it returns Zero although I added a new student.

However, inside the newStudent function if I remove either

numbertoname[_id] = _name;

or

nametonumber[_name] = _id;

everything works fine and when I add a student and do

mynewtest.getLength()

I get 1.

is there a constraint that I can't update two mappings in the same function?
Does this code work for anybody?


texts: Getting error in the contract code "please check your gas amount"

texts:
I am getting this error:

  Error: The contract code couldn't be stored, please check your gas
  amount.

This is when I am importing one extra contract with the name of TimedCrowdsale from OpenZeppelin. There was no error earlier when I imported and used Crowdsale, MintedCrowdsale and CappedCrowdsale from openzeppelin.


texts: Getting Invalid address or Invalid Params when deploying new contract on test network with Parity

texts:
I am trying to deploy new contract on the net and I get two errors depending how exactly how I do it. Since I can not get ABI compiling contract on Parity I use solc --abi to get it. Now depending if I use compiled code or compile it on Parity I get one of two following errors:

  ..node_modules/web3/lib/web3/formatters.js:271
      throw new Error('invalid address');

  Error: invalid address - (when compiling contract with web3 on Parity)

or

  Error: Invalid params - (when using contract compiled with solc)

Any ideas what I am doing wrong? Here is the code:

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

web3.eth.defaultAccount=web3.eth.accounts[0]

var source = "" +
"contract test {\n" +
"   function multiply(uint a) returns(uint d) {\n" +
"       return a * 7;\n" +
"   }\n" +
"}\n";
//var compiled = web3.eth.compile.solidity(source);

var compiled = 0x606060405260788060106000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa1146039576035565b6002565b34600257605160048080359060200190919050506067565b6040518082815260200191505060405180910390f35b60006007820290506073565b91905056;

console.log(compiled);

var abi = [{"constant":true,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"payable":false,"type":"function"}]

web3.eth.contract(abi).new({data: compiled}, function (err, contract) {
    if(err) {
        console.error(err);
        return;
        // callback fires twice, we only want the second call when the contract is deployed
    } else if(contract.address){
        var myContract = contract;
        console.log('address: ' + myContract.address);
    }
});

It is worth noting that calling:

web3.eth.compile.solidity(source);

gives:

  0x606060405260308060106000396000f3606060405260e060020a6000350463c6888fa18114601c575b6002565b346002576007600435026060908152602090f3

while solc --bin gives:

  0x606060405260788060106000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa1146039576035565b6002565b34600257605160048080359060200190919050506067565b6040518082815260200191505060405180910390f35b60006007820290506073565b91905056

Shouldn't they give same outcome?


texts: Blockchain synchronization starting from scratch after switching between main network and testnet

texts:
I first synchronized the main blockchain via the CLI geth --fast --cache=512, it took several days to download around 3,300,000 blocks.

Then I closed the command line geth, opened Mist, and switched to testnet. The testnet blockchain was completely downloaded in a few hours, I started to mine and reached around 800 ETH on the testnet in one night.

Then I re-switched to the main network in Mist and all of sudden, the synchronization started back from scratch.

I checked the %appdata%/Ethereum/geth/chaindata folder, and it still contains around 13Gb of data, but Mist doesn't seem to care, it resynchronizes everything as if the folder was empty ...

Same thing happened when I switched another time to testnet : %appdata%/Ethereum/testnet/geth/chaindata is full but in Mist, my mined ETH are gone and the synchronization starts from scratch.

Did I do anything wrong, or does it mean that :

One cannot use both testnet and main network ?
One cannot synchronize the blockchain first via the geth CLI and then via Mist user interface without having to start over?

Cheers


texts:
If I'm using fixed-point arithmetic to represent rates, for example, 2% in ray (27 decimal precision) would be 102000000000000000000000000000.
If I had a rate like 101333333333333333333333333333 (1.33%), how can I round it to the nearest 0.25%?
I would want 10125000000000000000000000000 (1.25%) to be the result.