texts:
Below is my solidity code. When i try to run function insertBusinessHash, the error "gas required exceeds allowance (42000000) or always failing transaction" pops up. Any suggestions?

pragma solidity ^0.5.11;

contract Audit_trail{

BusinessHash[] public businessHashes;
ProductionHash[] public productionHashes;
DistributionHash[] public distributionHashes;
ShopHash[] public shopHashes;

struct BusinessHash{
    bytes32 hashPart1;
    bytes32 hashPart2;
}

struct ProductionHash{
    bytes32 hashPart1;
    bytes32 hashPart2;
}

struct DistributionHash{
    bytes32 hashPart1;
    bytes32 hashPart2;
}

struct ShopHash{
    bytes32 hashPart1;
    bytes32 hashPart2;
}

function insertBusinessHash(bytes32 _hashPart1, bytes32 _hashPart2) public{
    BusinessHash memory newBusinessHash;

    newBusinessHash.hashPart1 = _hashPart1;
    newBusinessHash.hashPart2 = _hashPart2;

    businessHashes.push(newBusinessHash);
}

function getBusinessHashes() public view returns (bytes32[] memory, bytes32[] memory){
    uint length = businessHashes.length;

    bytes32[] memory hash1 = new bytes32[](length);
    bytes32[] memory hash2 = new bytes32[](length);

    for(uint i=0; i<businessHashes.length; i++){
        BusinessHash memory currentBusinessHash;
        currentBusinessHash = businessHashes[i];
        hash1[i] = currentBusinessHash.hashPart1;
        hash2[i] = currentBusinessHash.hashPart2;
    }

    return (hash1, hash2);
}

function insertProductionHash(bytes32 _hashPart1, bytes32 _hashPart2) public{
    ProductionHash memory newProductionHash;

    newProductionHash.hashPart1 = _hashPart1;
    newProductionHash.hashPart2 = _hashPart2;

    productionHashes.push(newProductionHash);
}

function getProductionHashes() public view returns (bytes32[] memory, bytes32[] memory){
    uint length = productionHashes.length;

    bytes32[] memory hash1 = new bytes32[](length);
    bytes32[] memory hash2 = new bytes32[](length);

    for(uint i=0; i<productionHashes.length; i++){
        ProductionHash memory currentProductionHash;
        currentProductionHash = productionHashes[i];
        hash1[i] = currentProductionHash.hashPart1;
        hash2[i] = currentProductionHash.hashPart2;
    }

    return (hash1, hash2);
}

function insertDistributionHash(bytes32 _hashPart1, bytes32 _hashPart2) public{
    DistributionHash memory newDistributionHash;

    newDistributionHash.hashPart1 = _hashPart1;
    newDistributionHash.hashPart2 = _hashPart2;

    distributionHashes.push(newDistributionHash);
}

function getDistributionHashes() public view returns (bytes32[] memory, bytes32[] memory){
    uint length = distributionHashes.length;

    bytes32[] memory hash1 = new bytes32[](length);
    bytes32[] memory hash2 = new bytes32[](length);

    for(uint i=0; i<distributionHashes.length; i++){
        DistributionHash memory currentDistributionHash;
        currentDistributionHash = distributionHashes[i];
        hash1[i] = currentDistributionHash.hashPart1;
        hash2[i] = currentDistributionHash.hashPart2;
    }

    return (hash1, hash2);
}

function insertShopHash(bytes32 _hashPart1, bytes32 _hashPart2) public{
    ShopHash memory newShopHash;

    newShopHash.hashPart1 = _hashPart1;
    newShopHash.hashPart2 = _hashPart2;

    shopHashes.push(newShopHash);
}

function getShopHashes() public view returns (bytes32[] memory, bytes32[] memory){
    uint length = shopHashes.length;

    bytes32[] memory hash1 = new bytes32[](length);
    bytes32[] memory hash2 = new bytes32[](length);

    for(uint i=0; i<shopHashes.length; i++){
        ShopHash memory currentShopHash;
        currentShopHash = shopHashes[i];
        hash1[i] = currentShopHash.hashPart1;
        hash2[i] = currentShopHash.hashPart2;
    }

    return (hash1, hash2);
}

}


texts: How to make ERC20 tokens non-transferable until a certain date?

texts:
I want to create a token is not sellable or transferable until a specific date (so that only initial buyers can buy tokens, but they should not sell tokens until ICO is completed), what would be the best way to do this?

For example, if I was to implement something like

if(msg.sender != owner){
   require(now >= endOfICO);
}

inside of the transfer function would that be acceptable, or even usable?

Thanks a lot for any help or advice, or even links to other discussions as I cannot find information on how to incorporate time-based locks on transfers.


texts: Question about Remix warnings: gas cost and same name of variable

texts:
When I try to compile the following contract on Remix:
pragma solidity ^0.5.9;
contract good{
   mapping (address =>uint) public balances;
   function withdraw () public {
      uint balance = balances [ msg . sender ];
      balances [ msg . sender ] = 0;
      msg . sender . transfer ( balance );
   }
// state reverted , balance restored if transfer fails
}

I am getting the two warnings:

Gas costs: Gas requirement of function good.withdraw is infinite:
If the gas requirement of a function is higher than the block gas
limit, it cannot be executed.  Please avoid loops in your functions or
actions that modify large areas of storage (this includes clearing or
copying arrays in storage)

Why the gas cost is infinite? I am not using 'call'?

2)same name of var good.withdraw() : Variables have very similar names
"balance" and "balances". Pos: 5:6:

Will the EVM consider balance and balances as same or is this just a Remix issue?
Zulfi.


texts: Compiling cpp-ethereum (aleth) sources as a part of my cpp project

texts:
I want to use cpp-ethereum aleth smart contracts sources in my altcoin project. My sources can compile with cmake or autotools system. I tried two ways to compile cpp-ethereum with my sources:

Using cmake build system, I had added aleth as git submodules, then in my CMakeLists.txt putted this command
add_subdirectory(src/cpp-ethereum)
and then received an error:

CMake Error at src/cpp-ethereum/CMakeLists.txt:8 (message):
  Git submodules not initialized, execute:

git submodule update --init

So, I understood that CMakeLists.txt in aleth sources designed for stand alone compiling...

Using autotools build system: I had put all dependencies, cpp-ethereum (aleth) sources into my project dir. Put all paths into Makefile.am and configure.ac scripts, but during compile received dependencies sources errors:

Please, give me some instructions how can I compile my sources (no matter, with using autotools or cmake, but will be better with cmake of course) with cpp-ethereum sources with all dependencies in a single binary. Thanks in advance!


texts: How Do I Create A New Ethereum Account/Address In My DApp

texts:
i am starting to learn how to create a Dapp and i am trying to create a way for users to login without having to use metamask.

I am using truffle-hdwallet-provider which works fine for creating an account but i don't think i understand how it works.

I can create a new instance of a provider using:

const provider = new HDWalletProvider(mnemonic, network);

It will create an address no matter what string value i use for mnemonic. if a wallet can be created with any string value, then why does metamask enforce a 12 word mnemonic?

If an account can be created with a mnemonic, why does metamask ask for the private key if i want to import an account?

What is the functional difference between the mnemonic and the private key if both can get the same address?

Is it possible to use a private key to create an account on my app using HDWalletProvider i cant find any examples or documentation explaining this.

^^^ I have asked a few questions because i am new to this, any answers to any of the questions is appreciated.


texts: Unable to deploy contract on Ropsten network

texts:
When I try to migrate contract to Ropsten Network (truffle migrate --network ropsten) it keeps migrating the contract on the net with id 4447 unless Ropsten is the only network configured in truffle.js file.

Here is my configuration

module.exports = {
  networks: {
  ropsten: {
    network_id: 3,
    host: "localhost",
    port: 9545,
    gas: 6712388,
    gasPrice: 65000000000
  }
},
optimizer: {
  "enabled": true,
  "runs": 200
}
};

Snippet of the generated JSON of my contract after truffle migrate --network ropsten

"networks": {
    "4447": {
      "events": {},
      "links": {},
      "address": "0xf204a4ef082f5c04bb89f7d5e6568b796096735a",
      "transactionHash":
"0x35abaaed14ab37937fdcf38551ee1b6068c5950ad4d59b8df65a6ad852892b13"
    }
  },

Version

-> % truffle version
Truffle v4.1.11 (core: 4.1.11)
Solidity v0.4.24 (solc-js)

Configuration with multiple network as requested by @Roman Frolov

module.exports = {
  networks: {
      development: {
      host: "localhost",
      port: 9545,
      network_id: "*",
      gas: 6712388,
      gasPrice: 65000000000
    }
  ropsten: {
    network_id: 3,
    host: "localhost",
    port: 9545,
    gas: 6712388,
    gasPrice: 65000000000
  }
},
optimizer: {
      "enabled": true,
      "runs": 200
    }
    };


texts:
when I try to compile my contract I see errors like this :

DemirelToken.sol

https://eksiup.com/p/4z49413damc3

here's the code :

    pragma solidity ^0.5.0;

import "node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";

contract DemirelToken is ERC20, ERC20Detailed {
    constructor(uint256 initialSupply) ERC20Detailed("Gold", "GLD", 18) public {
        _mint(msg.sender, initialSupply);
    }
}

I get errors like this:

node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol:3:1: ParserError: Source "node_modules/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol" not found: File import callback not supported
import "./IERC20.sol";
^--------------------^
,node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol:4:1: ParserError: Source "node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol" not found: File import callback not supported
import "../../math/SafeMath.sol";
^-------------------------------^
,node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol:3:1: ParserError: Source "node_modules/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol" not found: File import callback not supported
import "./IERC20.sol";


texts: How to get price of ETH to DAI within smart contract?

texts: Is it possible to get the current price of Ethereum to Dai within a smart contract? Can this be done without a transaction, using a read operation by the nodes on some kind of existing decentralized exchange or the dai contract itself?


texts:
I have a couple of applications running on an Ethereum Blockchain hosted on a VM. For some reason, every now and then, I find my VM rebooted... so my blockchain is turned off...

There's no problem in restarting the chain again, but since the Blockchain is not halted carefully, I end up losing all transactions.

Is there something that I can do to address this issue? Periodically, I try to switch off / on the chain to minimise potential damage.

I am running Geth/PoA on a windows box.


texts: Is a hardfork more democratic then a softfork?

texts:
I was told that a hardfork would be a more democratic choice for Ethereum and the DAO problem then a Softfork was. Yet it has a greater impact to the system, as far as I understood. Which is true?
Am I right that any kind of fork is provided by the developers of Ethereum as only they got the knowledge to create it. So is it comparable to some kind of governance by the dev team?


texts: Error: [ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string

texts:
While recovering address from hash and sign, getting above error.

myHash = '0xd0109ef5f602b69354acd389a2c752f9b80ef6bbce92a922ae8853d43a027b68';

mySign = '0xebedaa7185fe2b0c4a6a6e3f1a833abd14eeb2f05f46931ec5c602e9f67a43af2071e9bcda9a1598dcc9e936ceea71d95d648f9c390c1ef6d58fd01012e2ab4e1c';

var getRecoveredAddress = function (myHash, mySign)
{
    return new Promise(function (resolve, reject) {
        token.recover(myHash, mySign
            , (error, result) => {
                if (error) reject(error);
                console.log(result)
                resolve(result);
            })
    });
};

Please let me know what what's wrong with this code!! Thank you in advance!


texts: What's happening within child DAO #59 on the ETC chain?

texts:
From What are the balances of The DAO and it's child DAOs on the Ethereum Classic chain? we know that the baddies have drained 3641694.241898506992612606 ETH from child DAO #59.

What is happening within child DAO #59?

See also:

What are the balances of The DAO and it's child DAOs on the Ethereum Classic chain?
How many ethers have been drained through the recursive call attacks on The DAO?


texts: Exodus & Trust Wallets at the same time. Is it possible? Please help

texts:
I used my trust wallet’s 12 word on exodus wallet that I recently downloaded on my laptop and all the funds appears on both wallets now ! (In fact after Exodus wallet started to work the Trust wallet was showing *** for amount of each asset for a few minutes but then started to work same as before and showing all the coins now).
My question is can I keep and use both wallets at the same time ?
Also all my Tron coins are staked on Trust wallet but is still showing on exodus wallet as well. I am confused. Please help.
Thanks,


texts: Web3 API call error in Meteor Autovalue function and collection insert

texts:
I am running a Meteor application and faced with an error I cannot figure out.  I am using a quick form to insert a document into a collection and one of the fields is a Hash address to be obtained from a web3 api call using auto value.

//Schema with autovalue to obtain hash address via web3 call
CustomerSchema = new SimpleSchema({
  customerBlockchainAddress: {
    type: String,
    label: "Blockchain Address",
    autoValue: function() {
         var address = web3.personal.newAccount("password");
         console.log("Address: ", address);
         return address;
     },
     autoform: {
         type: "hidden"
     }
  },
//additional schema fields

The method is invoked by a quick form. See below:

//HTML
<template name="NewCompany">

    {{#if isSuccessfulCompany }}

Successfully registered company information.

    {{else}}

Register Company Information:

        {{> quickForm collection="Companies" id="insertCompanyForm" type="method" meteormethod="insertCompany" class="new-Company-form"}}
    {{/ if}}

Insert method:

insertCustomer:function(customer){
    CustomerSchema.clean(customer, {
      extendAutoValueContext: {
        isInsert: true,
        isUpdate: false,
        isUpsert: false,
        isFromTrustedCode: false
      }
    });
    check(customer, CustomerSchema);
    if (! this.userId) {
        throw new Meteor.Error('not-authorized');
    }
    if(! Roles.userIsInRole(this.userId,'individual')){
        throw new Meteor.Error('not-authorized for your role');
    }
    //custom API that takes fields from the customer doc and stores
    them on the blockchain
    Meteor.call('individualRegistration', customer, function (error,
    result) {
             if (error) {
                 console.log("error", error);
             };
             console.log(result);
         });
    return Customers.insert(customer);
}

The error I am getting is:

Exception while invoking method 'insertCustomer' TypeError:
XMLHttpRequest is not a function

Using log statements, the AutoValue function is obtaining a new address from the web3 call as expected but it is printing four times with different addresses before the error is thrown.  If I hard code the address with just a string, the insert function works properly as expected with the custom API.

Any help in understanding this error would be greatly appreciated.

Thanks


texts: Why web3.version.api shows undefined for web3 1.0 and not undefined for web3 0.20.3?

texts:
I'm trying to use MetaMask and web3js to talk to my smart contract. Below are my test codes.

This is without defining a web3 js file and I get the result "0.20.3" at console.

<script>
window.addEventListener("load", function() {
    // Checking if Web3 has been injected by the browser (Mist/MetaMask)
    if (typeof web3 !== "undefined") {
      // Use Mist/MetaMask's provider
      web3 = new Web3(web3.currentProvider);
      var version = web3.version.api;
      console.log(version);
    } else {
      console.log("No web3? You should consider trying MetaMask!");
      // fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
      window.web3 = new Web3(
        new Web3.providers.HttpProvider("https://localhost:8545")
      );
    });
</script>

And this is with defining a web3 1.0 beta-34 file. But I get "undefined" at console.

<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/web3.min.js"></script>
<script>
        window.addEventListener('load', function() {
        // Check if Web3 has been injected by the browser:
        if (typeof web3 !== 'undefined') {
            // You have a web3 browser! Continue below!
            web3 = new Web3(web3.currentProvider);

            var version = web3.version.api;
            console.log(version); // "0.2.0"

            startApp(web3);

        } else {
            alert("No hay web3");
            // Warn the user that they need to get a web3 browser
            // Or install MetaMask, maybe with a nice graphic.
        }
    });
</script>


texts: So I'm super late withdrawing the DAO and depositing it in my Ethereum Wallet. I tried to withdraw my DAO on one occasion. I created a DOA Watch Contract and a DAO Withdraw Contract. Nothing happened. I had no confirmations on my execution contract and nothing was deposited in my account. Should I have more Ether in my wallet to propel the withdraw? Total novice here. Any advice would be appreciated. Cheers!


texts: why using uint for account balance in solidity?

texts: This question may have been asked many times but I did not find a good answer online. The account balance is usually represented as fixed decimal in other language but in Solidity it is uint. How an integer can be used for account balance?


texts:
I cannot unlock my account.

I decrypted my account from encrypted accoun, and want to unlock it to deploy contract.

However, I am getting this error,

 Node error: {"code":-32000,"message":"could not decrypt key with given passphrase"

This is my web3 code.

const decryptEtherAccount = await web3.eth.accounts.decrypt(etherAccount,'test!')
web3.eth.defaultAccount = await decryptEtherAccount.address
const account = await web3.eth.getAccounts()
const address = await web3.eth.personal.unlockAccount(account[0], decryptEtherAccount.privateKey, 1000)
console.log(address)

Are there any problems of my code?

Also, could we unlock account, not node?


texts:
Please look into the below Web3 script, this is returning undefined, but it must have returned the transaction hash and its related meta data.
Code:
const Tx = require('ethereumjs-tx').Transaction
const Web3 = require('web3')
const web3 = new Web3("https://ropsten.infura.io/v3/...")

const account1 = 'Account1'
const account2 = 'Account2'

const pk1 = Buffer.from('privateKey', 'hex')

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

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

const tx = new Tx(txObject)
tx.sign(pk1)

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

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


texts: Are Whisper and Swarm still being developed?

texts:
I know that both Whisper and Swarm were is early prototype stages, with Whisper already being included in the geth client.

What is the current status of these project? I know Swarm has been largely superseded by ipfs, but there was a plan to monetize it. Is that still being worked on?


texts: What is a suitable pattern for mobile/web apps that leverage ether?

texts:
Looking to understand how to build an app that leverages Ethereum - what suitable patterns are out there (ideally to go via some tutorials).

I'd like to build a Hello World simple app (mobile and/or web) that allows a user to pay a bit of ether to take a message, hash it, and put the result on the blockchain for all to see (and more importantly, verify that something was known/sent at a particular time)

(asked before but was closed down as the question was too broad: What is a suitable pattern for building a web/mobile app that leverages ether?)


texts: How to send transaction/call function from server-side?

texts:
After an event emits from my smart contract and I hear it server-side, I want to call a certain function in the smart contract and pass it some information to use.

I'm wondering how you place a transaction server-side. In this question it seems simple: Signing a transaction server-side

but how does the server-side know which account to use/private key. Browser-side it pops-up metamask and the user physically signs it. How does server-side do that? There is nobody to physically sign it and no where for it to pop-up?

Thanks for any help!


texts: isContract function using EVM assembly to get the address' code size

texts:
My problem is that I need to make sure my contract processes only the transactions coming from EOA (externally owned accounts). For this I need to determine the type of account I'm dealing with. In this question I found a solution, here's the code:

function isContract(address addr) returns (bool) {
  uint size;
  assembly { size := extcodesize(addr) }
  return size > 0;
}

Since I don't understand assembly at all, I have no idea what's going on there.

Does this function work as described?
Is there a way for a contract to fool it?
Will this function work when the network transitions to POS?

Thank you!


texts:
I'm a beginner in ICO and i make a mistake

i have 2 transaction with REVERETED status. What can i do to fix that issue ?.

Tx  ID No.1
0xa713a3bbadb029fd186302ef59b4beac04aa02bfd52e7647ddb6d557e73aee48

TX ID No. 2
0x310efedeea02d9232ba36a2f8499f83c1934d6b2068d4726778c1f7da59e66b9

Thanks you in advance

Daniel


texts: Has proof-of-stake been formally proved?

texts:
From my understanding Bitcoin solves the Byzantine's Generals Problem under the assumption that there's no attacker that control more than 50%+1 of the mining power and this has been studied and proved in academic papers.

But what about Proof-of-Stake? I see several crypto (not just Ethereum) using or planning to use PoS. But does it work?  Has proof-of-stake been studied in scientific papers and proved to actually solve the same problem that Bitcoin solves?  Under which assumptions?

I understand that PoS is not wasteful like PoW and that PoS apparently allows for faster blocks, but if PoW solves one problem that PoS doesn't solve, PoS ain't an option to replace PoW because they're simply not doing the same thing?


texts: Recover msg.sender in externally signed private transaction in Quorum

texts:
When I send an externally signed private transaction (contract bytecode) using the sendRawRequest API of quorum-js, the from field, or the msg.sender field at the solidity contract comes out as a random address. It seems like the Quorum node is creating a new account when I send the transaction after storing it at Tessera using storeRaw API.
Although, when it's not a private transaction, sending an externally signed transaction does yield the original signer in the msg.sender field at the contract level.
Is there a way to get recover the original signer (as msg.sender maybe) at the contract level?
I followed this guide: https://github.com/ConsenSys/quorum.js/blob/master/7nodes-test/deployContractViaHttp-externalSigningTemplate.js


texts: adding an struct instance into a dynamic array of struct objects

texts:
Consider this code.
function getDoctorsList(uint[] memory _docIds) public view returns (doctor[] memory) {
    doctor[] memory _doctors;
    for(uint i = 0; i < _docIds.length; i++) {
        _doctors[i] = doctors[_docIds[i]];
    }
    return _doctors;
}

Here I am using an array of id's of a mapping and store the appropriate struct instance into a dynamic array of struct instances. But I can not execute this function. It is saying that:

call to DogChain.getDoctorsList errored: VM error: invalid opcode. invalid opcode The execution might have thrown. Debug the transaction to get more information.

Previously, I tried pushing each items. But compiler says, it is not possible. can anyone help me with this?


texts: Decentralising the presentation tier/layer of a DApp

texts:
Though the data/state tier (i.e., the ledger), business logic tier (i.e., smart contracts) and storage tier (i.e., file storage e.g., IPFS, etc) is decentralised, understand that the presentation layer of DApps is still centralized on a web server, which somewhat goes against the spirit of a truly decentralized application.

How then can one build a truly decentralized for all 4 tiers?

Nathan Aw


texts: How to capture opcode executed for a transaction

texts:
In remix debug mode, we can see opcodes executed line by line for a transaction, is there any way we can print the list of opcode and their corresponding line number(maybe memory address?) when executing a transaction locally on a Geth client connected to a private chain? Maybe we need to instrument the Geth client?
Some concrete idea or example would be really helpful! I want to collect this information for code coverage purpose.

New Edit: I figured out how to use debug.traceTransaction(), however, the returned JSON still misses some info, for example, in the remix debugger, a line of opcode such as

"PUSH1 40"

will only show "PUSH1" in the trace, how can I get the more detailed trace like the ones Remix debugger provides?


texts: Want to Access remote dai smart contract in another smart contract

texts:
I want to transfer Dai tokens from account1 to account2.
My account1 has 50 DAI tokens.
Kovan Dai contract address given by makerdao is: 0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa.

What I am doing is,
1. I have signed in metamask by account1.
2. approve balance by a method called approve(address(this), balance).
    - address(this) is my deployed smart contract address.

function approve(uint _value) public {
    _daiToken.approve(address(this), _value);
}

Transfer balance to account2 using transferFrom(address(this), account2, balance) => which is not working.

function transferFrom(address account2, uint _value) public {
    _daiToken.transferFrom(address(this), account2, _value);
}

But it gets an error,
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
The execution failed due to an exception. Reverted

I search for this error but it didn't satisfy to solve the problem. I don't know I am sending wrong address in approve and transferFrom or doing something anything wrong.

Full Code snippet
- I deployed My Contract smart contract using DAI smart contract address    (0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa).

pragma solidity ^0.5.0;

interface IERC20 {
    function totalSupply() external view returns (uint supply);
    function balanceOf(address _owner) external view returns (uint balance);
    function transfer(address _to, uint _value) external returns (bool success);
    function transferFrom(address _from, address _to, uint _value) external returns (bool success);
    function approve(address _spender, uint _value) external returns (bool success);
    function allowance(address _owner, address _spender) external view returns (uint remaining);
    function decimals() external view returns(uint digits);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
}

contract owned {
    IERC20 daitoken;
    address owner;

    constructor(address addr) public{
        owner = msg.sender;
        daitoken = IERC20(addr);
    }

    modifier onlyOwner {
        require(msg.sender == owner,
                "Only the contract owner can call this function");
        _;
    }
}

contract MyContract is owned{

    address owner;

    constructor(address _daiToken)
    public
    owned(_daiToken)
    {}

    function approves(uint256 _value) public {
        daitoken.approve(address(this), _value);
    }

    function allowance(address _owner, address _spender) public view returns(uint256) {
        return daitoken.allowance(_owner, _spender);
    }

    function transferFroms(address _to, uint256 _value) public {
        daitoken.transferFrom(address(this), _to, _value);
    }

    function transfers(address _addr, uint256 _value) external {
        require(daitoken.transfer(_addr, _value));
    }

    function balanceOf(address _addr) public view returns(uint256){
        return daitoken.balanceOf(_addr);
    }
}


texts:
Reading the uport whitepaper https://uport.me/library/pdf/whitepaper.pdf :

The purpose of having a Proxy contract as the core identifier is defined as :

  The purpose of having a Proxy contract as the core identifier is that
  it allows the user to replace their private key while maintaining a
  persistent identifier. If the user’s uPort identifier instead was the
  public key corresponding to their private key, they would lose control
  over their identifier if they were to lose the device where the
  private key is held.

Why do I need my private key ? If the proxy contract is essentially acting as a private key in that it's used to identify me then why keep the private key ?


texts:
i'm using etherscan API to get info about transaction transfer event.
I'm using this route :
https://api.etherscan.io/api?module=account&action=tokentx&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken

I tried on a specific address, and i got this return :
   {
      "blockNumber":"11776758",
      "timeStamp":"1612268225",
      "hash":"0x30568148b640d7aec6e5474a97b717d804cadd036a22536768da1db92f96749b",
      "nonce":"180",
      "blockHash":"0x7679fc069005991fb1debfff9afe0a16ed68ed24745143b1df1af25342aa5b2e",
      "from":"0x9f4aa9b4661f0c55b61fc12b1944f006a71c773f",
      "contractAddress":"0x8a9c4dfe8b9d8962b31e4e16f8321c44d48e246e",
      "to":"0x3acefe2fb0375018b68d8499ec9c73bf96a27ba3",
      "value":"7412118173062171917583",
      "tokenName":"NameChangeToken",
      "tokenSymbol":"NCT",
      "tokenDecimal":"18",
      "transactionIndex":"33",
      "gas":"151692",
      "gasPrice":"180000000000",
      "gasUsed":"124538",
      "cumulativeGasUsed":"2146953",
      "input":"deprecated",
      "confirmations":"762"
   },

Here we can see user transfer some eth to get NCT token.
How can i know the amount of wich currency the user use to buy NCT token ? Because the only information i have here is the NCT token amount.
I don't know with that data with wich currencie user swap NCT ( that was ETH, USDT etc ... ?) I don't either if that was a buy or a sell :/
I'm probably using the wrong api route ?


texts: Listing filters in geth. Do they timeout and expire?

texts:
Suppose I make a JSON-RPC call to create a new filter as follows (from the documention page):

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":["0x12341234"]}],"id":73}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x1" // This is the filter ID- 0x1
}

Now I have registered a filter at the geth client and now I can make further calls to the filter.

Can I go to the geth console and list all the registered filters (in case I forget them or just for other reasons)? Do they ever expire/timeout except of course after a restart which clears all the filters.


texts: Examples of light-client interactions to extract Merkle proofs?

texts:
I'd be grateful for pointers to working examples of interacting with the geth/parity light-client protocols. I'm particularly interested in working code which shows how to extract the Merkle proof that a transaction (or transaction receipt) is included in a block hash.

NB: This question is sort of similar to this one, but it has a little more texture, and I'm hoping the documentation has improved since then.


texts:
function TriggerContract() {
        var account = getAccounts();
        var test = web3.eth.defaultAccount;

    console.log(account);
    var q = document.getElementById("Quantity").value;
    var u = toHex(document.getElementById("Unit").value);
    var m = toHex(document.getElementById("Material").value);
    var x = contractAddress.countMaterials(function(err, result) {
          if (err) {
            console.log(err)
          } else {
            console.log("Hey")
          }
        });
    console.log(x);
    contractAddress.setMaterial((test,q, u, m) => {
          if (err) {
            console.log(err)
          } else {
            console.log("YES")
          }
        });
    Reset();
  }

I get a "Uncaught Error: Invalid number of arguments to Solidity function" on the following line and have no idea why. The number of arguments should be correct. Any suggestions would be greatly appreciated.

contractAddress.setMaterial((test,q, u, m)

function setMaterial(address _address, uint64 _weight, bytes16 _material, bytes16 _unit) public{
        materials[_address] = Material(_address, _weight, _unit, _material);

        materialAccounts.push(_address) -1;
        emit materialAdded(_materialID);
    }


texts: Error that contract is not convertible to expected type address

texts:
In older solidity compilers this code snippet works. In newer compilers, I get an error. Can someone what I need to change so it works again? I get the following error message: "Type contract createWallet is not implicitly convertible to expected type address. I extracted the snippet so it is easier to see my problem.

contract factorywallet {

   function newWallet(uint256 _unlockDate) public returns(address wallet){
        wallet = new createWallet(msg.sender);
    }
}

contract createWallet{
    address public owner;

    constructor(address _owner) public {
        owner = _owner;
    }
}


texts: Does it make sense to have a Node.js backend serving json to frontend for dapp?

texts:
Currently, the architecture I am looking at is that the smart contract (SC) sits on the ethereum network, but it is a complex and multilevel contract system. Just navigating through the tiers of the smart contract platform is a lot of effort and I am considering making a node.js backend service that implements web3 to make the multi-level SC calls and return my needed data in a JSON RESTful response.

This was meant to reduce the amount of craziness that the frontend (vue.js) would have to handle in order to serve up the UI the data it needs.

Although, the blockchain has all the events created and I can use web3 to search back and populate the UI that way, but then I would also need to navigate through multi-level SCs to get the data I need.

Would it make more sense to have a fat Frontend UI that does event parsing and platform navigation, or to have a nodeJS backend that is opensource acting as a blockchain reader that handles that for me and then serves up everything in a pretty JSON for the UI?


texts: For an Openethereum PoW private chain is there a simple configuration to make my node mine blocks?  I know geth just needs a --mine but I would prefer to do this in Openethereum if easily possible.


texts: Infura returns strange error: `query returned more than 10000 results`

texts:
The purpose of the function below is to track USDT that is transferred to and from Yearn and Fulcrum.
When I call search_liquidity(_toBlock), I get an error that says Returned error: query returned more than 10000 results. This error is confusing to me because I even get this error when I query USDT transactions between Yearn and Fulcrum from a single block.
Are there situations where Infura returns this error even though the query did not return more than 10000 results? Is this a problem with the Fulcrum address I selected?
let search_liquidity = async(_toBlock) => {
        try {
            withdraw_events = await USDT_contract_interface.getPastEvents('Transfer',
                {
                    filter: {
                        src: '0xE6354ed5bC4b393a5Aad09f21c46E101e692d447', // Yearn sender and receiver address for USDT
                        dst: '0xf013406a0b1d544238083df0b93ad0d2cbe0f65f' // what I suspect to be the sender and receiver address for USDT for Fulcrum
                    },
                    fromBlock: yearn_liquidity_transfer_addresses.starter_block,
                    toBlock: _toBlock
                }
            )

            deposit_events = await USDT_contract_interface.getPastEvents('Transfer',
                {
                    filter: {
                        src: '0xf013406a0b1d544238083df0b93ad0d2cbe0f65f',
                        dst: '0xE6354ed5bC4b393a5Aad09f21c46E101e692d447'
                    },
                    fromBlock: yearn_liquidity_transfer_addresses.starter_block,
                    toBlock: _toBlock
                }
            )

            events.push(...withdraw_events,...deposit_events)
        }
        catch(error) {
            console.log(error)
        }
    }


texts: How to get the contract address after deploying contract without using truffle?

texts:
I'm currently using web3 0.20.6 and I'm planning to stay in web3@0.20.6 because there are issues with HTTP in the beta versions of web3@1.0.0-beta.* like

  The current provider doesn't support subscriptions: HttpProvider

Now I'm trying to figure out how to get the contract address after being deployed.
Because in web3@1.0.0-beta.*, we can use like the example below to get the contract address.

    contract.deploy({
        data: '0x'+bin,
        arguments: [request.body.vin, cost, request.body.buyer]
    })
    .send({
        from: request.body.dealer,
        gas: gas
    })
    .on('receipt', receipt => {
        util.log(`>>>>> contractApi - Contract sucessfully deployed @ address: ${receipt.contractAddress}`);

        data.contract_address = receipt.contractAddress;

        response.json(data);
    });

But how do you do it in web3@0.20.6 ? I couldn't find the solutions online without using truffle. I'm not planning to use truffle as well.

What I did try was,

const deployedContract = LoginContract.new ({
    data: '0x'+binLogin,
    from: '6ded1c5b448819a6cde4293e33fbe54583ef5c52',
    gas: 4700000
});

contractData = deployedContract.address;
util.log(`>>>>> setup - Login Contract sucessfully deployed @ address: ${contractData}`)

But the result in console is undefined address

  22 Mar 14:04:15 - >>>>> setup - Login Contract sucessfully deployed @ address: undefined

Then after about 5-10 seconds, this popped up in the console

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

I'm like super confused right now because the gas amount should be sufficient.

EDIT 1
Thanks to @mirg's answer, the deployment is successful. However, I noticed that the instructions below the contract deployment:

contractData = deployedContract.address;
util.log(`>>>>> setup - Login Contract sucessfully deployed @ address: ${contractData}`)

continue to run and does not wait for the contract deployment to complete/finish.

How do you make further instructions to wait and process the result of that contract deployment?
In web3@1.0.0-beta.* it is achievable by using

.on('receipt', receipt => {}

But I have no idea how it is achieved using web3@0.20.6.


texts: revoke or invalidate token when after 30min

texts:
Dapp/SmartContract Goal

I send x amount of ether to Address "AAA" from Address "000"

If after 10 min if the newly received address "AAA" still has all x amount of ether.  It should return all the ether back to address "000" register "unused" to that transaction.

Can someone show this PoC using Solidity-Browser?

thanks


texts:
I want to build a de-fi webpage that receives ethereum from users, so i want to store all ethereum within a smart contract and want to know how much ether does a user has. if i create a new unique wallet for each user then i have to send each sent ether to main smart contract and i have to pay gas price for each user. is there a way to make users to store ethers in my smart contract and i can make a relationship between user and sent ether balance in one step?
example:

create a unique ethereum wallet for user
show that wallet only for that user so i can create a relationship between username and ether sent.
transfer users eth to main de-fi contract.

i am paying gas for each user with step 3 just to create relationship between user and ethereum wallet. is there a better way?


texts: Does Ethereum have a payment URI like Bitcoin?

texts:
Does Ethereum offer a payment URI like Bitcoin does?
I'd like a user to be able to click a link and have a wallet (Mist) open with a transaction to that address.

Examples

Just the address:

bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W

Address with name:

bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Luke-Jr

Request 20.30 BTC to "Luke-Jr":

bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=20.3&label=Luke-Jr

more here


texts: Is it possible to send ERC20 tokens to a contract address like sending ether?

texts: Can we send ERC20 tokens to a contract address??


texts: Is it possible to get the transaction hash from within a Solidity function call?

texts:
Within a Solidity function, is the transaction hash available as a global variable from within the contract? I would have thought it would be something like tx.hash
in the same way you can do tx.origin etc.

My thinking is that the transaction hash will not be available until the contract has been mined. Is this correct?


texts: Why view function is changing the state?

texts:
Following piece of code returns the already stored addresses on smart contract.

function getAddr(string AddrName) public view returns(address) {
    return addressBook[keccak256(AddrName)];
}

When I try to execute function, it execute as a WRITE function instead of READ function. What maybe the problem?


texts:
We are using @truffle/hdwallet-provider [1] to sign transactions when deploying smart contracts on Besu. All the provided examples left the private key or the mnemonic in plain text in the truffle config file. I would like to use a JSON UTC file.
What is the best way to solve that?
[1] https://www.npmjs.com/package/@truffle/hdwallet-provider


texts: "No Contracts Deployed" TRUFFLE ERROR PLEASE HELP!

texts:
I really need help!
[12:20 PM]
i deployed an erc721 smart contract to testnet, it worked fine! Then i deployed it into the live network. It worked. But, i have an other script to mint my tokens. I used low gas price and the trasaction took couple of hours. but i found it on etherscan so it succed. Now i am using the command "truffle exec" with my mint-tokens.js script to mint tokens.
I GOT THIS ERROR:
"Error: FakinSurreal has not been deployed to detected network (network/artifact mismatch)
at Object.checkNetworkArtifactMatch (C:\Users\user\AppData\Roaming\nvm\v9.10.0\node_modules\truf
fle\build\webpack:\packages\contract\lib\utils\index.js:249:1)
at Function.deployed (C:\Users\user\AppData\Roaming\nvm\v9.10.0\node_modules\truffle\build\webpa
ck:\packages\contract\lib\contract\constructorMethods.js:84:1)
at
at process._tickCallback (internal/process/next_tick.js:118:7)"
[12:21 PM]
and when i use "truffle networks" i got this:
" Network: mainnet (id: 1)
No contracts deployed.
Network: rinkeby (id: 4)
FakinSurreal: 0x9321F5B07dBC329Ed55C1eb4b2eadA82f8e02E97
Migrations: 0xcd941BC06Eb1bC9bD83cCbF937fA606dD0956149"
[12:22 PM]
I have to deploy the contract again with higher gas fee, or its anyway of using my contract address (from etherscan) to interact with my token using truffle?
[12:22 PM]
Can i configure somewhere the address into the truffle to find my deployed Contract?
Thank you!


texts: Truffle delpoyment Error: unknown account

texts:
i am trying to deploy my smart contract on live network, i have successfully deployed the same contract on rinkeby but facing error
while on live network, here is the detail

1 - Account balance

  0.10000 ethers

2 - geth command

geth --rpc --rpcapi db,eth,net,web3,personal --unlock="0x1C11f6b1A2d1c0b00ad4145eb067184736EB973f"

3 - truffle js

"live": {
network_id: 1,
host: "127.0.0.1",
port: 8545, // Different than the default below
from: "0x1C11f6b1A2d1c0b00ad4145eb067184736EB973f",
gas: 4612388
}

4 - Error

truffle migrate --network liveUsing network 'live'.

Running migration: 1_initial_migration.js
Deploying Migrations...
... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: unknown account
at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/cli.bundled.js:43303:16)
at /usr/lib/node_modules/truffle/build/cli.bundled.js:331156:36
at /usr/lib/node_modules/truffle/build/cli.bundled.js:175492:11
at /usr/lib/node_modules/truffle/build/cli.bundled.js:314196:9
at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/cli.bundled.js:315621:13)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/cli.bundled.js:70159:18)
at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/cli.bundled.js:70449:12)
at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/cli.bundled.js:70604:12)
at IncomingMessage. (/usr/lib/node_modules/truffle/build/cli.bundled.js:70564:24)
at emitNone (events.js:91:20)

OS: Linux
Node: 6.2
npm: 3.10


texts: I think to better my understanding of the EVM and underlying file system, I want to read through one or more ethereum client implementations and potentially build a client myself. So far I've been slowly digging through the pyehtereum client since it's the easiest to read. But it is still quite challenging. I was wondering if there are any resources that walks through a client implementation?


texts: Using unix timestamp and making clients get token

texts: I'm trying to make a function that uses unix timestamp for setting a limited time and after the limited time is over I would like to make clients get their token by themselves Does anyone have any idea or help? Thanks!


texts: How to interact with my Rinkeby contract via truffle console?

texts:
I've been using truffle console to interact with a contract which I developed locally with Ganache.  I'd like to be able to call the contract's methods using the console once deployed to the Rinkeby network in the same way that I've been able to do so with Ganache.

I'm aware that I can do this using Remix but I'm wondering if I can do this using the terminal as well.  In other words, is there a config option for the console to interact with Rinkeby?


texts: giving users ETH addresses to deposit to

texts:
So I want to allow users to deposit ETH to their accounts in my website.
How could i go about giving a user an ETH address to deposit to that address and then detect it and add the funds to user's account? the same way that binance does if you are familiar with.

well i guess first i need a pool of ETH accounts with their private keys, which brings up the first question: how can i automatically generate bunch of eth accounts and export heir private key?

then i would allocate each user an ETH depositing address and would need to keep checking for a deposit in that ETH account, and that is the second question, which is how can i check for deposit/transactions in that address

any help or advice would be appreciated, i couldn't find any article or tutorial about it


texts:
I see the Parity option for "bombDefuseTransition" here, under chain spec:

https://github.com/paritytech/parity/wiki/Chain-specification

Two questions:

1 - Why is this needed?  (Would I be correct in saying that the difficulty bomb is coded into the software, therefore ANY test/dev net you use will have it, unless you use that flag?)

2 - How would one know what "block number at which the difficulty bomb (epsilon in Yellow Paper Eqs. 39, 44)" should be removed at?


texts:
I am working on private test-net and trying to send ether to contract but ether is not being transferred. I tried using both geth console and Mist.
eth.sendTransaction({from:eth.accounts[0], to: "0x2D13f7fbBA77EF39bd21d661bc77cd85ECA0C230", value: web3.toWei(15, "ether"), gas: 1000000})
On using debug.traceTransaction(txHash) , I am getting invalid jump destination (PUSH1) 2
undefined
Why can't I send ether to contract?


texts: Get return data from sendSignedTransaction

texts:
I need access to data returned by function that also changes state.

Example: I have a contract live on testnet with a function that creates and then returns a new ERC20 token.

contract MyContract {
  function createNewToken(string _name) payable returns (address newToken) {
    require(msg.value == 1 ether);
    tokenNames.push(_name);
    ERC20 newToken = new ERC20();
    return address(newToken);
  }
}

How do I get access to the returned newToken after calling contract.methods.createNewToken from web3. I'm guessing I need some kind of call alternative to sendSignedTransaction But I haven't found any.

My current approach:

const nonce = await web3.eth.getTransactionCount(PUB_KEY);
const data = myContract.methods.createNewToken(
    "exampleTokenName"
).encodeABI();
const pvtKey = new Buffer.from(PVT_KEY, 'hex');

const gasPrice = toHex(toWei("1", "gwei"));
const gasLimit = toHex((10 ** 6).toString());
const value = toWei("1", "ether");

const rawTx = {
    nonce: toHex(nonce),
    gasPrice,
    gasLimit,
    to,
    value: toHex(value),
    data
}

const tx = new Tx(rawTx);
tx.sign(pvtKey);

const serializedTx = tx.serialize();

web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', resolve) <---- Only returns the Receipt object no call data
.catch(reject);


texts:
This might be a silly question. if one is able to call JSON RPC API methods such as eth_sendTransaction directly using Postman or any web client, albeit a little troublesome, why use web3?

I have been using web3 js in my DApp. Asking this for understanding.

https://github.com/ethereum/wiki/wiki/JSON-RPC


texts: Risk of attack if you give more than the half of your tokens?

texts: I have read that you should own at least the half of your tokens in a DAO to avoid attacks. Is this true? Does it applies for crowdsales too? If so, crowdsale should be just giving less than the half of their tokens? What kind of attacks are probable when this happens?


texts:
I'm researching REST-Like API services for Ethereum in order to use it on our service. However, there are only a few services I could find. I'd very grateful if you could share the other services.

REST-Like API (I'm looking for these kind of services)

https://etherscan.io/apis

https://www.blockcypher.com/dev/ethereum/#introduction

https://www.etherest.io/

https://github.com/EverexIO/Ethplorer/wiki/ethplorer-api

JSON-RPC wrapper

https://www.myetherapi.com/

https://infura.io/docs/#calling-a-json-rpc-method

Memo

https://svelte-hn.now.sh/item/15019722


texts: i'm trying to set the web3.eth.defaultAccount with web3js 0.20.5. Somehow setting the default account like this.web3.eth.defaultAccount = this.web3.eth.accounts[0] does not work. Error message: this.provider.send is not a function. I'm able to obtain the address in this.web3.eth.accounts[0] though (web3js seems to be working in general).


texts:
I'm new in blockchain and ethereum, And I tried to transfer contract tokens and estimate needs gas(eth)
there was the error response when address ETH balance not enough
> eth.estimateGas({from:"0x717af978a95f60f61f6fd187001d9877fcac839b", to:"0x839419b3eec7d05d612f15106faea79e277fe790", data:"0xa9059cbb000000000000000000000000444bfbe8bc521557923fdeb217ab35d760b5cf100000000000000000000000000000000000000000000000008ac7230489e80000", gasPrice:1})
Error: gas required exceeds allowance (0)
    at web3.js:6347:37(47)
    at web3.js:5081:62(37)
    at <eval>:1:16(12)

Is't possible to ignore this balance check and get "estimateGas" anyway?


texts:
I wonder how to get some ether for development testing.

https://faucet.rinkeby.io is not working - even after I tweeted my account id and gave the twitter url. It kept saying couldn't find ethereum url or something.

https://app.mycrypto.com/faucet keeps returning "Our faucet is currently running low on this network. Please try again later."

Now, I'm even thinking of getting some ether for money but for $1 or so. Where can I get ether ?
I am using MetaMask.


texts:
Follow the procedures on this page brownie : create new project and compile with brownie. Encounter the following error, please comment how to fix it.

Configuration and environment.

Python 3.7.7
ganache-cli 6.14.5

(.token-venv) MacBookPro:token nelson$ brownie compile
  Brownie v1.9.2 - Python development framework for Ethereum
  .....

  [ 60%] Linking CXX executable solc
  File "brownie/_cli/__main__.py", line 58, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 37, in main
    project.load()
  File "brownie/project/main.py", line 656, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 160, in __init__
    self.load()
  File "brownie/project/main.py", line 213, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 96, in _compile
    optimizer=compiler_config["solc"].get("optimizer", None),
  File "brownie/project/compiler/__init__.py", line 97, in compile_and_format
    find_solc_versions(solc_sources, install_needed=True, silent=silent)
  File "brownie/project/compiler/solidity.py", line 158, in find_solc_versions
    install_solc(*to_install)
  File "brownie/project/compiler/solidity.py", line 90, in install_solc
    solcx.install_solc(str(version), show_progress=True)
  File "solcx/install.py", line 229, in install_solc
    _install_solc_osx(version, allow_osx, show_progress, solcx_binary_path)
  File "solcx/install.py", line 374, in _install_solc_osx
    "".format(cmd[0], e.returncode)
OSError: make returned non-zero exit status 2 while attempting to build solc from the source.
This is likely due to a missing or incorrect version of a build dependency.

For suggested installation options: https://github.com/iamdefinitelyahuman/py-solc-x/wiki/Installing-Solidity-on-OSX


texts: interface function declarations to be used internally

texts: Is it possible to use externally declared interface functions internally in a smart contract?  i.e. say contract A inherits interface A, would contract A be able to implement the functions from interface A in an internal fashion (declaring a function as internal) not allowing the public to call it?


texts: Is there any version of AAVE protocol deployed on polygon/matic testnet?

texts:
As AAVE documentation suggests, there is a deployed version of the protocol on matic/polygon mainnet. However, it does not make any mention of those smart contracts on Mumbai testnet which I need to test my DAPP before publishing it on the matic mainnet.
Does anybody know about its availability as well as contract, token and aToken addresses?


texts: ParserError: Expected token Semicolon got Lparen

texts:
This is my code (I use Remix ethereum):

emit Transfer(_initialOwner, _initialOwner, _initialAmount);

How can I fix it?


texts: Difference between creating contract with and without using new

texts:
Hi can anyone tell me the differnece between creating contract using a new operator and creating contract by passing the address.

Example:

contract A{
    uint256 public num = 10;
    function get() returns(uint){
        return num;
    }
}

contract B{
    function get() returns(uint){
        A a = new A();
        a.get();
    }
}

and

contract B{
    function get(address add) returns(uint){
        A a = A(add);
        a.get();
    }
}


texts:
I have a contract that looks like this:
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract SwappableToken is ERC20 {
  constructor(string memory name, string memory symbol, uint initialSupply) public ERC20(name, symbol) {
        _mint(msg.sender, initialSupply);
  }
  function _approve(address owner, address spender, uint256 amount) public override {
        super._approve(owner, spender, amount);
    }
}

However, when doing this I get:
TypeError: Overriding function visibility differs.
The _approve method has visibility of internal but I'd like to make it public (Why? Well for testing crazy stuff is all. Yes I know that's a terrible idea for production)
Is it not possible to override the visibility of a function from the base contract?
How would I make an ERC20 where anyone can call the approve function for any owner and sender without rewriting the whole contract?


texts: How to retrieve wallet's creation date via API of etherchain.org?

texts:
I've been searching for a way to retrieve wallet creation date and didn't found any good approaches so far.

What I've found is parsing First seen field (left-bottom corner) from etherchain.org site.

I realize that this is not exactly what I'm looking for but at least something that nothing.

Does etherchain.org provide respective API for retrieving this value by issuing HTTP request or maybe you know better places where I can retrieve this data?


texts: Is it possible for an older version of jaxx wallet to give me a word for my backup phrase that isn't on MEW word list? They refuse to give me the list they use. Just refer me to the MEW one and then say that they use it as well. But I didn't write down pirate for no reason four times in a row. Smells fishy


texts: How can I call an external API (only to push data) in a smart contract?

texts:
I read that there are solutions like http://www.oraclize.it/ to bring external data into a smart contract.

Is there a simpler way if I only want to notify an external service (no need to bring in external data) when a method in a contract has been called?


texts:
I'm following Medium tutorial and is stuck on the step where contract should be deployed. I did everything like described in the tutorial but when I run truffle migrate it displays

Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x1724c314275c3449e202592c37b57eb670cec5a1fe3bff53fab36ec2f094b19f

then hangs for about 10-20 minutes and then displays

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Contract transaction couldn't be found after 50 blocks

I'm using geth, running node locally which is synced, have about 4 ether on my test account.
As far as I understand message says that contract is not found on blockchain which makes sense: when I look up transaction with id 0x1724c314275c3449e202592c37b57eb670cec5a1fe3bff53fab36ec2f094b19f (one that is printed in console) etherscan says state is "pending". It stays in this state for 30 minutes or so and then disappears completely.

I've tried to increase the "gasPrice" to 200 Wei but that didn't help

What could be the reason of this?

Update

If you are having the same problem while going through the tutorial see my comment to resolve the issue by using "rinkeby" network.


texts: How can we get other transactions result like using window.web3.eth.getTransactionReceipt on our own transaction?

texts:
If I send a transaction, I can watch the result using window.web3.eth.getTransactionReceipt like this:

tradeContract.methods.test(...args).send({
  from: pubData.user.address,
  gas: gasAmount
})
  .then(res => {
    let txId = res.transactionHash
    let isSuccess
    window.web3.eth.getTransactionReceipt(txId).then(transReceipt => {
      if (transReceipt) {
        isSuccess = transReceipt.status === '0x1'
        if (isSuccess) {
         // do something if transactions success
        } else {
       // do something if transactions fail
        }
      }
    })
  })

However, if I listen to the Transfer event of the contract

listenContract.events.Transfer({}, (er, data) => {
  let txId = data.transactionHash
  window.web3.eth.getTransactionReceipt(txId).then(transReceipt => {
    // always return null because the transaction is pending
    console.log('transReceipt', transReceipt)
  })
})

transReceipt is always null because the transaction is pending. So, in this case, do we have to poll until the transaction finish? Does web3.js has some API can do it like the code on top? I didn't find it. I do find a lot of poll solution like:

Get Transaction Hash And Mined Receipt


texts: As of June 11, 2018, the price of 1 ether is about $520 (from https://www.coindesk.com/ethereum-price/). From https://ethgasstation.info/, the average price of 1 gas is 2 Gwei (1 Gwei=10^9 wei) which implies that the average price is 2 times the square root of $520 (about $46). It seems to be very high (an addition operation costs 1 gas). Is there a mistake in the calculations?


texts: Who pays for the storage on smart contracts?

texts:
Here is a smart contract from the official tutorial

contract MyToken {
    /* This creates an array with all balances */
    mapping (address => uint256) public balanceOf;

    /* Initializes contract with initial supply tokens to the creator of the contract */
    function MyToken(
        uint256 initialSupply
        ) {
        balanceOf[msg.sender] = initialSupply;              // Give the creator all initial tokens
    }

    /* Send coins */
    function transfer(address _to, uint256 _value) {
        require(balanceOf[msg.sender] >= _value);           // Check if the sender has enough
        require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
        balanceOf[msg.sender] -= _value;                    // Subtract from the sender
        balanceOf[_to] += _value;                           // Add the same to the recipient
    }
}

This has a mapping. It is impossible to tell in advance how many entries are going to be added to this mapping.

How is the miner compensated for the amount of storage used by this contract?


texts: Difficulties calculating mined ETH per month

texts:
I am trying to replicate calculator for ethereum mining available at

https://www.cryptocompare.com/mining/calculator/eth

So far I got to following formula

Seconds in 1 month / (Total Hash Power MH/s / My Hash Power MH/s * Block Time s) So in my case with following parameters:

Seconds per month: 2592000

Total Hash power MH/s: 30728202.35

My hash power MH/s: 74.525

Block Time s: 15

I get 0.4190912262 as a result opposed to 2.10 value from online calculator mentioned above. I'm not entirely sure where my formula is wrong i.e. I calculate seconds needed to mine 1 block and then divide whole month by these seconds to find out how many blocks I can mine.

For simplicity assume all other costs like electricity etc.. are 0


texts: Creating ERC20 or ERC721 in Optimistic Rollup

texts: If there's a dapp running in optimistic rollup that lets users mint new ERC20 and ERC721 tokens. How can ETH main chain know about the new minted tokens?


texts: Truffle - Migrate Contract to a private network in Azure

texts:
I try to migrate a Smart Contract to a private network running in Azure. It works fine with testrpc but when I try to migrate it to the (remote) private network I always get the following error:

Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (C:\Users\xxx\AppData\Roaming\npm\node_modules\truffle\node_modules\web3\lib\web3\errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (C:\Users\xxx\AppData\Roaming\npm\node_modules\truffle\node_modules\web3\lib\web3\httpprovider.js:116:32)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\xxx\AppData\Roaming\npm\node_modules\truffle\node_modules\xhr2\lib\xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (C:\Users\xxx\AppData\Roaming\npm\node_modules\truffle\node_modules\xhr2\lib\xhr2.js:354:12)
    at XMLHttpRequest._onHttpRequestError (C:\Users\xxx\AppData\Roaming\npm\node_modules\truffle\node_modules\xhr2\lib\xhr2.js:544:12)
    at ClientRequest.<anonymous> (C:\Users\xxx\AppData\Roaming\npm\node_modules\truffle\node_modules\xhr2\lib\xhr2.js:414:24)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1278:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

What I did so far was creating and compiling the contract and modifying truffle.js to

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

When I run migrate --network azure in the truffle console the error occurs.

Does someone know how to do it correctly? Respectively why the error occurs?

Thanks


texts: How to resolve this error in solidity “The constructor should be payable if you send value.”?

texts:
In this solidity code the finalizeRequest() is giving a run-time error. Here is the error :

Campaign.finalizeRequest(uint256) 0x692...77b3a

transact to Campaign.finalizeRequest errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Note: The constructor should be payable if you send value.  Debug the transaction to get more information.

Here is the code:

pragma solidity ^0.5.14;

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

    address public manager;
    uint public minimumContribution;
    // address[] public approvers;
    mapping (address => bool) public approvers;
    Request[] public requests;
    uint public approversCount;

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

    function contribute() public payable {
        require(msg.value>minimumContribution);
        // approvers.push(msg.sender);
        approvers[msg.sender]=true;
        approversCount++;
    }

    function createRequest(string memory description,uint value,address payable recipient) public restricted {
        // require (approvers[msg.sender]);
        Request memory newRequest=Request({description:description,value:value,recipient:recipient,complete:false,approvalCount:0});
        requests.push(newRequest);

    }

    function approveRequest(uint index) public {
        Request storage request=requests[index];

        require(approvers[msg.sender]);
        require(!request.approvals[msg.sender]);
        request.approvals[msg.sender]=true;
        request.approvalCount++;
    }

    function finalizeRequest(uint index) public restricted payable{
        Request storage request = requests[index];

        require(request.approvalCount>=(approversCount/2));
        require(!request.complete);
        request.recipient.transfer(request.value);
        request.complete=true;

    }

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

As far as I could debug, when I comment out request.recipient.transfer(request.value); in the finalizeRequest() function no runtime error is thrown. So error seems to be in this line of code ,kindly help resolving this.


texts: error when getting TransactionReceipt from parity node with ethereum-go

texts:
In my golang oracle, I need to get the TransactionReceipt for my transaction.

To do so I call client.TransactionReceipt(context.TODO(), txHash)

This yields a transaction receipt when the node is geth but fails when the node is parity. The error message is json: cannot unmarshal non-string into Go struct field Receipt.root of type hexutil.Bytes

I'm guessing this has something to do with the JSON returned by the nodes but I can't see any errors.

The JSON returned by GETH is:

{
  blockHash: "0x88ed2d126dc004b56309da73a897dee7601a03fa6aa4133f8b942646fe71b995",
  blockNumber: 1,
  contractAddress: null,
  cumulativeGasUsed: 21000,
  gasUsed: 21000,
  logs: [],
  transactionHash: "0x182eb16fa75d58e16b2ac13ba3697ad00a2a961f2d7cbb6c15e3c17fd262c267",
  transactionIndex: 0
}

and the one returned by Parity is:

{
  blockHash: "0x28f5afbde2ffe91f409f91b27ebe75d963326bfa79e72f29492692d06f48427a",
  blockNumber: 643,
  contractAddress: null,
  cumulativeGasUsed: 21000,
  gasUsed: 21000,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  root: null,
  status: null,
  transactionHash: "0xe7cf7d79c52fdec083706b51dca3aa3374b00a3d8276708e632387f8b1cdbfc1",
  transactionIndex: 0
}

The only difference I can see are the 2 additional fields root and status but these exist in the type declaration of the receipt:

type Receipt struct {
    // Consensus fields
    PostState         []byte   `json:"root"`
    Status            uint     `json:"status"`
    CumulativeGasUsed *big.Int `json:"cumulativeGasUsed" gencodec:"required"`
    Bloom             Bloom    `json:"logsBloom"         gencodec:"required"`
    Logs              []*Log   `json:"logs"              gencodec:"required"`

    // Implementation fields (don't reorder!)
    TxHash          common.Hash    `json:"transactionHash" gencodec:"required"`
    ContractAddress common.Address `json:"contractAddress"`
    GasUsed         *big.Int       `json:"gasUsed" gencodec:"required"`
}


texts: Handling require/assert failure errors correctly from a Node.JS app?

texts:
I have a getter function in my smart contract that returns one of the string values in statically defined string array.  Upon entry to the function, it does a bounds check on the incoming index using require().  If the bounds check fails, what will happen in my Node.JS app that used Web3.js to make the call?  Will a Javascript error be thrown?  Will I get NULL back?

If anyone has a good article or web resource that shows the proper way to handle errors from a Web3.JS call that resulted in an assert or require operation being triggered on the smart contract side, please share.

Here is my smart contract code:

pragma solidity ^0.4.23;

import "github.com/OpenZeppelin/zeppelin-solidity/contracts/ownership/Ownable.sol";

contract VideoDummyData is Ownable{

    // Constructor, MUST be public.
    constructor() public {
        // Unused.
    }

    // Array of sample video IDs.
    string[3] m_aryVideoIds =
        ["ZUSPD9zOyJs", "4nqJiBRNQuw", "PLcxE4UkJt0"];

    // Return one of the sample video IDs.
    function getVideoIdAt (uint ndx) public view returns(string)
    {
        // Bounds check on the desired index.
        require(ndx < m_aryVideoIds.length);

        return m_aryVideoIds[ndx];
    }
}


texts: How to design a smart contract that allows people to trade NFTs

texts:
Instead of smart contracts that people deposit ETH into as offers to buy NFTs (ETH for NFT), how can a smart contract be designed so that two counterparties can deposit NFTs into the smart contract in a direct NFT for NFT trade?

Trader 1 would require the specific NFT #030 from SuperRare to be
deposited in the smart contract
Trader 2 would expect NFT #052 from Rarible to be deposited in the smart contract
Once these conditions are met, the NFTs are swapped owners

Does a platform exist that supports this sort of NFT for NFT trade. if not, how to go about designing this smart contract, which language, things to consider, etc..


texts: Plasma: how were the UTXO bitmaps conceptualised and how will they be stored?

texts:
From the white paper, page 5:

  We construct an interactive game whereby the exiting party attests to
  a bitmap of participants’ ledger outputs arranged in an UTXO model
  which requests a withdrawal.

Are these bitmaps matrixes of bits, just like in images? Or key-value pairs? Then, given the underlying economic incentives of Plasma, who stores them and how? Is there a model similar to Bitcon's UTXO storage, i.e. $DATADIR/chainstate?


texts: Can't connect to geth JSON RPC from React Native Expo

texts:
I am using the ethers library on npm to connect. My code for testing the connection is as follows
  let result = await ethers.utils._fetchData(
    {
      url: "https://MY_URL",
      headers: { "content-type": "application/json" },
    },
    ethers.utils.toUtf8Bytes(
      '{ "id": 42, "jsonrpc": "2.0", "method": "eth_chainId", "params": [ ] }'
    )
  );
  console.log(result);
  console.log("Text", ethers.utils.toUtf8String(result));

Both results come back as empty though.


texts: Transfer between ETH and MyToken source code

texts:
I want to build a functionality that allows following:
1) Transfer between ETH and MyToken for same address.
2) Transfer between ETH and MyToken between two different addresses.

Since solidity does not allow changing balance of my "ETH" account, I will need to write some part of code in web3js and some part is smart contract.
Is that correct?
What will be the right design for this?

Please note that at present I'm writing this in my Private Net for demo purpose only.


texts: Is My Etherum Wallet Synching with the Blockchain?

texts:
I just downloaded geth and started running the geth --rpc command. Is everything working and normal?

  peer=5e56002f0252fe80 number=1701275 hash=6fe05e…979f0a WARN
  [05-16|15:29:09] Header broke chain ancestry
  peer=5e56002f0252fe80 number=1701657 hash=4b1ecb…519ee6 WARN
  [05-16|15:29:10] Header broke chain ancestry
  peer=5e56002f0252fe80 number=1702403 hash=359304…d535fb WARN
  [05-16|15:29:11] Header broke chain ancestry
  peer=5e56002f0252fe80 number=1703158 hash=a8edf8…099703 WARN
  [05-16|15:29:12] Header broke chain ancestry
  peer=5e56002f0252fe80 number=1703561 hash=8b738c…823f53 WARN
  [05-16|15:29:13] Header broke chain ancestry
  peer=5e56002f0252fe80 number=1704121 hash=409083…b041d7 WARN
  [05-16|15:29:13] Header broke chain ancestry
  peer=5e56002f0252fe80 number=1704509 hash=ba83bc…6c6ca0

Got this also

  WARN [05-16|15:37:57] Synchronisation failed, retrying
  err="receipt download canceled (requested)" INFO [05-16|15:38:01]
  Imported new block headers               count=0    elapsed=2.979ms
  number=1914414 hash=0f3c0d…075354 ignored=192 INFO [05-16|15:38:01]
  Imported new block receipts              count=0    elapsed=0s
  number=1914235 hash=4a964a…5a322a ignored=13 INFO [05-16|15:38:01]
  Imported new block headers               count=0    elapsed=1.978ms
  number=1914606 hash=4ff356…074458 ignored=192

I'm a total noob is everything working?


texts: Scam input token cannot be transferred on Uniswap

texts:
I've been seeing this pop up quite a bit recently. Scammer creates a ERC token with the name of something popular - Shiba or Kishu. Adds alot of liquidity to the pool but once you buy the token you cannot swap it back for any other token. Eventually they drain the liquidity pool and repeat.
You receive the error: "The input token cannot be transferred. There may be an issue with the input token."
Is there any solution to this for those that have been affected before the pool is drained?
Thanks


texts: Does a transaction that consumes the block gas limit take an entire block by itself?

texts:
Does a transaction that requires the entire block gas limit to be executed (currently ~8M) take the entire block by itself?

And if that's true, will that transaction take longer to get confirmed than say a regular transfer transaction? (given they're both sent with the same gas price)


texts: Price calculated by the reserves is different than on the exchange

texts:
If i look at the pancake ADA BNB swap pair: https://bscscan.com/address/0xBA51D1AB95756ca4eaB8737eCD450cd8F05384cF#readContract, and I check the reserves. Normally the 2nd reserves divided by the 1st reserves defines the price, being: 2108534785760605257816 / 981370391524232518116195, which is 0.002148562. So the price for 1 BNB = 0.002148562
But then if I check the price on pancakeswap it's higher. I can't seem to figure out why that is


texts:
I want to know if my syntax is correct not how to catch a revert.

the task is: Call bid method from accounts[1] of Auction.sol using auctionInstance and pass itemId=0, count=6 as arguments

 it("Should NOT allow to bid more than remaining tokens", function() {
return auctionInstance.bid(itemId[0],count[6],{from:account[1]})
.then(function (result) {
  /*
  We are testing for a negative condition and hence this particular block will not have executed if our test case was correct. If this part is executed then we throw an error and catch the error to assert false
  */
  revert("Failed to check remaining tokens less than count");
}).catch(function (e) {
  var a = e.toString();
  if(e === "Failed to check remaining tokens less than count") {
  assert(false);
  } else {
    assert(true);
  }
})

The project code looks like this I had to complete it that is the code at the top.

   //Test Case for checking if the bid is more than the token amount
  it("Should NOT allow to bid more than remaining tokens", function() {
    /**********
    TASK 1:   Call bid method from accounts[1] of Auction.sol using auctionInstance and
    pass itemId=0, count=6 as arguments
    HINT:     To make a function call from account 1 use {from: accounts[1]} as an extra argument
    ***********/
    return //
    .then(function (result) {
      /*
      We are testing for a negative condition and hence this particular block will not have executed if our test case was correct. If this part is executed then we throw an error and catch the error to assert false
      */
      throw("Failed to check remaining tokens less than count");
    }).catch(function (e) {
      var a = e.toString();
      if(e === "Failed to check remaining tokens less than count") {
        /**********
        TASK 2: This is the error which we had thrown. Should you assert true or false?
        HINT:   Use assert(false) to assert false
                Use assert(true) to assert true
        ***********/
        //
      } else {
        /**********
        TASK 3: assert the opposite here
        ***********/
        //
      }
    })
  });


texts: web3 smart contract calls to slow (arrays / lists)

texts:
I call contract like this :

  static async getInitialProps(res) {

    const users = await UsersContract.methods.getUsers().call();
    const totalusers = await UsersContract.methods.getTotalUsers().call();
    var i;
    const emails = [];
    const usersETHaddr = [];

    for (i = 0; i < totalusers; i++) {

     emails.push(await UsersContract.methods.getUserEmail(i).call());
     usersETHaddr.push(await UsersContract.methods.getUserETH(i).call());

    }

    return { emails,usersETH};

  }

When i have 10-15 users inside the array it loads ok
But when i have 20-30 users it takes around 3 minutes to load

I use infura not geth

So why does it load slower when i add more users to the array ?


texts: Is there anyway to broadcast transaction to all peers changing handler? I want to optimize and broadcast to all connected peers


texts:
I have read everywhere that exposing personal over rpc is dangerous and is vulnerable. The question is HOW? Is it possible for anyone to send transactions to my geth console, if my ipaddress and port on which geth is listening is compromised?
Secondly, I don't understand if it's a security threat, how are some coins based on Ethereum are able to provide their own wallet? They must be using RPC api to connect to geth. Isn't their coin at risk?
I am also building a web interface for my coin using web3.js so that users of my coin could use web to access their accounts and carry out transactions but for that I need to expose personal over RPC. Am I compromising security? If yes, what else I can do to provide web access to my users of their accounts.
Can -rpcaddr and -rpccorsdomain help in any way? I couldn't understand their use properly. If I set --rpcaddr "ip1", "ip2" --rpccorsdomain "ip1", What does this means?


texts: How to generate Data payload for a smart contract transaction programmatically?

texts: Some wallets, like Gnosis Safe multisig, do not have web3.js support or ABI encoder built-in. How one can create a transaction that calls a smart contract function and originates from such wallets?


texts: Gas required exceeds allowance when deploying a contract

texts:
I try to deploy a contract using truffle to my private ethereum network using geth and i get this error  gas required exceeds allowance (6721975) or always failing transaction. I have create an account and i have mined with this. I also have connected it with metamask. What i have to do to solve it?

genesis.json

{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000042",
"mixhash":
"0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x200",
"alloc": {},
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash":
"0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xffffffff",
"alloc": {
}
}

contract

pragma solidity 0.5.8;

contract Creation {
    // Model a Candidate
    struct Candidate {
        uint id;
        string name;
        uint voteCount;
    }

    // Store accounts that have voted
    mapping(address => bool) public voters;
    // Store Candidates
    // Fetch Candidate
    mapping(uint => Candidate) public candidates;
    // Store Candidates Count
    uint public candidatesCount;

    // voted event
    event votedEvent (
        uint indexed _candidateId
    );

    constructor () public {
        addCandidate("Candidate 1");
        addCandidate("Candidate 2");
    }

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

    function vote (uint _candidateId) public {
        // require that they haven't voted before
        require(!voters[msg.sender]);

        // require a valid candidate
        require(_candidateId > 0 && _candidateId <= candidatesCount);

        // record that voter has voted
        voters[msg.sender] = true;

        // update candidate vote Count
        candidates[_candidateId].voteCount ++;

        // trigger voted event
        emit votedEvent(_candidateId);
    }
}


texts:
I have created a contract with functions...the get() is used for storing and getarray is for returning values...

struct arrayy{
    uint256[] arrayvalue;
}
mapping(address => arrayy) arraymapping;

event logg(
    uint256 z,
    address sender
);

function get(uint256 y, address _owner) internal{
   arraymapping[_owner].arrayvalue.push(y);
   emit logg(y,_owner);
}

function getarray(address _owner) internal returns(uint256[]){

    return(arraymapping[_owner].arrayvalue);
}

Then I deployed the contract, and tried to call the get() function by using...

DeployedContractAddress.call(bytes4(keccak256("get(uint256,address)")),1234,0xfffff);

The value is stored because, When I tried to call the getarray() function the value is returned...

But the emit() is not working...

Why this emit() is not working? Help me to resolve this issue? Help will be appreciated...


texts: Why is my rinkeby balance is 0 after syncing even though transaction shows ether was sent

texts:
Could you please help me to find out what I’m doing wrong.
I’ve topped up my test accounts from https://faucet.rinkeby.io/. When I check their balances on https://rinkeby.etherscan.io/balancecheck-tool,  I can see that both of them have 3 ethers each. The accounts are: ‘0x402596a354411c73a3fe8e99ba1e7226fe88361c’ and ‘0x6403e1c470f3bb7f0f1bd23756624e0293f98079’.

But when I open a connection with Rinkeby test network using this command: geth --rinkeby --rpc --rpcapi="personal, eth, network, web3, net" --ipcpath "~/Library/Ethereum/geth.ipc" (I left my computer for night to get all the updates from Rinkeby) and on the other tab open Geth console (geth attach) and run eth.syncing I see that my local network is updated. But when I run eth.getBalance(eth.accounts[1]) or eth.getBalance(eth.accounts[2]) to see the balances of my funded accounts I see 0.

What am I doing wrong? Could you please help me overcoming this issue? I will be so grateful to you! This problem is driving me insane...


texts: Geth not synchronizing - Firewall issue?

texts:
I am trying to sync an ethereum node on my computer, which is connected to a university network.

However it seems that geth is not finding any peers, same thing with mist. It looks to me like the port used by geth to synchronize (30303 from what I understood) the node is blocked.

Is there any way I could use a different port ?

Update:

I found a way to change the port, and even enable upnp, from the geth command-line documentation :

--port value          Network listening port (default: 30303)
--nat value           NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")

However, synchronization still does not start. Here is what I get when running the geth --fast --cache=4096 --port=10350 --nat=upnp command :

I0320 12:09:23.150087 p2p/server.go:608] Listening on [::]:10350
I0320 12:09:23.152087 node/node.go:341] IPC endpoint opened: \\.\pipe\geth.ipc

And it stays stuck here...


texts: How do you restore a wallet in Mist on OSX from a Windows backup?

texts:
In Mist on Windows I went to Accounts -> Backup -> Application Data, and backed up the Mist folder it pointed to. I assume this is backing up my wallet contracts, since Accounts -> Backup -> Accounts doesn't seem to?

I'm also running Mist on OSX, how can I transfer my wallet contracts there?


texts: windows geth "path not updated" problem during installation

texts:
When I try to install geth to my Windows 10 pc, I have faced two problem.

first, Although my computer has intel cpu, geth Windows executable is for amd architecture. I could not find any executable for intel. The name of the exectable is: geth-windows-amd64-1.6.7-ab5646c5.exe

Second, I have tried to install geth with the previous executable, but it shows below given warning. Afterward, altough it seems installation completed successfully. geth command could not be found when I type on cmd. You can find related screenshots below.


texts: Should we patent Dapps with new technology or processes?

texts:
I understand in the decentralized space patenting anything is generally frowned upon.  Having said that, doesn't this expose Dapp developers to patent trolls, such as the Bank of America, from patenting open-source technology and then requesting royalty from every for-profit entity developing Dapps?
From a legal resources perspective, banks or trolls may have a lot more resources to sue and see a legal battle through.  Wouldn't it be advantageous to patent our discoveries and processes?
Source: http://www.coindesk.com/bank-of-america-patents/
Please note the following difference between patent, copyright and trademark:

What Is a Copyright?
Copyright is a form of protection provided to the authors of "original works of authorship" including literary, dramatic, musical, artistic, and certain other intellectual works, both published and unpublished.
What Is a Patent?
A patent for an invention is the grant of a property right to the inventor, issued by the Patent and Trademark Office. The term of a new patent is 20 years from the date on which the application for the patent was filed in the United States or, in special cases, from the date an earlier related application was filed, subject to the payment of maintenance fees. US patent grants are effective only within the US, US territories, and US possessions.
What Is a Trademark or Servicemark?
A trademark is a word, name, symbol or device which is used in trade with goods to indicate the source of the goods and to distinguish them from the goods of others.

My question is specific to patents.


texts:
Using Truffle, I'm trying to implement my first smart contract by running the MetaCoin webpack.  After running Truffle Develop, I can see my list of accounts:

Truffle Develop started at http://127.0.0.1:9545/

Accounts:
(0) 0xb2d5b74e4f22f3b7006fb5e77f3940982fe1a316
etc.

In my truffle.js file, I'm using:

    module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  networks: {
    development: {
      host: "localhost",
      port: 9545,
      network_id: "*" // Match any network id
    }
  }
};

I then use:

  import Web3 from "web3";
  import metaCoinArtifact from "../../build/contracts/MetaCoin.json";

  const App = {
  web3: null,
  account: null,
  meta: null,

  start: async function() {
    const { web3 } = this;

    try {
      // get contract instance
      const networkId = await web3.eth.net.getId();
      const deployedNetwork = metaCoinArtifact.networks[networkId];
      this.meta = new web3.eth.Contract(
        metaCoinArtifact.abi,
        deployedNetwork.address,
      );

      // get accounts
      const accounts = await web3.eth.getAccounts();
      this.account = accounts[0];

      this.refreshBalance();
    } catch (error) {
      console.error("Could not connect to contract or chain.");
    }
    },  //more code below

However, when I then run my app through the browser via npm run dev, my console is returning:

Could not connect to contract or chain.

What step am I missing to have my app talk to my local blockchain?


texts: Detecting nodes by an identity in Ethereum network?

texts:
According to this answer: (https://bitcoin.stackexchange.com/a/63657/41513) the following can be definition of a node:

  "A node is a computer that has a copy of the blockchain (or at least a
  part of it), and broadcasts and receives transactions and blocks from
  other nodes."

If we assume this definition is correct, then is there any approach to detect the nodes? For example, how to detect a node is node-i and another node is node-j? Is there an approach to detect those nodes by an identity?

Is "fingerprinting a node" can be considered as a solution to identify a node? (https://www.npmjs.com/package/node-fingerprint) or (https://pdfs.semanticscholar.org/d5ef/30919b4f28b82d6fb637e17a5a992f82ecaa.pdf)


texts: How can my Ethereum node accept remote connections?

texts:
I need to use Web3 on some Python and Javascript applications i'm creating, so i decided to setup a light node on a VPS. The node seems to work, but i'm having troubles accessing it from outside the vps. I'm making sure to serve the RPC API and i tried everything, but i still can use web3 from inside the vps.
w3 = Web3(Web3.HTTPProvider('http://<MY-IP>:8545'))
print(w3.isConnected())

Gives False.
Instead, if i try to do the same from my local VPS where the node is hosted i get True.
Here is how i'm starting the node:
geth --syncmode "light" --rpc --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,web3"

I know that it's not a good practice to make the node available to any remote connection, but i'm not storing private keys or balances, i just want to use it to get blokchain data from web3 and i'll see if there is a way to make it accept only specific IPs. How can i make it accept remote connections?
Can the problem be that port 8545 is refusing remote connections? Or is it something else?


texts: How to test a contract on Truffle with multiple nodes?

texts:
I am a Truffle user. I would like to create one contract and test this. When testing, I'd like to setup three nodes, link them, access the contract and test it. Is this possible? Or am I doing strange things?
Please tell me if possible.

node1 rpcport:8101,
node2 rpcport:8102,
node3 rpcport:8103,

I set up. I used admin.addPeer command, link them.

Next, to deploy that contract on node1, I did truffle migrate command.

Next, to build a app I created with Truffle on node1, I did truffle build command.

And, I would like to build the app on node2, node3, then I would like to access the same contract. ← How do I do?


texts:
I have followed all the steps to mine Ethereum and I am currently mining, but where does what I have mined go?

Is it through the address that I was given through Geth?

How do access the mined Ethereum?


texts:
I have been using arrays of struct for my contract. In Remix IDE with the private network, one function costs me around 300,000 gas. However, if I call the same function from web3js, it costs me a lot and sometimes the cost exceeds block gas limit which was set to 9,999,999.

Could you please let me know if array costs more gas than mapping does?


texts: How can I instantiate an array of addresses?

texts:
I simply want to create an array with stuff in it. Everything I try is an error message in mist. Even this code snippet I got straight from the docs wont compile:

contract C {
    uint someVariable;
    uint[] data;
    function f() {
        uint[] x = data;
        x.push(2);
    }
}

I simply want to do something that would be analogous to this ruby:

arr = ['0x36eaf79c12e96a3dc6f53426c', '0xf235aa56dd96bda02acfb361e']

I dont need the size to be dynamic, and the type is address.


texts: Deployed contract working in Remix but not working from Browser Console

texts:
I am stuck with this problem for a long time. Please help me ........
I deployed contract from Remix and its is working fine, But getting Invalid argument error in console after running this file in browser. And getting empty array while calling method to read stored value via .call()
Contract deployed on rinkeby testnet on address "0xB1131a52f23740444577cBfCa11A8F2b90e5CEd3" (Rinkeby testnet)
Console Output:
Default Account: 0xD3B2f24f27Eb75b941084Ef56065F51b9589dba6 index.html:69
 Deployed Contract Address: 0xB1131a52f23740444577cBfCa11A8F2b90e5CEd3 index.html:77

//this is for .send() function
  invalid tuple value (argument="tuple", value="123", code=INVALID_ARGUMENT, version=abi/5.0.0-beta.153) index.html:80

//this returned for .call() function*
 []length: 0__proto__: Array(0)

Solidity code:
pragma solidity >=0.4.22 <=0.8.0;

/**
 * @title Storage
 * @dev Store & retrieve value in a variable
 */

contract Storage {

    uint256 public number;

    constructor(uint256 num) public{
        number = num;
    }

    /**
     * @dev Store value in variable
     * @param num value to store
     */
    function store(uint256 num) public {
        number = num;
    }

    /**
     * @dev Return value
     * @return value of 'number'
     */
    function retrieve() public view returns (uint256) {
        return number;
    }

}

HTML file:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

Welcome to Storage

  <input type="text" name="" id="storage">

Value of the storage is 0

    <button id="get">Get Storage</button>
    <button id="set">Update Storage</button>


texts:
I am trying to get balance of my account on test ropsten network but currently i am confused a bit . I have synchronised geth server on ropsten network and have sent from my other wallet to wallet that i have created in geth using mist wallet. My wallet there is:

https://ropsten.etherscan.io/address/0xa340ac939b0ab504a9a0bcef337ff0f8172a910e

And I have sent to it 1 rETH from 0x68f4d98bbcc1e11351edfaf7de7782cf3f44c9bc account.

I was block 3396592 and I am shure that my eth have already synchronized this information .

> web3.eth.getBlock(3396592)
  // .... shows me block information with
  transactions: [ .... "0x012d98ddcd6073b9fbcda88867ba9e44a99698d047d00ddfe48d9078107e4604" ... ]
  ...

And even more i can see this transaction :

  web3.eth.getTransaction("0x012d98ddcd6073b9fbcda88867ba9e44a99698d047d00ddfe48d9078107e4604")
  {
    blockHash: "0xb806fa78a958ede78e32c23f8d9a6ba09735be401586a51da3bba72db0bdecb5",
    blockNumber: 3396592,
    from: "0x68f4d98bbcc1e11351edfaf7de7782cf3f44c9bc",
    gas: 21000,
    gasPrice: 1000000000,
    hash: "0x012d98ddcd6073b9fbcda88867ba9e44a99698d047d00ddfe48d9078107e4604",
    input: "0x",
    nonce: 0,
    r: "0xbd6d4d51c42d7e87c0aec8fa4fade9320a84c98f6a5ecd87e44bef7d5151c8ae",
    s: "0x75273a8e3b4d8d2c93a7c89d4b93934cb08ec775567b578014a3d4fd33ed43d1",
    to: "0xa340ac939b0ab504a9a0bcef337ff0f8172a910e",
    transactionIndex: 10,
    v: "0x2a",
    value: 1000000000000000000
  }

But get balance shows me always 0 ETH:

  // balance of my local account
  eth.getBalance("0x4168eAE10bF4CBEdB34237fc858A5BBEb03f0Be9")
  0
  eth.getBalance("0x68F4D98bbcC1e11351EdfaF7DE7782cF3F44c9Bc")
  0

The question what i am doing wrong.

UPD:

I have read this question Why is my ether balance 0 in geth, even though the sync is nearly complete? , that seems looks like my. And now i have removed and resynchronized my database without fast' flag but with the same effect. I already have my block but all balances are zeros. I have 72 blocks behind tail and never reach fully synched state.