texts:
I am writing test driven smart contracts. There is one smart contract with parameterized  constructor. And I am using the require statement in the constructor. I want to catch the error in my test case. The returned error is:

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

According to me it should be related to Revert. Can any one tell me why its showing the error of Gas.

Below is the code:

constructor(
        TwoC _twoc
        ) Ownable() Destructible() payable public {
        require(_twoc != address(0));

    }

Test Case:

it('Initial :: Null-Economy-Address-TestCase', async () => {
    let twoc= await twoc.new();

    await obj.new(null_address);


texts: Can a smart contract automatically generate tokenURI based on tokenID

texts: Is there a way a smart contract can automatically generate tokenURI using the tokenIDs of erc721 tokens, if we dont want to use other methods. I am a newbie so need some guidance.


texts: Work around for getting third party contract to pay eth for transactions?

texts:
I'd like to find a way for an address to trigger a transaction without paying the cost of eth.

I know that two years ago there was some talk about making this a feature of ethereum. Does anyone know what the status of that is?

Until then I'm trying to figure out how to do a workaround.

I was thinking that I could have a contract loaded with eth that would then approve other address to call the contract and trigger that contract to issue a transaction.

So then the address could then use some kind of delegate call to this contract. If the address was on the approved list then this contract would issue the transaction and pay for the eth.

Would something like this work? And can anyone point me to an example of this being done?

Thanks!


texts:
I am reading about the problem that happened today between geth and parity and i've found this qualification OOG transaction, what is it?
https://www.reddit.com/r/ethereum/comments/5eoaaw/consensus_flaw_in_geth_we_have_identified_the/


texts: What is the easiest way to check the storage size of the full state DB?

texts:
What is the easiest way to check the current size of the ethereum blockchain?

I'm thinking it would be:

cd <datadir>
du -sh chaindata

Just would like to confirm.


texts:
I'm new to the blockchain space and I am trying to grasp some fundamentals before delving into programming smart contracts. Please correct me if I am wrong regarding any of the following. This is just my understanding as of now.

Plasma will enable me to run 1 or more smart contracts on a separate chain on top of the Ethereum root chain. I will have validators/miners for my off-chain smart contracts. I should also be able to create a token that can be used to pay transactions costs.

If this is the case, how do I create validators/miners for my token? Is there a specification for this? Also, are there any good resources for understanding how to create a plasma staking token?


texts: How to resolve ERC-20 Token transfer might have failed issue?

texts:
I withdrew ARCT (ArbitrageCT) tokens from (yobit.net) to my ether address. It was listed as successful in the exchange but the tokens were not added to my address. On checking the transaction it said; the token transfer might have failed.
Why did this fail? Was there issue in exchange or contract ?
Many other people have faced same problem.
https://etherscan.io/tx/0x240146d7ea604ea6742030f209adcf906d41bdf1baf6f4815e4fc2fc1809028a


texts: I want to detect if my user unlock their metamask so I can redirect them to the right page as soon as they unlock instead of having them click away from the "your metamask is locked" page. Is that possible?


texts: What's the best way of searching in a mapping of objects?

texts:
I need a mapping of objects like this:

mapping (string => person) as clients;

struct person{
        string name;
        uint score;
    }

let's say i have 3 persons on my table:
john doe
marcus aurelius
john mcfee

i need to somehow make a search from outside the smart contract in order to find all persons with john in the name, without executing any smart-contract function.

i understand i can't have a public mapping with string => person and converting string to bytes32 isn't viable because i need a bigger string  to use as key.

how can i make both the keys and the objects public so i can search from outside the contract?
should i use an auxiliary mapping or is there a more efficient way of doing this?


texts: How can I make an offline transaction and send it to Ethereum client network in java?

texts:
private class Myclass extends AsyncTask<Void, Void, Void> {

        protected Void doInBackground(Void... params) {

            //sldknfbhvsjhxcnzmcxcmj
            Web3j web3 = Web3jFactory.build(new HttpService("https://rinkeby.infura.io/...."));
            Web3ClientVersion web3ClientVersion =null;
            try {
                web3ClientVersion = web3.web3ClientVersion().sendAsync().get();
            } catch (ExecutionException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String clientVersion = web3ClientVersion.getWeb3ClientVersion();

            Log.i("checking just",clientVersion);
            Admin admin = AdminFactory.build(new HttpService("https://rinkeby.infura.io/v3/..."));  // defaults to http://localhost:8545/
            PersonalUnlockAccount personalUnlockAccount = null;
            try {
                personalUnlockAccount = admin.personalUnlockAccount("0x...",
                        String.valueOf(true)).send();
            } catch (IOException e) {
                e.printStackTrace();
            }

            if (personalUnlockAccount.accountUnlocked()) {
                // send a transaction
                TransactionManager transactionManager = new RawTransactionManager(
                        web3,
                        getCredentialsFromPrivateKey()
                );

                Transfer transfer = new Transfer(web3, transactionManager);

                TransactionReceipt transactionReceipt = null;
                try {
                    transactionReceipt = transfer.sendFunds(
                            RECIPIENT,
                            BigDecimal.ONE,
                            Convert.Unit.ETHER,
                            GAS_PRICE,
                            GAS_LIMIT
                    ).send();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            Log.i("checking just",clientVersion);

            return null;
        }

    }

    private Credentials getCredentialsFromWallet() throws IOException, CipherException {
        return WalletUtils.loadCredentials(
                "passphrase",
                "wallet/path"
        );
    }

    private Credentials getCredentialsFromPrivateKey() {
        return Credentials.create(PRIVATE_KEY);
    }


texts:
So basically I am just getting started with Truffle and I have created my first Solidity code, which looks like this:

pragma solidity ^0.4.4;
contract HelloWorld
{

function SayHello() internal pure returns (string)
{
    return ("Hello World!");
}

}

I then opened Powershell and ran the following command:  testrpc
Than I compiled and migrated my code using "truffle" compile and "truffle migrate"

The problems started occurring when I opened "truffle console" and did this, giving me an error at the end:

PS C:\Users\**\MetaCoin> truffle console

truffle(development)> var hw

undefined

truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed});

undefined

truffle(development)> hw.SayHello.call()

**TypeError: Cannot read property 'call' of undefined**

truffle(development)>

Can someone help me with this?
Thanks.


texts:
and am trying to write some test for a payable function in Solidity but i don't know how to go about it any help will be appreciated .
I want to test for the case where the buyer send an amount less of the item price . should i just check if the state of the item hasn't changed or is there a way to check if the modifier didn't "Pass"

modifier checkValue(uint _sku) {
    _;
    uint _price = items[_sku].price;
    uint amountToRefund = msg.value - _price;
    items[_sku].buyer.transfer(amountToRefund);
}
modifier paidEnough(uint _price) {require(msg.value >= _price);_;}

function buyItem(uint _sku) forSale (_sku) checkValue(_sku) paidEnough(items[_sku].price) public payable
{
    items[_sku].buyer = msg.sender;
    items[_sku].seller.transfer(items[_sku].price);
    items[_sku].state = State.Sold;
    emit Sold(_sku);
}


texts: You must deploy and link the following libraries before you can deploy a new version of Contract

texts:
I made my custom library and try to using on my own project.
Below is the 2_deploy_contracts.js

module.exports =  async(deployer, netowrk) => {
await deployer.deploy(OptionStorage, ownerAddress);
await deployer.deploy(LDerivativeFactory);
await deployer.link(LDerivativeFactory, DerivativeFactory);
await deployer.deploy(DerivativeFactory, OptionStorage.address, XToken);
};

and in test cases, I am trying to use it as

beforeEach(async () => {
    optionStorage = await OptionStorage.new(owner);
    //library = await Library.new();
    //DerivativeFactory.link('LDerivativeFactory',library.address);
    derivativeFactory = await DerivativeFactory.new(optionStorage.address, quoteToken.address, { from : owner, gas : 50000 });
});

but in running the test cases I am facing the error

  Error: DerivativeFactory contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of DerivativeFactory: LDerivativeFactory

How to resolve it? I try to link in the test cases as well then I ended up with different error

  Error: Error: base fee exceeds gas limit

Any help is admirable


texts: how can i convert this number to arguments?

texts:
in this img you seen 570.1777 ext TRANSFER by function
i want now how can convert this amount to arguments easy


texts: How can I calculate gas price and gas limit programmatically using web3j

texts:
I am using following code to deploy my smart contract but now my transaction is taking too much time to mine on my private blockchain.
String contractAddress = myContract.deploy(web3j, credentials, DefaultGasProvider.GAS_PRICE, DefaultGasProvider.GAS_LIMIT, BigInteger.valueOf(campaign.getId()),
                        campaign.getName(), startDateTime, endDateTime).send().getContractAddress();

So far I was using DefaultGasProvider to calculate gas price and gas limit but it seems like now these limits are not enough to mine my blocks...its taking like 34 mins to mine my transactions.
How can I programmatically calculate these value using web3j. Please help me.


texts: Ethereum Puppeth private blockchain hosted in google cloud how to connect through rpc

texts:
I have deployed a priavate etheruem Poa bloackchain to google cloud using puppeth everything is working fine but i can't figure out how to connect throw rpc to the private network !

please help ! any advice ?


texts: How to call & use ERC20 airdrop smartcontract

texts:
I'm using remix solidity browser compiler.

I deployed this code for an AirDrop smart contract:
https://pastebin.com/kzYxmEab

I used the same address to create/deploy the Airdrop contract as was used to create/deploy the token contract. I sent a test amount of the token to the Airdrop Contract, also from the same address as created it.

I want to use the sendTokens() function to send multiple at a time eg.
["A","B","C","D"],[2,4,6,8]

Where and how exactly do I actually use and interact with this contract? Is it from within Remix compiler? Is it from within MyEtherWallet, while logged in with MetaMask of the creator address, by using the ABI/json box there?

Tx Hash of the AirDrop contract deployed.

thanks


texts: Parity - what --tracing and --pruning options use to get all blocks fastest way

texts: I need download all blocks to be able to get all history transactions to create some statistics like mean Ether amount etc. Is it necessery to use --pruning archive and use ~ 1TB od disk? Or default setting with --tracing on will give what I need?


texts:
I wanted to get array length by getter function, but it keeps reverts. But I have no idea why it's reverting. Here is my code.

struct ItemAddress {
    uint8 sendNatCd;
    uint8 rcvNatCd;
    uint16 ordID;
    string sendAddr;
    string rcvAddr;
}

ItemAddress[] public itemAddresses;

function createItemAddress(
    uint16 _ordID,
    uint8 _sendNatCd,
    uint8 _rcvNatCd,
    string calldata _sendAddr,
    string calldata _rcvAddr
)
    external
    returns
(
    uint256 itemAddressID
)
{
    ItemAddress memory _itemAddress = ItemAddress({
        ordID: _ordID,
        sendNatCd: _sendNatCd,
        rcvNatCd: _rcvNatCd,
        sendAddr: _sendAddr,
        rcvAddr: _rcvAddr
    });

    itemAddressID = itemAddresses.push(_itemAddress) - 1;

    return itemAddressID;
}

function getItemAddress(uint16 id)
    external
    view
    returns
(
    uint16 _ordID,
    uint8 _sendNatCd,
    uint8 _rcvNatCd,
    string memory _sendAddr,
    string memory _rcvAddr
)
{
    ItemAddress storage itemAddress = itemAddresses[id];

    _ordID = itemAddress.ordID;
    _sendNatCd = itemAddress.sendNatCd;
    _rcvNatCd = itemAddress.rcvNatCd;
    _sendAddr = itemAddress.sendAddr;
    _rcvAddr = itemAddress.rcvAddr;
}

function getItemLength()
    public
    view
    returns (uint256)
{
    return itemAddresses.length;
}

When I push data to itemAddresses array with createItemAddress(), I can get the data with getItemAddress() (ex. getItemAddress(0)). But when I call getItemLength(), it keeps reverting. So I tried itemAddresses.length at truffle console, and it returned 0. I'm confused that I could receive data from getItemAddress(), but why the itemAddresses array length is zero. What did I do wrong here?


texts: Unable to view the transaction details in etherscan

texts:
I am using ethereumJs and web3.js to send erc20 tokens from one account to another account.I am able to get the hash of transaction, but cant see any transaction details on the etherscan.

var Web3 = require('web3');
var express = require('express');

var router = express.Router();
var fs    = require("fs");
var EthereumTx = require('ethereumjs-tx');
var crypto = require('crypto');
var secp256k1 = require('secp256k1');
var keccak =  require("keccak");

router.get('/', (req, res, next) => {

if ( typeof web3 !== 'undefined' && typeof web3 !== undefined) {
    web3 = new Web3(web3.currentProvider);

   console.log('if');
}
   else{

   web3 =  new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/tPNyqnWI32IepQh2lrMf"));
   var count = web3.eth.getTransactionCount("0xD8d9e3fE93315b8ce838E39c4696438A8d8E66F3");
var abiArray = JSON.parse(fs.readFileSync('./public/mycoin.json', 'utf-8'));
var contractAddress = "0x9A48831A220c793ed4CcF0dCbD5390fB56EF9B91";
var contract = web3.eth.contract(abiArray).at(contractAddress);
   var number =  web3.eth.blockNumber;
   var rawTransaction = {
    "from": "0x95297713bdb43515420d9662a88516219085bb8a",
    "nonce": "0x001",
    "gasPrice": "0x9184e72a000",
    "gasLimit": "0x7458",
    "to": "0xDED54CC5f578Aa39c1083dbe16D68a28C776cA02",
    "value": "0x012",
    "data": contract.transfer.getData("0x9A48831A220c793ed4CcF0dCbD5390fB56EF9B91", 10, {from: "0xD8d9e3fE93315b8ce838E39c4696438A8d8E66F3"}),
    "chainId": "0x04"
};

var privKey = new Buffer('9e37167fd8b807a3805e41e34e07dd5472512ec568878c0a08c49cec0c5f9a4b', 'hex');
console.log('else');
var tx = new EthereumTx(rawTransaction);

tx.sign(privKey);
var serializedTx = tx.serialize();
;
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
     if (!err) {
        console.log(hash);
     }
     else{
        console.log(err);
     }
});

}

});

module.exports = router;

I am also broadcasting the trx hash to the network but getting an error----rlp: value size exceeds available input length
Trx hash : 0xf614784bd9b375e1e4d6486880deb50a829b1a229620e80b16f5befe1c9ab4a0


texts: Address as name of an array in solidity?

texts:
How to make an array with its name as address of user?
For example string[] public 0x7v77wfr349C9864De0119E94c3f8d.


texts:
I am having trouble accessing data from a mapping that I have created on the client side.

My smart contract has 2 function 1 that sets the values for the mapping.  The second one retrieves the values of my mapping.   When I deploy and run these functions in Remix they return the correct value.  But when I start to integrate then with my front end I am hitting some issues.

Here are the smart contract functions:

struct Student {
    string grade;
    address studentAddr;
    string fName;
    string lName;
    string email;
    string className;
}

mapping (address => Student) Students;

address[] public studentAccts;

Setter Function:

 function setStudent (address _address, string _grade, string _fName, string _lName, string _email, string _className) public {
    var student = Students[_address];

    //Setting the variables of my Struct.
    student.grade = _grade;
    student.studentAddr = _address;
    student.fName = _fName;
    student.lName = _lName;
    student.email = _email;
    student.className = _className;

    studentAccts.push(_address) -1;
}

Then my Getter

function getStudent(address _address) view public returns (string, address, string, string, string, string){
    return (Students[_address].grade, Students[_address].studentAddr, Students[_address].fName, Students[_address].lName, Students[_address].email, Students[_address].className);
}

Now on my the client side.
My Function to populate the mapping for each address.

    Registrar.setStudent($("#address").val(), $("#grade").val(),$("#first_name").val(), $("#last_name").val(),$("#email").val(),$("#className").val(),(err, res) =>{
      console.log("this is my result", res);
      if(err){
        console.log(err)
      }
    });

Then to retrieve the values in the mapping based on a specific address:

  $("#Retrieve").click(function(){
    const address = $("#address").val();

    Registrar.getStudent(address, (err, res) =>{
      console.log(res);

    })

  })

When I call the getStudent's function in my smart contract I am getting an array that looks like this:
["0x00000000000000000000000000000000", "0x0000000000000000000000000000000000000000", "0x00000000000000000000000000000000", "0x00000000000000000000000000000000", "0x00000000000000000000000000000000", "0x00000000000000000000000000000000"]

Not sure what I am missing here.  Any help would be greatly appreciated!


texts: Solidity ^0.6.0 Truffle Compile Error: Cannot read property ... of undefined

texts:
I initalised a new truffle project by using truffle init.
I changed the solc version to ^0.6.0 in the truffle-config.js file.
I ran truffle compile and got this error:
TypeError: Error parsing C:/init-truffle/contracts/Migrations.sol: Cannot read property 'addFunction' of undefined
    at runWithReadCallback (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:37:1)
    at compileStandard (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:78:1)
    at Object.compileStandardWrapper (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:85:1)
    at Object.parseImports (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\parser.js:47:1)
    at Object.getImports (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:374:1)
    at Promise.all.then.results (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:346:1)
Truffle v5.0.5 (core: 5.0.5)
Node v10.16.3

Here is the Migration.sol file:
pragma solidity >=0.4.21 <0.7.0;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

  constructor() public {
    owner = msg.sender;
  }

  modifier restricted() {
    if (msg.sender == owner) _;
  }

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;
  }
}

Here is the 1_initial_migration.js file:
const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

Does anyone know what to do? This file compile without any problems with solc version set to ^0.5.0.
Environment:

Operating System: Windows 10
Truffle v5.0.5 (core: 5.0.5)
Node v10.16.3

Thanks


texts: machine learning (clustering algorithm) in smart contract

texts:
i want to implement a clustering algorithm (k-means for example) in a smart contract.

for the traning data (big Data Set) , i want to use IPFS(off-chain) to save my dataset.

is this Idea Correct?
How and with what can i start?
can i use IDE remix solidity to implement all this.
thanks.


texts: geth vs ganache (testrpc): failed transactions produce different results

texts:
It seems that geth and ganache-cli (testrpc) have differing behaviour on failed transactions.  Suppose

(1) I have a trivial smart contract with a variable, a getter&setter, and an event.  The setter takes a boolean argument, and if that argument is false, it fails.  Otherwise, it sets the variable and fires and event.

(2) I have a test that does get()/set(true,42)/get()/set(false,84)/get()

(3) when I run with ganache-cli as a backend, the second set() produces a VM revert exception

(4) when I run with geth, I get a transaction hash, and looking it up, yields a receipt with empty log (so the tran didn't run).  Further, the subsequent get() shows that the variable has not been changed.

(5) by contrast, the first set() yields a tranhash/receipt from both backends, and of course, the log is there and I can find the events.

To sum up: running against both backends, the state-behaviour of ethereum is the same.  BUT against geth, we get no exception on the second set(), whereas with ganache-cli, we DO get an exception.

I don't know whether this is expected behaviour.  But I do know this: I checked both openzeppelin-solidity and gnosis/MultiSigWallet, and both of them have unit-tests that expect the ganache-cli behaviour, and fail when run against geth.

One of the two is wrong here.  If I'd make a guess, it's ganache-cli.  But OTOH, two well-respected projects both count on this behaviour.

Not sure what to think.  Anybody got a clue about this?

contract Bar
{
  uint n ;
  event Argle(uint arg);
  function argle_int(uint arg) internal {
    n = arg ;
  }

  function argle(bool pass, uint arg) public {
    Argle(arg) ;
    require(pass) ;
    argle_int(arg);
  }

  function get() public view returns (uint) {
    return n ;
  }
}


texts: Can the CALL opcode be used to create a contract?

texts:
The Yellow Paper Appendix H defines the CREATE and CALL opcodes.  For CALL:

  the operand order is: gas, to, value, in offset, in size, out offset,
  out size.

By setting the second operand (the "to") as zero, can the CALL opcode be used to create a contract?

If that's possible, what would the differences between using CREATE and CALL be?  Are there any cases where it would be better (for example cheaper gas) to use the CALL opcode to create a contract?


texts: If mining is on, on an Ethereum node on EC2 AWS instance, it is unable to connnect to peers on Azure

texts:
I am runing a private ethereum network with nodes on AWS and Azure.
AWS EC2 - Mining Node &
Azure - Peering node
When the mining is on, in AWS node, the peering is lost intermitently, with Azure node. But when the mining is stopped, the peering happens and all blocks are in sync.
Have someone faced similar issue or what might have caused the issue?
Any resolution or lead is of great help.
Regards,
Manoj


texts:
I am getting following error message with require statement:

  Error: Wrong argument count for function call: 0 arguments given but
  expected 1. This function requires a single bytes argument. Use "" as
  argument to provide empty calldata.

        require(msg.sender.call.value(address(this).balance)());
                ^--------------------------------------------^ :

  Error: No matching declaration found after argument-dependent lookup.

        require(msg.sender.call.value(address(this).balance)());
        ^-----^

The require statement is:

require(msg.sender.call.value(address(this).balance)());

Somebody please guide me.

Zulfi.


texts: Duplication of events in permissioned geth Chain with clique PoA consensus algorithm

texts:
I have an Ethereum chain running on my local host via geth and i am using the clique PoA Algorithm. I have 4 authority nodes so the number of Nodes allowed to sign a block should always be 1 because of ( N - (N/2 + 1)) with N being the number of authority nodes.
I also have a Node.js script that is syncing with the events happening in the chain. I am using an eventListener like this:

AboStoreContract.events.allEvents({fromBlock: "latest"})
    .on('data', (event) => { handleEvent(); }).on("error", console.error);

The connection between node.js and my node running on localHost is made through the geth.ipc file like this:

const web3 = new Web3("\\\\.\\pipe\\geth.ipc", net);

Now my issue is that often the same event gets duplicated. its always 3 times if duplicated. I started inspecting the transactionHash and blockHash and it seemed like 2 duplications have the same transactionHash + blockHash and then the 3rd duplication has the same transactionHash but a different blockHash.

The only reason how i can explain this is due to a chainreorganization going on, but as i only have 4 authority/signing nodes there can, due to clique consensus algorithm, at all times be only one node allowed to sign. So there cant be a race going on that leads to making use of the GHOST protocol to see which fork has the higher "value"

I know that i am supposed to wait for a certain number of Blocks so i can be sure that the events are not lying in a forked chain that gets thrown away, but in my usecase blocks are only created when a transaction happens, so i have to react to events right away.

So the question is: why do i get duplicated events, when chain reorg is impossible? or is it still possible and i dont understand the clique algorithm?

thanks in advance


texts: I'm looking to see if there are any ethereum multisig wallets that use schnorr multi-signatures instead of smart contracts? Would be useful for saving gas and potentially using contracts/sites that require interaction by EOA addresses.


texts: How to register an account in web3.js v0.x

texts:
I want to create a new account using web3.js < v1.0

In web3.js 1.0.x we have this method:

web3.eth.accounts.create();

or at least this method:

web3.eth.accounts.privateKeyToAccount(myPrivateKey);

But unfortunately I didn't any equivalent method in web3.js v0.x

Do you know any way to create a new account in web3.js v0.x?

P.S: this topic (Creating an account using web3js or web3j) is about this subject, but it doesn't contain any correct alternative solution.


texts: How can I send ethers from my smart contract to another address using transfer?

texts:
recievers_address.transfer(address(this).balance);

when I use this from one of the functions of my smart contract

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

red underlined under the receivers-address!

to be noted: recievers_address is a private field.


texts: excluding certain recipient addresses from an array iteration

texts: How can I iterate through an storage array in a function which signature defines an input-array parameter declaring excluded recipient addresses that should not be targeted in the iteration of a for loop?


texts:
Hello guys,

Is there any of you who have tried to add metamask to electron.js. I wasn't able to find any relevant sources. My goal is to create desktop dapp. If you have any articles or advices will be much appreciated.


texts: Metamask and web3 wrong behaviour when extension is disabled

texts:
Basically I have a dapp that gets the web3 object from window.web3 (the injected from metamask).

When i disable de extention from chrome (not removing, just disabling) the web3 invocations are skipped, no callback is generated.

To Reproduce

Install metamask in your browser
Disable it
In the dapp, send a transaction

My code:

const getData = myContract.myMethod.getData(parameters);
web3.eth.sendTransaction({ from: from, to: CONTRACT_ADDRESS, data: getData }, function (error, result) {
       console.log("Callback !")
});

I suposse that sendTransaction should fail or throw an error

OS: Windows
Browser: Tested on chrome and mozilla firefox
MetaMask Version: Latest 5.2.2

Any ideas?

The problem is just when is disabled, when the plugin is installed or removed from chrome i get the right responses (the popup shows and an error is throwed respectively)

I have implemented that if user refresh the page the web3 instance get obtained again, and if it is disabled then the web3 object is null. The problem is that the browser doesnt detect the disabling until a reload

I can see that when disabling the webpage shows this warnings, but.. is there any way to detect those events to set the window.web3 object to null or something?

I have created an issue into metamask github: https://github.com/MetaMask/metamask-extension/issues/5936


texts: Ethereum Wallet on Mac - Way Too Slow and uses up CPU!

texts:
I am really concerned with the amount of blocks I have to sync and how long it takes/how much power it consumes. It took me 2-3 days to fully sync last week and now I am syncing all day again. It feels that with current volumes it won't be long before it will be mathematically impossible for me to sync.

I have seen some posts about fast geth (no idea what it is/what it means) but they give some programming codes and I have no idea what to do or where to start. I refuse to use an online wallet as this means trusting someone else (I have few hundred £ in cryptsy).

Is there anything like Electrum for ethereum where long block dl & sync is not required? Just wanted to also add that I am certain way more people would use ethereum and its price would rise if the interface was more user friendly and long sync wasn't required.

Update: checked for updates and running latest version of Ethereum (09/09/2017)


texts: Do i really need all these arrays and mapping? Gas usage issue

texts:
I've written a sample contract below. My question is, do i really need so much mappings and arrays? It's very gas hungry by storing a couple of times basically the same data. Could the same result be achieved with fewer storage operations?

contract example {

    struct StructPrimary {
        uint start;
        bool isActive;
        uint index;
        address owner;
        uint[] indexcounter;
    }

    uint globalCounter;
    uint[] public userArray;

    // Mapping
    mapping(uint => StructPrimary) public structByIndex;
    mapping(address => StructPrimary) public structByAddress;

    function addCandidate (address _candidate) public returns (uint) {
        // Data stored in the StructPrimary, needed to get global info on the candidate
        StructPrimary storage accounts = structByIndex[userArray.length];
        accounts.start = 0;
        accounts.owner = _candidate;
        accounts.isActive = true;
        accounts.index = userArray.length;
        accounts.indexcounter.push(userArray.length);

        // Index stored in a mapping. Needed for most contract functions (operates by ID, not by address)
        structByIndex[accounts.index].owner = _candidate;

        // Address stored in a mapping. This gives a quick overview of all registered indexes belonging to the same address
        structByAddress[_candidate].indexcounter.push(userArray.length);

        globalCounter++ ;

        // This array is used troughout the contract to loop trough the users
        return userArray.push(accounts.index);
    }
}


texts:
I have a Geth server which is fully synced, but the second server I have lunched cannot being synced after 2 weeks! I don't know why is this happening, but I decided to test another way.
I setup a new server and now, I would like to know how can I duplicate Geth server to have a new one?
For this purpose, I tried a way. I copied all geth and keystore directories from server 1 to server 2 via SCP in about 1 hour. Everything got finished and I ran the geth command, but I received the error below:

Fatal: Error starting protocol stack: gap (#9924668) in the chain between ancients and leveldb

I would be pleased if you can help me to know the appropriate way of having a duplicated server, or solving the issue mentioned above.


texts: How to call smart contract function when the owners address receives ethers?

texts:
A token ERC-20 smart contract can call functions when the transfer() function is called to send or receive tokens. I can test if is the owner address and make things.
Its possible that my smart contract know if the owner address receives ethers (no tokens) and call a function?


texts:
I am taking a smart contract course on udemy which belongs to 2017.Many web3 versions have come since then which is making me confused to implement what i am learning in newer versions.
When i want to create an instance of web3 on my project(web3.js) and use it in another script(app.js) and print it on console, I am facing an empty array instead of array including my meta mask address.
web3.js
import Web3 from "web3";

const web3 = new Web3(window.web3.currentProvider);

export default web3;

app.js

import React, { Component } from "react";
import logo from './logo.svg';
import './App.css';
import web3 from "./web3";

class App extends Component {
  render() {
    web3.eth.getAccounts().then(console.log);
    console.log(web3.version);
    console.log("Salam agha sina!");
    return (

          Edit src/App.js and save to reload.

            Learn React

    );
  };
}

export default App;


texts:
how can i  do the transfer from eth wallet address to another eth wallet address?
because i have a public eth wallet address with  balance within , i dont know how can i transfer the balance in order to use it on purchase.I am trying to to search for the sites like coinbase where i could be able to do this ,i dont know what can i do.I need your advise before the time while my eth balance are still in use.


texts: How can I check if a user is logged in to Metamask?

texts:
I tried a very simple example of web3, it works if you Log In to Metamask and try to send some ETH.

However if I'm not logged in to Metamask no errors and no tips are shown.

How can I check if a user is already logged in to Metamask?

         <title>Introduction to Dapps. Simple MetaMask example.</title>

      <fieldset>
         Ether:
          <input type="text" id="amount"></input>

        <button onclick="send()">Donate to the Author</button>

      </fieldset>


texts: Can we trust a dApp as much as we would trust Ethereum?

texts:
I was reading about bridging Ethereum and IPFS and I stumbled upon an article that uploads the file to IPFS and records the hash of it as an Ethereum transaction. I then tried to understand the difference between a smart contract and a dApp from this answer.

From what I understood, a smart contract is part of the blockchain and dApp is outside the system of blockchain. So, my question is, given a dApp that uploads your file to IPFS and records its hash on Ethereum's chain, would you trust this app as much as you would trust the Ethereum chain?

In case "trust" seems to be ambiguous, consider my question as follows:
Would you consider this dApp as tamper-evident as Ethereum? Would you trust it to share your credentials to record a transaction on Ethereum?

Some reading material towards the following question would be much appreciated:
 What would be the ideal-most way(steps) to upload a file on ipfs and record its transaction on Ethereum if not this one?


texts:
I'm working on an ethereum blockchain project where people want to make reservations in a city. My backend sends a transaction to the smart contract with the user id, city and other data. The smart contract must perform other operations including communicating with an oracle. BookRequest (send) is called. This method calls the oracle smart contract. When the oracle smart contract (via its backend) gets the necessary data it calls the CallBack method. I have a doubt: when is the transaction mined? Before getting the final result (booking was successful or not)? Or later? If the transaction was mined and I received the hash, what does "Restore request context from Requests [id_]" mean? Are transactions not immutable?
The user wants to check if the booking was successful and uses the hash of the transaction, but what does he find? Find the booking result that was updated when it did the restore context? I do not know if I was clear.
function BookRequest(bytes32  id_, bytes32  location_, bytes32  attr1, int256  attr2) public payable
   {
       bool  result ;

        Requests[id_]=Request({ Location: location_,
                                   Attr1: attr1,
                                   Attr2: attr2     }) ;

        (result,)=address(WeatherAddr).call.gas(0x300000).value(msg.value)(abi.encodeWithSignature("GetWetaher(bytes32,bytes32)", id_, location_)) ;
      if(result==false)  require(false) ;
   }

function CallBack(bytes32  id_, int256  tempirature_) public
   {
//          1. Restore request context from Requests[id_]
//          2. Process request for booking
   }


texts: How to get reason revert using web3.eth.call

texts:
I have a smart contract with required message and pretend to use the required/validation message in front end.
require(bytes(hashAlreadyRegistered[hash]).length  == 0, "Hash already registered");

I'm trying to get the reason of revert using web3.eth.call.
By my understanding reading the doc if i pass the object generated by sendTransaction it will work. I think it is what i'm trying to do but didn't work so far.
My codes
sendTransaction method:
await canManipuleContract.methods.setDocumentHash('#_' + request.body.hash)
    .send({
      from: fromAddress,
      gas: 400000,
      gasPrice: 21000000000
    })
    .then(function(txRaw) {
      console.log(txRaw)
      return response.json( txRaw.transactionHash );
    })
    .catch(function(error) {
      handleRevert(error);
      console.log("Error: \n" + error);
      return response.json( 'error' )
    })
  }

web3.eth.call method:
function handleRevert( transactionObject ) {
    web3.eth.call( transactionObject, function( err, result ) {
      if ( ! err ) {
        console.log( 'result ' + result )
      }
      console.log( 'err ' +  err)
      //return response.json( 'Error: Returned error: execution reverted' )
    })
  }

The return value of handleRevert is always err 0x. In geth console i clearly see the value err and errdata returning the correct messages.
If i pass the contract address instead transactionObject in web3.eth.call method it always return Error: Returned error: execution reverted, but never the required message it self.
Version:
Geth: 1.9.15-stable
web3.js: ^1.2.8
What am i missing here? Any others methods to get the message required of smart contract will help here.


texts: Received " VM error : revert " while calling payable function in remix

texts:
Function prototype is

    function pay1(uint xyz) payable{
    require(xyz==msg.value);
}

I set (in remix) value to 30 ether and called function with the argument 30.


texts: We want to migrate away from truffle for deploying the smart contract. What kind of approaches would be good to do this? Can deployment be done without truffle or similar tools, and done manually "pure" way?


texts:
Looking at the evmjit code I noticed that the LLVM optimizer is actually used right before execution of a contract by the virtual machine.
I have also noticed that the Solidity compiler has its own optimizer that optimizes bytecode.

Therefore, I was wondering ... what is the benefit of having a bytecode optimizer in the Solidity compiler vs relying completely on the LLVM optimizer in the virtual machine ?


texts: How to hide the private information of the transaction sender?

texts:
I want to implement the following functions in theory through solidity in test chain environment, and it is not required to be implemented in a production environment: a user can initiate a transaction and the miner verifies the transaction. However, during the verification process, the miner knows that the transaction is valid, but does not know the key privacy information such as the address of the sender. I want to know if this can be achieved, or is there a way to achieve a similar effect?
Hope you can help me, thanks!


texts: Button to interact with a smart contract function

texts:
I have this function on a smart contract:
    function togglePlayerReverse(bool _isReverse)
  public  {
    playerReverse[msg.sender] = _isReverse;
  }

I want to use this button to allow the player to switch his status true/false:
    <input type="text" id="" placeholder="true or false">
                   <button id="buttonReverse">Switch</button>

How do I implement this in the main.js file?


texts: The principle of geth checking whether a block has the highest total difficulty

texts:
How and when does geth check whether there is any block not with the highest total difficulty in chain and rollback? What is the principle of it?
If the location of source code for it could be provided，so much the better.
Thanks.


texts:
How to to fork Ethereum main net (from latest block) into a non-official chain that can only be mined by PoA/clique using geth?

Preference for keeping geth code untouched if possible.

As expected, user balances, smart contracts state and history would keep the same as main net until that point, from which on will diverge.


texts: Owner of contract is set to contract address?

texts:
I just testing a contract with truffle and Im wondering why the owner of the contract is set to the contract address itself.
Migrations:
const contractA= artifacts.require("ContractA");
const wbtc = artifacts.require("WBTCC");

module.exports = function(deployer, network, accounts) {
  deployer.deploy(contractA, { override:false, from: accounts[1] })
  .then(() =>deployer.deploy(wbtc, { override:false, from: accounts[1] }));
}

Test:
const rs = artifacts.require("ContractA.sol");
const wbtc = artifacts.require("WBTCC.sol");

contract('contractA', async (accounts) => {

    let instance;
    const truffleAssert = require('truffle-assertions');
    let deployAccount = accounts[1];
    before(async () => {
        iwbtc = await wbtc.deployed({from: deployAccount});
        irs = await rs.deployed({from: deployAccount});
    })
//...

ContractA:
pragma solidity >=0.4.24;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

contract ContractA is Ownable, ReentrancyGuard {
    using SafeMath for uint256;

    constructor () public {
    }
//...

And there is the answere of the owner() function of Ownable.sol:
owner =  0xe9ad029f5115e8569b281fb09c2316673E71085E
Do anyone have an idea why the owner is set to the contract address? Should not the Ownable set the owner in the constructor to the msg.sender?
Thanks if so :)


texts: Why do I get serialization errors in calling events?

texts:
I have put some events in my contracts like this

event TokenTransfer(address indexed sender,address indexed receiver,uint32 indexed num_tokens);
event ExceptionEvent(uint16 indexed retcode,address indexed userAddress,string context);

In my nodejs script I am doing something like this

iouContractInstance.TokenTransfer({},{fromBlock: 0, toBlock: 'latest'}).watch(function(blockWatchError, blockWatchResult){
    console.log("Looking out for Tokentransfer data");
    console.log("TokenTranfer Error:"+blockWatchError);
    if(!blockWatchError){
        console.log("The event data result is:"+blockWatchResult);
    }
});

iouContractInstance.ExceptionEvent({},{fromBlock:0,toBlock:'latest'}).watch(function(blockWatchError, blockWatchResult){
    console.log("Looking out for ExceptionEvent event data");
    console.log("ExceptionEvent Error:"+blockWatchError);
    if(!blockWatchError){
        console.log("The event data result is:"+blockWatchResult);
    }
});

On my node js console I get something like this

Looking out for Tokentransfer data
TokenTranfer Error:Error: Can only serialize integers
Looking out for ExceptionEvent event data
ExceptionEvent Error:Error: Can only serialize integers
Looking out for Tokentransfer data

Can somebody tell what am doing wrong?
My environment is:
Blockchain:hydrachain
Solidity:solc 0.2.0-1
Ubuntu 14:04


texts:
I'm getting this error while installing testrpc:

 C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers [C:\Users\user\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\node_modules\ethereumjs-util\node_modules\secp256k1\build\secp256k1.vcxproj]


texts:
new to ethereum. I'm tring to write smartcontracto to manage car rental. Can anyone explain me why the function to insert new car is not working (code below):
function insertnewcar(string memory model, string memory plate_) public  {
    car[c].car_name = model;
      car[c].plate = plate;
      car[c].car_id += 1;
     c++;
}

I make it work only putting the function in this way:
      function insertnewcar(string memory model, string memory plate_) public  {

         /* car[c].car_name = model;
          car[c].plate = plate;
          car[c].car_id += 1;
         c++; */

         car.push(Car({
             car_name:model,
             plate:plate_,
             car_id:c+1
         }));

     c++;
  }

I leave you below the entire code. the error i'm getting is "invalid opcode. invalid opcode the execution might have thrown. debug the transaction to get more information."
thanks!
pragma solidity ^0.6.0;

contract new_client {
    enum carstatus {free, rented, maintenance}
    struct Car {
        string car_name;
        string plate;
        uint car_id;
    }

    mapping(address => Car) booking;
    Car[] public car;
     uint c=0;

    struct Client {
        string name;
        string surname;
        uint age;
        bool license;
        address id;

    }

    uint total_client;

    Client[] public client;
    uint numberofclient;

    function innewclient(string memory name_, string memory surname_, uint  age_, bool  license_, address id_) public  {
        require(age_ >= 18, "must be 18 at least");
        require(age_ <= 75, "can't be over 75");

        client.push(Client({
            name: name_,
            surname: surname_,
            age: age_,
            license: license_,
            id: id_

        }));

        numberofclient = client.length;

    }

   function gettotalclient() public view  returns(uint) {

       return numberofclient;
   }

    function checkifclient(address _id) public view returns(bool,uint) {
        for (uint i=0; i<=numberofclient;i++ ) {
            if (client[i].id ==_id){
                return (true,i);
        }
        else {
            return (false,0);
        }
    }

  }

  function insertnewcar(string memory model, string memory plate_) public  {

     /* car[c].car_name = model;
      car[c].plate = plate;
      car[c].car_id += 1;
     c++; */

     car.push(Car({
         car_name:model,
         plate:plate_,
         car_id:c+1
     }));

     c++;
  }

  function gettotalcar() public view returns(uint) {
      return car.length;
  }

  function carlist() public view returns(string memory,string memory,uint) {

      for (uint i=0; i<=car.length; i++){

          return (car[i].car_name,car[i].plate,car[i].car_id);
      }
  }
}


texts: How to get return value from a contract on JavaScript?

texts:
I am making a contract with a front-end made with JS, I studied myself how to make it work calling the functions with or without variables. But I don't know how to get the return value. I would appreciate your help.
On Remix it works fine.
The solidity function of the issue

function Recompte()  public returns (uint _votes, string memory _info){
    if (estat == true) {
        return (votes,"Poll stills on");
    }else{

        for (uint i = 0; i<candidats.length; i++){
            if (candidats[i].votes > votes){
                votes = candidats[i].votes;
                idwinner = candidats[i].id;
            }
        }
    }
    return (idwinner, candidats[idwinner].name);
}

Code of JavaScript for this function for the moment

$("#fer_recompte").click(function(){
    var val = 0;

    val = parseInt($("#value_input").val());
    console.log(val);
    window.ethereum.enable();
    web3.eth.getAccounts().then(function(accounts) {
        var acc = accounts[0];
        console.log(acc);
        return contract.methods.Recompte().send({from: acc});
    })
})

Sorry for making a mess, enters don't work and I don't know why JavaScript isn't inserted well.

Thank you for your time


texts: Creating transactions with Transaction Data to Metamask

texts:
We can use transaction data to submit any Ethereum transaction using Metamask, right? Not only ERC20 transfers, right?
Does anyone knows how can I generate hexadecimal transaction data to Metamask from users inputs in my dApp?

Shall I use this code?

web3.eth.abi.encodeFunctionCall({
    name: 'myMethod',
    type: 'function',
    inputs: [{
        type: 'uint256',
        name: 'myNumber'
    },{
        type: 'string',
        name: 'myString'
    }]
}, ['2345675643', 'Hello!%']);

  "0x24ee0097000000000000000000000000000000000000000000000000000000008bd02b7b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000748656c6c6f212500000000000000000000000000000000000000000000000000"

Is there any pitfall I should know?

Thank you


texts: How can I get a private key from a mnemonic phrase?

texts: I want to convert a 24 words length seed phrase into a private key using web3.


texts: Is it possible to develop an application without smartcontract in etheruem?

texts:
We are trying to develop a Dapp through which user can save some information in blockchain. We want to use this application as a storage of data so that later point of time user can query on that. do we need smart contract in this case?

For example, 1000 users(accounts) are simply saving their identity in the block chain.


texts: How can I find the result of a function using Events?

texts:
Consider the following basic solidity smart contract

     event BattleResult(string result,uint playerResult, uint enemyResult);
     mapping(address => uint)playerChoice;

     function setChoice(uint _number)public {
         playerChoice[msg.sender] = _number
        }

     function battle(address _target) public {
      playerValue = playerChoice[msg.sender];
      enemyValue = playerChoice[_target];
      if(playerValue > enemyValue){
       emit Battleresult("win",playerValue,enemyValue);
       }
      else if(playerValue < enemyValue){
       emit Battleresult("lose",playerValue,enemyValue);
       }
      else if(playerValue == enemyValue){
       emit Battleresult("draw",playerValue,enemyValue);
       }

}

In this basic example players choose a number and they set up a battle. Don't mind the security measures and the fact that players can check opponent's value before entering a battle.

The problem I have is that when I set up the battle on the frontend, I try to show the player the results (whatever is emited: win, lose or draw). The problem I have is that it is so impossible to filter information just for a specific player and everytime I try to do something I am getting no results in the console.

I tried

SmartcontractInstance.events.BattleResult({}, {fromBlock: 0}, function(error,event){
      console.log(event);
    })
  }

which allows me to get all the past events. However is there a way to get just the result from the specific battle?

For example, should I change my solidity smart contract and for each function add

returns(string,uint,uint)

One thing I tried to do is check the address and see if it matches the sender, then push it into the array and I would simply show the last index (this sounds inefficient but maybe is just my opinion).

let result =[];
    SmartcontractInstance.events.BattleResult({}, {fromBlock: 0}, function(error,event){
      for(let i=0; i<event.length;i++){
        if(event.args.address == account[0]){
          result.push(event.args.address);
        }
      }
    })
console.log(result);  /// i'm getting an empty array unfortunately


texts: My Ethereum app consists of creating a post like on Facebook and people can like/comment on it. Should I create separate contract copy for every post or just one contract to deal with all posts?


texts: Calling smart contract function from another address

texts:
I am trying to build a dApp where a user A sends a request to a user B mentioning a certain sum of ether that B can get.

If B accepts the offer, then B get the ether proposed by A.

When I'm logged in with B's address, I can't call the smart contract using A's address, which makes sense. However, I was wondering if there is something similar when logged with B's address as  :

this.state.contract.methods.myFunction().send({ from: A_Address })

To sum up, I want that A sends a certain amount of Ether to B when B clicks on a button and the button appears only if A has allowed his consent. Is it possible ?


texts: What is the equivalent of ERC-20 tokens on the Cardano blockchain?

texts:
Ethereum, with its first mover advantage, is the basis for hundreds of ERC-20 tokens that rely on the Ethereum blockchain. Right now, virtually all altcoins listed on decentralized exchanges like Uniswap are ERC-20 tokens, making Ethereum a monster in DeFi.
What is the equivalent of ERC-20 tokens for Cardano? Are there any tokens, DApps or independent projects based on the Cardano blockchain. If so, name some top examples.
Why doesn't Uniswap (a decentralized exchange) list anything Cardano-related?
I heard Cardano makes use of an "ERC-20 converter" but not sure what that means for the question


texts: understanding etherscan.io blockchain explorer (ropsten)

texts:
I am new to eth. I tried to explore the blockchain using etherscan.
For the record, here is my eth address:

(0x757e0617fae3050242ddd13e2117ef1c62fdaf4d).

There are three things in etherscan's page that I don't understand.

(screenshot 2) I paid out some of the eth I had received from a faucet to other accounts (one of them is mine, another is that of the faucet). This translate in the balance being less than 3. But only one transaction (the original payment from the faucet) appears in this block explorer. Why is it that the balance is in line with the transaction history I know, but the outgoing transactions themselves do not appear?
(screenshot 2) Why is my address capitalized the way it is on etherscan.io, in contrast to what I see in the geth console? [ANSWERED: see comments]
(screenshot 3) An address on which I sent eth shows a positive balance, but no transaction history. How can this be?

Thanks


texts:
i am trying to code a decentralized application and what i am trying to do right now is to get the token price of 1000000000000000 and display it. but when i try to get token price i keep getting 0. im using metamask

App = {
 web3Provider: null,
 contracts: {},
 account: '0x0',
 loading: false,
 tokenPrice: 1000000000000000,

 App.contracts.DappTokenSale.deployed().then((instance) => {
  dappTokenSaleInstance = instance;
  return dappTokenSaleInstance.tokenPrice();
}).then((tokenPrice) => {
  App.tokenPrice = tokenPrice;
  $('.token-price').html(web3.fromWei(App.tokenPrice, "ether").toNumber());
}

console log results of tokenprice Object { s: 1, e: 0, c: (1) […] }

this is the the code that i am following, it worked for him but how come it doesnt work for me.
https://github.com/dappuniversity/token_sale


texts: Compiling a list of verified smart contracts

texts:
What would be the best way to compile a list of all verified smart contracts on the Ethereum blockchain, similar to the one on etherscan (https://etherscan.io/contractsVerified) But more than the latest 500 shown there.
My plan was something like that:
-set up a full node and completely sync all data
-use ethereum-etl (https://ethereum-etl.readthedocs.io/en/latest/) to gather all contracts
But how would I go on from there, especially to add data about the verification and number of transactions?


texts:
One of the functions of my smart contract can only be executed if three conditions are met. At the moment I have a single require which combines all the conditions like this:

  require(evalCond1() && evalCond2() && evalCond3());

But when I try to check my code coverage with solidity-coverage it only sees two branches: the one in which the require is met and the other, in which at least one of those conditions evaluates to false (no matter which one). I was wondering if there was any issue with breaking down the single require in three separate ones, one for each condition:

 require(evalCond1());
 require(evalCond2());
 require(evalCond3());

I think this improves readability (since the real function names are a bit more complex than evalCond) and helps showing the correct coverage for branches, but I'm not sure this doesn't have any side effects regarding gas usage and performance.


texts: I am experimenting with the zeppelin os upgradeable contracts but what I only need for my contract is to keep one specific state array when I deploy to another address. Avoiding proxy issues, upgrade frameworks and such, is there a way to do this manually somehow?


texts: How to use a smart contract to deploy another smart contract in ethereum?

texts:
Since I have a testing contract with the reentrancy vulnerability, I want to reproduce it. However, only when the deployer is a reentrancy attack contract can this vulnerability be reproduced.
Its codes are as following:
contract Forwarder {
  // Address to which any funds sent to this contract will be forwarded
  address public parentAddress;
  event ForwarderDeposited(address from, uint value, bytes data);

  event TokensFlushed(
    address tokenContractAddress, // The contract address of the token
    uint value // Amount of token sent
  );

  /**
   * Create the contract, and set the destination address to that of the creator
   */
  function Forwarder() {
    parentAddress = msg.sender;
  }

  /**
   * Modifier that will execute internal code block only if the sender is a parent of the forwarder contract
   */
  modifier onlyParent {
    if (msg.sender != parentAddress) {
      throw;
    }
    _;
  }

  /**
   * Default function; Gets called when Ether is deposited and forwards it to the destination address
   */
  function() payable {
    if (**!parentAddress.call.value(msg.value**)(msg.data))
      throw;
    // Fire off the deposited event if we can forward it
    ForwarderDeposited(msg.sender, msg.value, msg.data);
  }
}

So the first step is using a contract that can exploit the vulnerability to deploy this vulnerable contract,  how can I use a smart contract to deploy another one, especially through Remix?


texts: What is the difference between the constant and immutable keywords in Solidity?

texts: What is the difference between the constant and immutable keywords in Solidity and how do I use them?


texts: Connect metamask account to smart contract

texts:
I am learning Solidity. I have managed to create sample dapps with Truffle.
This sample apps are interacting with a smartcontract with web3js.
Each time my dapp calls a smartcontract's function, the metamask popup ask me a confirmation.
Everything works fine.
I have tried uniswap and there is something very strange for me: Uniswap ask me to "connect" my metamask wallet.
Then, i can see my Ethereum wallet's balance directly in uniswap webapp...
How can they do that ? I have looked uniswap soldity files on github and i do not understand where they connect the smartcontract to my metamask account.
Is it a good thing in term of privacy ? When i accept to connect my metamask wallet to uniswap, do i allow them to do what they want with my ether ?
Thanks


texts: Getting "Error while loading the content of .sol"

texts:
After setting up the "embark-create-react-dapp-template", I didn't see a folder for contracts. So I've created one under the root level of the project (just like in the demo). But then when I executed "embark run" I got the following:

Blockchain node is ready
Ethereum node detected..
Error while loading the content of EventCrowdTokenImpl.sol
loading solc compiler...
compiling solidity contracts...
EventCrowdTokenImpl has no code associated
did you mean "EventCrowdToken"?
deploying contracts
Executing pre-deploy actions...
Pre-deploy actions done. Deploying contracts
finished deploying contracts
Deployment Done

I can tell that my solidity files and contracts.js are fine since they did work in the normal deployment (without embark-create-react-dapp-template).

Note: I've updated the solc to the latest version since my contracts are on 0.5.0 . I'm not sure if that's the reason of the issue.

The error message didn't provide much details for me to investigate further.

I would appreciate if you would give me direction on how to solve it or ways to investigate further. Many thanks.


texts: How many projects are there which implement ERC1155 standard?

texts:
New ERC1155 standard which is thought to be an improved version of ERC721 and ERC20. But I see many projects still prefer ERC20 or ERC721 standards.
If so, do you know any projects implementing ERC1155? If so, do you know why did they implement that standard?


texts: truffle test - not able to understand why the control jumps to different test case

texts:
I am trying to write unit test cases in truffle framework.I am able to write and execute them. However, whenever I have 2 or more test cases the control jumps from 1 test case to another.

For ex: In my given test script the order of execution (added print statements) are out of sync.
I am new to javascript and promise. Please let me know what I am missing

Expected output :
  Contract: B
    ✓ Case1
    ✓ Case2
  2 passing (77ms)
In test case 1
In test case 1--->Result
In test case 2
In test case 2--->Result1
In test case 2--->Result2
In test case 2--->Result3

Actual Output :
Using network 'development'.
  Contract: B
    ✓ Case1
    ✓ Case2
  2 passing (77ms)
In test case 1
In test case 2
In test case 1--->Result
In test case 2--->Result1
In test case 2--->Result2
In test case 2--->Result3

Code attached :

// Load A and B contract
var A = artifacts.require("./A.sol");
var B = artifacts.require("./B.sol");

contract('B', function(accounts) {

   it("Case1", function() {

    A.deployed().then(function(instance) {

    instance.create("Testing1","test1",10,1788825289);

    return instance.getContentAddr.call();

    }).then (function(results){

    var contents = results;
    sg = contents[0];
    return  null;

    }).then(function() {

        console.log("In test case 1");
       return B.at(sg).supply(sg,{from:web3.eth.accounts[1],value:11000000000000000000});

    }).then (function(result) {
        console.log("In test case 1--->Result");
    });
  });

  it("Case2", function() {

    A.deployed().then(function(instance) {

    instance.create("Testing1","test2",10,1788825289);

    return instance.getContentAddr.call();

    }).then (function(results){

        var contents = results;
        sg = contents[0];

        console.log("In test case 2");
        return sg;
    }).then(function(instance) {

       return B.at(instance).supply(instance,{from:web3.eth.accounts[0],value:5000000000000000000});
     }).then(function(result) {

       console.log("In test case 2--->Result1");
        return sg;

    }).then(function(instance) {
        console.log("In test case 2--->Result2");
        return B.at(instance).resupply(web3.eth.accounts[0],5000000000000000000,{from:web3.eth.accounts[0]});
    }).then(function(result) {
        console.log("In test case 2--->Result3");
    });
  });
});


texts:
I'm writing a contract in solidity, in which a test case fails. I want to step through the code to find what's going wrong. I'm using truffle for development. This is what I do after making changes to the contract

truffle develop
compile
test ./test/NameOfMyTestCaseFile.sol

This returns failure on a particular test case.

The manual at DEBUGGING YOUR CONTRACTS, reads:

truffle debug <transaction hash>

I don't see any transaction hash output on my console. How do I use the debugger to step through the code ?


texts: How to run a simple Whisper (SHH) example

texts:
I am struggling to get a simple whisper (shh) example running.
I am using the following versions:
geth 1.9.24-stable-cc05b050
web3 6.14.5
I am running geth with the following command:
geth --shh --rpc

And I start coding with the following linex:
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var shh = web3.shh;
(async function main() {
   var keyPair = await shh.newKeyPair();
})();

Then I get the following error:
Error: Returned error: the method shh_newKeyPair does not exist/is not available

I guess that the shh command is not supported by the node (geth).
Can anyone instruct how to get a simple message passing example using Whisper running with the versions above? Thanks for the support.


texts: Would full but not archive node delete old trie node from LVLDB?

texts: Full not archive node would store the nearest 128 block's state in their lvldb. How could they delete old trie state in lvldb? I found they use dereference function in WriteBlockWithState function to delete it in cached triedb, but it would not affect the persistent lvldb.


texts: Unable to execute transactions due to out of gas on Ethereum Mist Wallet?

texts:
What should one do to resolve the issue "Data can't be executed, so it will use all provided gas." to execute transactions ?

Or how to reset the installation of Mist Wallet as I am using testnet for testing purposes.


texts: Sometimes I see people say the phrase "client" when referring to the node. Why is it called that? Really its not a client, because that depends on the client-server model.


texts: Are memory variables initialized by solidity?

texts:
I've the following struct

struct Vote {
  uint amount;
  uint count;
}

Is it initialized when allocated in memory?

function boofar(uint val) public {
  Vote memory result;
  result.amount += val;
}

When explicitly initialized the gas cost is higher 1481 vs 1417.


texts: What is the difference between bytecode, init code, deployed bytedcode, creation bytecode, and runtime bytecode?

texts: I constantly see different types of bytecode and do not know what each of them are. What are the differences between bytecode, init code, deployed bytedcode, creation bytecode, and runtime bytecode?


texts:
solidity version:0.4.25
web3 version:0.20.1

I write a contract using solidity,and I have finished the test on remix web and it work successfully.When I want to call the contract using web3,the geth console always print info:
 VM returned with error err="evm: execution reverted"
I am very new about solidity,so i can't see what's wrong with my code,please help to finger out my code's fault.Thanks very much!!!

fileEvi.sol:

contract fileEvidence{
    struct FileEvi{
        uint caseId;
        bytes fileHash;
        uint upTime;
        address upOperator;
    }
    mapping(bytes => FileEvi) evi;
    constructor () public{
    }
    function saveFileEvi(bytes _hash,uint _upTime ) public{
        evi[_hash].fileHash = _hash;
        evi[_hash].upTime = _upTime;
        evi[_hash].upOperator = msg.sender;
    }
    function getFileEvi(bytes _hash) public view returns(uint _upTime,address _upOperator) {
        _upTime = evi[_hash].upTime;
        _upOperator = evi[_hash].upOperator;
    }
}

caseEvi.sol:

import "./file_evi.sol";
contract caseEvidence{
    uint CODE_SUCCESS = 0;
    uint FILE_NOT_EXIST = 3002;
    uint FILE_ALREADY_EXIST  = 3003;
    uint USER_NOT_EXIST = 3004;

mapping(uint => address) caseEvidenceMap;
event SaveEvi(address _oper,uint _time,uint _caseId);
event GetEvi(address _oper,uint _time,uint _caseId);

function saveEvidence(uint caseId,bytes fileHash,uint fileUploadTime) public returns(uint code,address addr){
    address fileEviAddr = caseEvidenceMap[caseId];
    if (fileEviAddr == 0) {
      fileEviAddr = new fileEvidence();
      caseEvidenceMap[caseId] = fileEviAddr;
    }
    fileEvidence fileEvi = fileEvidence(fileEviAddr);
    fileEvi.saveFileEvi(fileHash,fileUploadTime);
    emit SaveEvi(fileEviAddr,fileUploadTime,caseId);
    return (0,fileEviAddr);
}

function getEviAddr(uint caseId) public view returns(address addr){
    return caseEvidenceMap[caseId];
}
function getEvidence(uint caseId,bytes fileHash) public view returns(uint _code,bytes memory _hash,uint _upTime,address _upOperator) {
    address fileEviAddr = caseEvidenceMap[caseId];
    fileEvidence fileEvi = fileEvidence(fileEviAddr);
    (_upTime,_upOperator) = fileEvi.getFileEvi(fileHash);

    if(_upTime == 0){
        return (FILE_NOT_EXIST,"",0,msg.sender);
    }
    return (CODE_SUCCESS,fileHash,_upTime,_upOperator);
}

}

web3.js:

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:50000"));
  web3.eth.defaultAccount = web3.eth.accounts[0];
  var eviContract = web3.eth.contract(abi).at("0xe176009923abb13c9215b1a3c10ba3481779a15b");
  eviContract.saveEvidence(9,'0x111111',222222,function(error,result){
     if (error)
         console.log('save evidence error ',error);
     else
         console.log('save evidence successfully',result);
 });


texts: While deploying a contract transaction is not happening

texts:
I am a newbie in Both Solidity and Programming.
I want to deploy a contract in MIST test network with some ethar. whan i pressing the publish button following error is showing.

i have added the following payable function...

function payTestFunds() payable{
    //do nothing function
}

my intention is to give some ethar to my contract account so that it can process some further transaction by itself.

function payRentToCarRentalServiceProvider(address _providerAddress) returns (bool){

    bool payStatus = true;
    if(_providerAddress.send(rentCar[_providerAddress].rent))
    {
        rentCar[_providerAddress].rent = 0;
        return payStatus;
    }
    else{
        return !payStatus;
    }
}

kindly help me...Thanks in advance


texts:
I am stuck with an issue as the contract works fine with remix ide and local ganache provider but when I am trying to use truffle with infura apis to deploy the contract over rinkeby testnet, I keep getting error.

I have tried with different gas limit values but nothing works and error is consistent.

Error :

(node:9286) UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit.
    at Object.callback (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-core-method/src/index.js:333:46)
    at sendTxCallback (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-core-method/src/index.js:486:29)
    at /home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-core-requestmanager/src/index.js:147:9
    at /home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/index.js:152:9
    at /home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/node_modules/async/internal/once.js:12:16
    at replenish (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/node_modules/async/internal/eachOfLimit.js:61:25)
    at /home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/node_modules/async/internal/eachOfLimit.js:71:9
    at eachLimit (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/node_modules/async/eachLimit.js:43:36)
    at /home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/node_modules/async/internal/doLimit.js:9:16
    at end (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/index.js:127:5)
    at /home/vineet/store/project/block-chain/ethereum/inbox/node_modules/web3-provider-engine/subproviders/provider.js:20:5
    at XMLHttpRequest.request.onreadystatechange (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/truffle-hdwallet-provider/node_modules/web3/lib/web3/httpprovider.js:118:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/home/vineet/store/project/block-chain/ethereum/inbox/node_modules/xhr2/lib/xhr2.js:469:24)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

truffle.js file

  module.exports = {   networks: {
      ropsten: {
        host: "127.0.0.1",
        port: 8545,
        network_id: '*',
        gas: 4700000,
        gasPrice: 20000000000,
      },   }, };

deploy.js file contents:

  const HDWalletProvider = require('truffle-hdwallet-provider'); const
  Web3 = require('web3'); const { interface,bytecode } =
  require('./compile');

  const provider = new HDWalletProvider(   'account mnemonic',
  'infura api link' );

  const web3 = new Web3(provider);

  const deploy = async () =>{   const accounts = await
  web3.eth.getAccounts();

  console.log('Attempting to deploy from account',accounts[0]);

  const result = await new web3.eth.Contract(JSON.parse(interface))
  .deploy({ data : bytecode,arguments: ['hello!'] })    .send
  ({gas: '2000000', from: accounts[0] });

  console.log('Contract deployed to ',result.options.address); };

  deploy();


texts: Find the public key of any ethereum account (that hasn't signed a transaction)?

texts: I need to find the public key of a list of Ethereum addresses. Is it possible to do this only with the transaction hash of one of their transactions? Per Get public key of any ethereum account the v, r and s values of the signature when a transaction is sent is also required. Using web3.eth.getTransactionReceipt for example doesn't bring back this information.


texts: Mist 0.9 Can't connect remote geth server

texts:
I setup a geth private blockchain with this command.

geth --dev --networkid 13  --rpc --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcport "8568" --rpccorsdomain "*" --datadir "/root/geth/chain" --port "30309" --identity "MyNode" --rpcaddr "0.0.0.0" console

And I test connect rpc port by curl, it is OK.

curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://x.x.x.x:8568

Then, I start mist by this command

./Mist --rpc http://x.x.x.x:8568

2017-07-28 11:33:16.171] [INFO] main - Running in production mode: true
[2017-07-28 11:33:16.175] [WARN] main - CONNECTING TO A NODE VIA HTTP INSTEAD OF IPCMAIN. THIS IS LESS SECURE!!!!
[2017-07-28 11:33:16.296] [INFO] main - Starting in Mist mode
[2017-07-28 11:33:27.290] [INFO] Db - Loading db: /Users/huxiangwei/Library/Application Support/Mist/mist.lokidb
[2017-07-28 11:33:27.304] [INFO] Windows - Creating commonly-used windows
[2017-07-28 11:33:27.305] [INFO] Windows - Create secondary window: loading, owner: notset
[2017-07-28 11:33:27.379] [INFO] updateChecker - Check for update...
[2017-07-28 11:33:30.031] [INFO] Windows - Create primary window: main, owner: notset
[2017-07-28 11:33:30.040] [INFO] Windows - Create primary window: splash, owner: notset
[2017-07-28 11:33:30.558] [INFO] ipcCommunicator - Backend language set to:  zh
[2017-07-28 11:33:31.269] [INFO] (ui: splashscreen) - Web3 already initialized, re-using provider.
[2017-07-28 11:33:31.352] [INFO] (ui: splashscreen) - Meteor starting up...
[2017-07-28 11:33:31.444] [INFO] ClientBinaryManager - Initializing...
[2017-07-28 11:33:31.445] [INFO] ClientBinaryManager - Resolving path to Eth client binary ...
[2017-07-28 11:33:31.445] [INFO] ClientBinaryManager - Eth client binary path: /Applications/Mist.app/Contents/nodes/eth/mac-x64/eth
[2017-07-28 11:33:31.446] [INFO] ClientBinaryManager - Checking for new client binaries config from: https://raw.githubusercontent.com/ethereum/mist/master/clientBinaries.json
[2017-07-28 11:33:31.922] [INFO] ClientBinaryManager - No "skippedNodeVersion.json" found.
[2017-07-28 11:33:31.923] [INFO] ClientBinaryManager - Initializing...
[2017-07-28 11:33:31.923] [INFO] ClientBinaryManager - Resolving platform...
[2017-07-28 11:33:31.924] [INFO] ClientBinaryManager - Calculating possible clients...
[2017-07-28 11:33:31.926] [INFO] ClientBinaryManager - 1 possible clients.
[2017-07-28 11:33:31.926] [INFO] ClientBinaryManager - Verifying status of all 1 possible clients...
[2017-07-28 11:33:31.927] [INFO] ClientBinaryManager - Verify Geth status ...
[2017-07-28 11:33:31.958] [INFO] ClientBinaryManager - Checking for Geth sanity check ...
[2017-07-28 11:33:31.959] [INFO] ClientBinaryManager - Checking sanity for Geth ...
[2017-07-28 11:33:32.115] [INFO] Sockets/node-ipc - Connect to {"hostPort":"http://47.88.138.98:8568"}
[2017-07-28 11:33:32.328] [INFO] Sockets/node-ipc - Connected!
[2017-07-28 11:33:32.328] [INFO] NodeSync - Ethereum node connected, re-start sync
[2017-07-28 11:33:32.329] [INFO] NodeSync - Starting sync loop
[2017-07-28 11:33:32.330] [INFO] Sockets/3 - Connect to {"hostPort":"http://47.88.138.98:8568"}
[2017-07-28 11:33:32.700] [INFO] Sockets/3 - Connected!
[2017-07-28 11:33:32.952] [INFO] (ui: splashscreen) - Network is privatenet
[2017-07-28 11:33:32.953] [INFO] (ui: splashscreen) - Network is privatenet
[2017-07-28 11:33:34.880] [INFO] updateChecker - App is up-to-date.
[2017-07-28 11:33:52.730] [ERROR] main - Error starting up node and/or syncing Error: Couldn't start swarm process.
    at Timeout.error [as _onTimeout] (/Applications/Mist.app/Contents/Resources/app.asar/node_modules/swarm-js/lib/swarm.js:420:21)
    at tryOnTimeout (timers.js:232:11)
    at Timer.listOnTimeout (timers.js:202:5)

I hope to setup a private blockchain and use mist to test smart contract.
Could you give me some idea? thank you very much!


texts: How to spend any ERC20 token with web3 (or how to find ABI from a contract address)?

texts:
I use web3 and I would like to know when somebody sent me any kind of ERC20 token. With web3, I can get the "to" and the "input" fields. With the "to", I get the contract address. With the "input", I get the recipient and the number of tokens transferred. Then, I want to spend those tokens. For that I need to connect to the contract so I need the ABI.

My questions: where can I find the ABI since I don't have the contract source ? It is possible to find the contract source ?


texts: Reverts on accessing concrete implementation of abstract mapping

texts:
I have two contract files A.sol and B.sol, and a test file B.test.sol.

Here is my current approach (reverts):

//A.sol

mapping (bytes32 => myStruct) public myStructs;

Struct myStruct {
  uint256 a;
  uint256 b;
  uint256 c;
}

//B.sol

interface I_A {
  function myStructs(bytes32) returns (uint, uint, uint) public;
}
contract B {
  A a;
  constructor(address a_address) { a = I_A(a) };

  function exb(bytes32 _structaddr){
    //REACHES HERE
    a.myStructs(_structaddr); //<REVERTS>
  }
}

//B.test.sol
import {A} from "./contracts/A.sol";
import {B} from "./contractsB.sol";

contract TestB {
  B testb;
  A testa;

   function beforeAll() {
     testa = new A();
     testB = new B(testa);
   }

  function test_exb() {
    b.exb();
  }
}


texts: What are the ways in which a transaction can fail and what happens when it fails?

texts:
What are the reasons transactions can fail and by this I mean all different types of transactions, i.e. payments EOA to EOA, contract function calls (from EOA or from other contracts) or other types that might be.

I know that nodes (depending on implementation) perform some validations before forwarding transactions but I am not sure about the scope of these.  Also what happens to transactions when a function throws, a modifier is not met or an assert fails?


texts: React Webpack Boilerplate for Blockchain

texts: Somebody suggested that I not use Truffle if i want to go into production mode. Is there a React Webpack boilerplate for Blockchain? If so, please point me in the right direction.


texts: Error compiling OpenZeppelin 3.0 ERC20 using Truffle

texts:
I'm trying to compile this code using the Truffle command truffle compile
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

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

It's basically a copy-paste from the openzeppelin official documentation.
This code woks perfectly in Remix IDE, but when I try to run it with Trufffle, I got this error:
Error parsing @openzeppelin/contracts/token/ERC20/ERC20.sol: ParsedContract.sol:98:40: ParserError: Expected '{' but got reserved keyword 'override'
    function totalSupply() public view override returns (uint256) {
                                       ^------^
Compilation failed. See above.
Truffle v5.0.5 (core: 5.0.5)
Node v10.16.3

Does anyone know what to do?
Thanks
EDIT:
I changed the version of the solidity compiler as recommanded by goodvibration and I got another error:
TypeError: Error parsing C:/tutorial-token/contracts/Migrations.sol: Cannot read property 'addFunction' of undefined
    at runWithReadCallback (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:37:1)
    at compileStandard (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:78:1)
    at Object.compileStandardWrapper (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:85:1)
    at Object.parseImports (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\parser.js:47:1)
    at Object.getImports (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:374:1)
    at Promise.all.then.results (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:346:1)
Truffle v5.0.5 (core: 5.0.5)
Node v10.16.3```


texts: Listening to events using ethers.js on a hardhat test network

texts:
I am currently migrating a truffle project to hardhat. I am facing a problem with listening to events. I have a simple ERC20 token and want to listen to the Transfer event. I am running the contract on a hardhat test network. Here is my test code, which does not catch the Transferevent. Any hits on what I am doing wrong is highly appreciated:
import { ethers } from "hardhat";
import chai from "chai";
import { solidity } from "ethereum-waffle";
import { FlanToken } from "../typechain/MyToken";
import { BigNumber} from "ethers";

chai.use(solidity);
const { assert } = chai;

describe("MyToken", () => {

    let myToken: MyToken;
    let accounts: any;

    beforeEach(async () => {
        accounts = await ethers.getSigners();
        const tokenFactory = await ethers.getContractFactory("MyToken", accounts[0]);
        myToken = (await myToken.deploy()) as MyToken;
        await myToken.deployed();
    });

    describe("token transfer", async () => {

        it("valid transfer", async () => {
            myToken.on("Transfer", (_from,_to,_value) => {
                console.log(_from,_to,_value);
            });

            await myToken.connect(accounts[0]).transfer(accounts[1].address, 1);

            // balance checks
            let balanceSender: BigNumber = await myToken.balanceOf(accounts[0].address);
            let balanceReceiver: BigNumber = await myToken.balanceOf(accounts[1].address);
            assert.equal(balanceSender.toNumber(), 999999, "Unexpected balance of sender afer token transfer.");
            assert.equal(balanceReceiver.toNumber(), 1, "Unexpected balance of receiver afer token transfer.");
        })
    });

});


texts: What are the trade-offs between Ethereum's public chain and private, permissioned chains?

texts:
I see a large number of news stories and companies talking about the possibilities for private or permissioned blockchains. What are the key tradeoffs between using a permissioned/private chain and using the public Ethereum blockchain?

When should one use a private blockchain and when a public one?


texts: I was wondering why most tokens inherit from an ERC20 interface, instead of just implementing all the functions directly. Are there are any problems that arise if the interface functions are just implemented directly?


texts: I swap ether to some coins and now i cannot swap back those coin to etherum. Probably i bought some scam coin but now my coinbase wallet is showing price against that coin. Is it possible that i can reverse my transaction or swap back


texts: Get ALL Token transfers from Block using Web3.py

texts: I am looking for a way to get all token transfers from the block using web3.py. I can now get the simple transfer or transferFrom data which was sent directly to token contract. But how can I parse a transaction with some internals inside? (for example https://etherscan.io/tx/0x707ecea0f43636d7c069e8561b4ef2c3bbc277e80cfd0f8551d189d8e9ff6ee5/)


texts:
After reading some topics on the implementation of ZK methods in the Ethereum, how would this affect the PoW?
Please have someone correct me if I am wrong (I started recently), but if the nodes need to validate transactions, how can they do it without having access to the information?
For example: a smart contract fulfills a condition when person A makes a payment of 1 Ether to person B. With ZK methods this information is not known. Therefore, if it is not known, how can the nodes validate that the contract has been correctly fulfilled if it is not possible to access this information?


texts:
I am curious if ERC20 token names are unique on the Ethereum block chain? For example, what is to stop someone from creating a new token called Golem (GNT) and publishing it to a smart contract?

I have a hunch they are not. Is there a reason for this?

It could end up being confusing to people if token names start repeating, imagine an ERC20 token called ETH


texts: I want to keep a track of top 5 token holders inside the contract in terms of their token balances, is there any efficient way to do that in solidity?


texts: How can we compile multiple smart contracts by compile.js file?

texts:
My compile.js file is below

const path = require('path');

const fs = require('fs');

const solc = require('solc');

const ballotPath = path.resolve(__dirname, 'contracts', 'blocktitans_ballot.sol');

const source = fs.readFileSync(ballotPath, 'utf8');

module.exports = solc.compile(source, 1).contracts[':blocktitans_ballot'];

I need help to export abi and bytecode for multiple contracts to write test scripts.

Above compile.js script works for single contract but how can I compile multiple contracts and export them?


texts: Use of Ethereum and the circumventing of economic sanctions

texts:
Say if one stays in a state that is heavily sanctioned, e.g., north korea, iran and these states do not have crypto exchanges, how can one leverage etheruem to create economic transaction mechanism in the absence?

Decentralised crypto exchanges?


texts: Deploy a contract from Solidity Browser or geth on an external node(connected into private ethereum blockchain)

texts:
I am trying to deploy a Contract from Solidity browser || geth. On my server machine, inside solidity browser || geth I am able to deploy a contract. But from my external node, which is connected into my private Ethereum blockchain; inside Solidity Browser || geth I won't able to deploy a contract. It halts and says: "Deploying and linking required libraries..."

[Q] How could I deploy a contract from Solidity Browser || geth inside an external node which is connected into the private ethereum blockchain?

On my client machine, the way I am connected into private Ethereum blockchain.

sudo ./geth --port 3000 --networkid 23422 --identity node1 --verbosity 3
--nodiscover --nat none --datadir="/home/avatar/MyEthereumEbloc"
--rpccorsdomain '*' --rpc --rpcaddr "localhost"
--rpccorsdomain="*" --rpcport="8545"  --nodiscover --maxpeers=4
  --bootnodes enode://<enode_id>@<ip>:3000 console

-

> admin.addPeer("enode://<enode_id>@<ip>:3000?discport=0")
true
> net
{
  listening: true,
  peerCount: 1,
  version: "23422",
  getListening: function(callback),
  getPeerCount: function(callback),
  getVersion: function(callback)
}

When I click into "create" button on Solidity Browser; on my on going geth console on client => I can see that transaction is created. But it never get mined. Basically contract's transaction get stuck inside pending transactions. The peer seems connected into private blockchain but the transaction never gets through.

I1015 19:19:44.002223 eth/api.go:1183]
Tx(0x2995698a4662ad2cc688471c19b4ce1d8fe0d1536f3548f249dadf7c16431205)
created: 0x91a81d46ee8844ab9e5dcf38a0aa37dd262fe4dd


texts: Mist stops syncing testnet when I'm mining

texts:
I wanted to mine me some testnet Ether to get started but I didn't succeed, and I noticed that:

Once I start mining I can't seem to sync anymore (the last block was always somewhere under 2min, now I can get hours late)
I can't get it to stop mining. I have to close Ethereum Wallet to get it up to date again. When I press "stop mining" or Ctrl+Shift+M it doesn't do anything.


texts: Best way to restore historical storage state

texts:
What is the best way to get historical storage state, given db with current world state and blockchain data?
Do I need to reverse assemby code or can I do this using receipt logs?


texts: Succinct contract state/storage root of a smart contract

texts:
In the yellow paper, it is mentioned(at section 4.1) that

  storageRoot: A 256-bit hash of the root node of a Merkle Patricia tree that encodes the storage contents of the account (a mapping between 256-bit integer values), encoded into the trie as a mapping from the Keccak 256-bit hash of the 256-bit integer keys to the RLP-encoded 256-bit integer values. The hash is formally denoted σ[a]_s.

Now

  I am using geth client and need to find σ[a]_s for a particular contract a. What could be a potential way to achieve that?

Additionally

  How to get account state σ [a] for a contract a.

Observe that I am only interested in the final succinct state of a contract which could be hash of the complete state of a contract at a particular instant of time and not the whole contract state which might include the code, storage etc.


texts:
I require to install a full go-ethereum geth node on a mac.
I've found countless of guides saying to just do:

brew tap ethereum/ethereum
brew install ethereum

But none of them write specifically if these commands will install the full node with several dozens of GB's of transactions or not.

Question:
Are these two commands enough to get a full node which is browsable through the geth command line? If not how to browse a full node?


texts: How does keccak256 concatenate values inside a Solidity smart contract?

texts:
I'm developing a smart contract in Solidity in which I need to evaluate the hash of two concatenated bytes32. I don't have to concatenate the bytes32 since the sha3 function supports more than one parameters and I'm using it as:

sha3(first, second);

Where first and second are bytes32.
I'd like to know how the concatenation is performed in order to replicate the same hash result locally, or using an online evaluator of the keccak-256 hash function.


texts: How to programmatically generate sub addresses using the root address in hd wallet?

texts:
And without using the private key. I've been digging into the ConsenSys's eth-lightwallet, although it uses a derived private key to generate the address which would expose the root private in danger.

Thanks!


texts:
I'm trying to work out why some Rinkeby transactions of mine are failing. For example, https://rinkeby.etherscan.io/tx/0x8746e41d51bb68df2649052c274ded300b9e5af7f820d9a856b7d199ba9e8fa4. I have no idea how to debug that transaction, so any pointers/advice would be very welcome.

fyi, I'm using infura's public API in an attempt to sidestep my organisation's firewall - thus, my dApp is deployed on IPFS at https://ipfs.io/ipfs/QmZetixYe97BStJZBbVH3woFEFrHzCMcuyak9JoCw4mjyx/#/, and it connects to Rinkeby via window.web3 = new Web3(new Web3.providers.HttpProvider(rinkeby.infura.io)). I 'think' that's okay, right?


texts: Can Solidity generate an image from a string?

texts: I've been researching on this but didn't get answers. Is there some way to put together a solidity contract that takes a string and generates an image file for the string based on some logic defined in the contract? I am aware that the image could be stored on the blockchain beforehand and can be retrieved later, but this is not what I am looking for. I understand that solidity doesn't have any image processing functions but still wanted to get some confirmation on whether there is some way to achieve it?


texts: Function stopped working? No check is being done now on transfer function

texts:
I created a function to deposit and transfer ether and it was working great until i tried to deploy again and now
the transfer function is not working anymore

No errors are being thrown, the transfer function is simply giving back transaction recipt without checking the amount stored anymore
Before if i deposit like 1 ether and tried to transfer it was working
But if i transfer it again then it threw error now it is not checking transfer function anymore

I have not slept for a day or so,.. it might be a simple mistake but i cant spot if out please if you can help as i need to show it today and it was working great a few hours before

solidity

 mapping (address => uint256) public balances;

    event LogDeposit(address sender, uint amount);
    event LogTransfer(address sender, address to, uint amount);

    function deposit() payable returns(bool success) {

        balances[msg.sender] += msg.value;
        emit LogDeposit(msg.sender, msg.value);
        return true;
    }

    function transfer(address to, uint value) public returns(bool success)
    {
        if(balances[msg.sender] < value) throw;
        balances[msg.sender] -= value;
        to.transfer(value);
        emit LogTransfer(msg.sender, to, value);
        return true;
    }

App.js

    var betAmount = document.querySelector("#bet #betAmount").value;

    var contract = web3.eth.contract(OraclizeContract.abi).at('0xBe5e4Be8Bc4800d4Fcf3509dDcCcE3630D7699C7');

    console.log(contract)

 OraclizeContract.deployed().then(function(instance) {

      console.log("Initializing");
        instance.deposit({from: fromAddress2,
                    gas: 3000000,
                    value: web3.toWei(betAmount, 'ether')}) //betAmount is a input box and fetching its value into betamount variable and passing it over here
                               .then(function(v){
                                       console.log(v);
                                       console.log("Function Executed");

                                 });
                       }).then(function() {
                                              console.log("Testing");
                       }).catch(function(e) {
                                               console.log(e);
                       });

    document.getElementById("transfer").addEventListener("submit", function(e){
          e.preventDefault();
        console.log("Initializing");
             contract.transfer(fromAddress1, 1000000000000000000,
                {gas: 3000000,
                 from: fromAddress2},
                            function (error, result){
                                   if(!error){
                                     console.log(result);//transaction successful
                                    } else{
                                     console.log(error);//transaction failed
                                     }
         })});
})
}

I tried a lot to compile again, migrate, but its not working...


texts:
I have a question to the solidity experts out there. I am Looking into fractionalize NFT's. I was thinking of many different ways of doing it. My first thought was to make a erc-20 market representing the NFT, and having maybe  features like bonding these to a curve to give the tokens liquidity.
However, I am currently reading about erc-1155 as-well and don't have any experience with it. With my surface level understanding and just reading some docs I can create the erc-20 and the erc-721 in the same contract and go about it from there. any thoughts?
So long question short how would you think about this problem of creating shares of an NFT's in a high level?