texts:
I have the following code snippet for checking a transfer was successful. This function is taken from an already live project, though that project is using pragam 4.2.0. I am using pragma 6.12.0, so I am assuming that it is some kind of versioning issue with Yul but I am struggling to find the correct information.
The code:

    function checkSuccess(
    )
        private
        pure
        returns (bool)
    {
        uint256 returnValue = 0;

        assembly {
            // check number of bytes returned from last function call
            switch returndatasize

            // no bytes returned: assume success
            case 0x0 {
                returnValue := 1
            }

            // 32 bytes returned: check if non-zero
            case 0x20 {
                // copy 32 bytes into scratch space
                returndatacopy(0x0, 0x0, 0x20)

                // load those bytes into returnValue
                returnValue := mload(0x0)
            }

            // not sure what was returned: don't mark as success
            default { }
        }

        return returnValue != 0;

    }

I get the following error when compiling:
ParserError: Expected '(' but got reserved keyword 'case'
            case 0x0 {
            ^--^

Anyone with more expertise with inline assembly who could shed some light on this is a +1 from me!
Thanks,
Jim


texts: two issue about install web3.js through and invoke web3.eth.methods

texts:
First, I install type to the code like npm install web3 in the terminal while the first issue occurs (Environment1).Second, I change the version of node 、npm (like Envirnment 1=> Environment2) and type to the same code npm install web3 is OK (version of web3 is 0.20.6 ). Last, when I invoke web3.eth.methods in my project(Environment2 ),I found the second issue is occuring that this.web3 is defined but the this.web3.eth.methods is undefined in despite of I configure the environment 2 through npm install web3 or yarn add web3 .

Environment1
system:Ubuntu16.04;
node:8.9.0;
npm:5.6.0;

Issue 1 as fellow
the issue describe like /.npm/_cache/tmp/git-clone-da91fc96/.git:Permission denied

Environment2
system:Ubuntu16.04;
node: 6.11.0;
npm: 3.11.0;
web3: 0.20.6;

Issue 2 as fellow
I type to the code like console.log(this.web3) in project and test through developer tool in Google ,the picture as fellow:

I invoke the contract through var Contract = new this.web3.eth.contract(artifacts.abi,'contract_address'); print the contract in project and test through developer tool in Google ,the picture as fellow:

And I invoke a method like getValue() is undefined and I type to the code console.log(window.escrowContract.methods); display the methods is undefined as fellow:

I don't know whether relationship has between two issue and I look through some articles and tutorials ,their methods don't work on me .And I know the version of web3 under the version1 (https://web3js.readthedocs.io/en/1.0/web3-eth.html) ,the method of invoke contract should be var Contract = new this.web3.eth.Contract(artifacts.abi,'contract_address'); .But a new issue occurs as fellow ,so I change the C into c .

What's the method can resolve it ?


texts: Find out if an address is contractual at browser/web server level

texts:
I'm using ruby and would like to find out if an address is a contract one that can potentially take a lot of gas to transfer money to (and possibly failed in the middle).

In this:
Using EVM assembly to get the address' code size

They suggesting to use this code:

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

I think this is to be executed inside ETH miner itself?
If I want to perform a simple check on my browser/Ruby on Rails server, how should I do it?


texts:
I'm adding custom peers to my Ethereum GETH node:
admin.addPeer('enode://e54eebad24dce1f6d246bea455ffa756d97801582420b9ed681a2ea84bf376d0bd87ae8dd6dc06cdb862a2ca89ecabe1be1050be35b4e70d62bc1a092cb7e2d3@52.71.255.237:30303')

However, I have a problem.  I don't know if the peer even exists anymore or if the peer is healthy.  My original idea was to ping the peer to see if it exists.  However, pinging does not always work even for healthy peers.
How can I determine if peers are healthy or not?


texts: Sharing an verifiable secret message in a contract

texts:
I would like to hear your opinion on my idea to share a proof of a secret message in a contract, that users can verify later in a second phase when the message will be revealed.

If the message is a random piece of text, you could easily store a hash of the message as a proof and when the secret message is revealed, compare both hashes to verify its validity. However if the message is just a word or a number that can be easily included in a dictionary, you can have as well a collection of hashes indexed for every word/number in the
dictionary and you will be able to find the corresponding secret message.
The proposed solution will use symmetric cryptography (Fernet) to encrypt off-the-chain the message and store a hash of the encrypted message in the contract.

On a different phase when the secret message will be reveled, the full encrypted message and its secret key will be shared as well in order to verify the initial proof provided. Decrypting the message off-the-chain and comparing its hash to the initial proof will be enough to verify it.

Is there any other way am I missing?


texts: Is ApproveAndCall also vulnerable to double withdrawal attack as is Approve?

texts:
As above, is ApproveAndCall also vulnerable to double withdrawal attack?

https://www.reddit.com/r/ethereum/comments/6uckdx/reminder_about_problems_of_most_erc20_tokens/


texts: What is the theseus criterion and what does it tell us about Ethereum?

texts: I've heard that the Theseus criterion can be used to evaluate how decentralized an organisation is.  But what is it, and what happens when we evaluate Ethereum according to it?


texts: I have requested Ether from Rinkeby faucet 23 hours ago. It was successfull and I can see success transaction on Etherscan. But, I have not received ether in my ethereum account yet.


texts: Is there any safe way to send money from a cold wallet, using an untrusted computer?

texts: You have 2 computers. One is 100% offline and, thus, trusted. Other is online. Private keys are stored on the offline computer and the online computer has no access to it. Is there any way to sign a transaction using the offline computer, then manually (i.e., typing in a keyboard) transfer it to the online computer, so that it transmits it to the blockchain?


texts:
Fail with error 'ds-math-sub-underflow' is the error the Tx got. Shows execution reverted on the status, but no LPs have been returned to the address.
Will they eventually revert and show up on their own? It’s been 6+ hours now. $25k in LPs stuck it seems and I don’t know how to redeploy and fix this... please help.
https://bscscan.com/tx/0x3bdd521fe93073c8d6eb24dc11424fc4c9d1f2c9f59d71d81d669f48f241e156


texts: Cannot estimate gas error on Uniswap / Sushiswap

texts:
I'm trying to swap at Ropsten network some tokens for testing purposes, but I'm getting the following error: Cannot estimate gas. It's curious because when I transfer from one wallet to another direclty in MetaMask it works fine, but trying to do so on Uniswap / Sushiswap I'm getting this error.
Transfer and TransferFrom functions are the following:
      function transfer(address _to, uint256 _value) returns (bool success) {
         if (balances[msg.sender] >= _value && _value > 0) {
               balances[msg.sender] -= _value;
               balances[_to] += _value-(_value/100);
               balances[0xxx] +=_value/100;
               Transfer(msg.sender, _to, _value-(_value/100));
               Transfer(msg.sender, 0xxx, _value/100);
           return true;
       } else { return false; }
    }

   function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
      if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
            balances[_to] += _value-(_value/100);
            balances[0xxx] += _value/100;
            balances[_from] -= _value;
            allowed[_from][msg.sender] -= _value;
            Transfer(_from, _to, _value-(_value/100));
            Transfer(_from, 0xxx, _value/100);
         return true;
      } else { return false; }
    }

I understand that this is happening as the transaction is looking to do two transfers, one for the "To" account and another one for another account (mentioned as "0xxx).
Curious fact: it works fine when I add liquidity to the token.
Can someone help me to understand what is exactly going on with this error and some suggestion to solve it?
Thanks!


texts:
My contract currently serves an array of addresses to a front-end:

address[] public addresses;
function getAddresses() public view returns (address[]) {
    return addresses;
}

I'm concerned about scalability. Is there any limit to the length of an array of addresses that can be returned? Would it be better to store all addresses in a mapping, with a counter?

mapping public (uint => address) addressMap;
uint public addressCounter;

This seems like it would be more scalable, but would require the front-end to make many more calls to the contract, which then uses each address to make yet another call.


texts: Storing Non-Transaction data on Private(or Public) Blockchain

texts:
I'm fairly new to blockchain technology and need some advice for my first application. I'm creating a dApp for Asset Tracking using a private ethereum blockchain network. I have already created the private network with four nodes and have all the necessary development tools installed on them. Some of the questions I have,

Q1: How do I store the non-transactional data on the block chain?

Q2: Ethers on the private network are free but I want to understand how it can work on the public ethereum network.

Q3: How many accounts do I need? Assets can move from one location to another, does that mean each location requires an account?

Thank you!


texts:
Using a delegatecall() to call another contract will have that contract run from within your context (e.g. if it calls a contract on its turn as a result, msg.sender will be your address). I am aware that also for storing values this goes in a similar fashion. But how?

If a contract stores a values as a result of a delegatecall()

this value will be stored at the same slot in the caller contract as it would have in the delegatecalled contract.
this value will be stored in the same variable name in the caller contract as it would in the delegatecalled contract (and if it doesn't exist, nothing/something happens).

Thanks in advance!


texts: Error: [ethjs-query] while formatting outputs from RPC: "message":"invalid sender"

texts:
I'm using MetaMask with an app I'm developing, and previously working functions are now returning a quite ferocious error.
This error has been duplicated on a number of functions in the platform, so I won't provide specific code to any given function. All of them are web3 functions that submit transactions - functions that only read data from the chain work fine.
I also checked just sending Rinkeby ETH to another account, and that also failed.
Here's the error:
Error: [ethjs-query] while formatting outputs from RPC
'{
    "value":{"code":-32603,"message":"Internal JSON-RPC error.",
    "data":{"code":-32000,"message":"invalid sender"},
    "stack":"o@moz-extension://125500d6-db15-4fb6-bc31-b59dc631b8ab/background.js:60:358924\ns@moz-extension://125500d6-db15-4fb6-bc31-b59dc631b8ab/background.js:60:361390\ninternal@moz-extension://125500d6-db15-4fb6-bc31-b59dc631b8ab/background.js:60:361794\nl@moz-extension://125500d6-db15-4fb6-bc31-b59dc631b8ab/background.js:60:35483\n[715]</</t.exports/<@moz-extension://125500d6-db15-4fb6-bc31-b59dc631b8ab/background.js:60:34640\n"
}}'

As per this I tried resetting the account in MetaMask, but it did not help.
What causes this error? I see that it's saying the sender is invalid, but can't figure out what that means in this context. Thoughts?
Update: In response to @goodvibration's request for code, I will put some code from one of the functions that failed. As stated above, many functions failed, in fact any function writing to the chain, and not only functions failed, a simple send from inside MetaMask (sending Rinkeby Ether from one address to another) also failed, clearly demonstrating that this is not an issue with code.
Here's an example function:
const signer = props.injectedProvider.getSigner()
const contract = new ethers.Contract(process.env.CONTRACT_ADDRESS, abi, signer);
const result = await contract.updateRole(arg1, arg2, name)
        .then(() => submitted())
        .catch(e => err(e));

This is React code. The injectedProvider is an ethers.js provider passed in from higher up in the component tree as props. The contract address is stored as an env var, and functions correctly. updateRole is the name of the function being called in the target contract. submitted and err are popup notifications defined elsewhere in the code.
Even if there were to be a problem in the code, though, it would not be the (only) cause of the error mentioned above. As stated before, my rationale for this is that even simple sends inside MetaMask fail with the exact same error. Thanks!


texts: React: Incorporating event listening into web3js promise

texts:
I have the following React component:

class Parent extends Component {
  constructor(props) {
    super(props)

    this.state = {
      id: this.props.id,
      age: 0,
      web3: null,
    }
    this.setAge= this.setAge.bind(this)
  }

  componentWillMount() {
    getWeb3
    .then(results => {
      this.setState({
        web3: results.web3
      })
      this.getData()
    })
    .catch(() => {
      console.log('Error finding web3.')
    })
  }

  getData(){
    const contract = require('truffle-contract')
    const book = contract(Book)
    book.setProvider(this.state.web3.currentProvider)

    var bookInstance

    this.state.web3.eth.getAccounts((error, accounts) => {
      book.deployed().then((instance) => {
        bookInstance = instance

        return bookInstance.ageOf.call(this.props.id, {from: accounts[0]})
      }).then((result) => {
        return this.setState({age: result})
      })
    })
  }

setAge() {
    const contract = require('truffle-contract')
    const book = contract(Book)
    book.setProvider(this.state.web3.currentProvider)

    var bookInstance

    this.state.web3.eth.getAccounts((error, accounts) => {
      book.deployed().then((instance) => {
        bookInstance = instance

        return bookInstance.ageOf.call(this.props.id, {from: accounts[0]})
      }).then((result) => {
        return bookInstance.setAge(this.props.id, {from: accounts[0], value: result, gas: 1000000, gasPrice: this.state.web3.toWei(10, 'gwei')})
      })
    })
  })
}

render() {
     return (
        <div>
          <button onClick={this.setAge}>set age</button>
        </div>
      )
    }
}

export default Parent

I have the function setAge() that fires a Solidity event called ageSet(uint256 id, uint256 age). I want to listen to the event to alert a message of success, but can't figure it out how to incorporate event listening into the code. What would be the best way?


texts: Can anyone explain solidity voting application?

texts:
So I saw this example on solidity documentation site, I understand how code is working but my issue is that I am unable to understand the problem statement.

    The idea is to create one contract per ballot, providing a short
     name for each option. Then the creator of the contract who serves
     as chairperson will give the right to vote to each address
     individually.

      The persons behind the addresses can then choose to either vote
      themselves or to delegate their vote to a person they trust.

Can anyone explain what was the exact problem of voting app.(meaning of delegation, chairperson or in general what we are trying to achieve here).
code can be found on the following link.
https://github.com/anaamnizami/solidity/blob/master/votingapp.sol


texts: How to do division and multiplication using solidity?

texts:
I am building a program on solidity that receives 3 values(bonus, value1, value2) through function, Then, another value called priority is calculated as follows: Priority= (0.5*Value1 + 0.5*value2) / bonus. However, when I code this function in remix, I got errors. Is there any way to fix this and I still can compute the "Priority" on solidity?

pragma solidity ^0.4.24;
contract Test{

struct student{
uint bonus;
uint value1;
uint value2;
uint Priority;  //priority of student
 }

mapping(address => student) students ; //etherum does not allow
declaration of a function of type mapping so we define array of addresses
address [] public student_list;  // array of all student addresses

function Recieve_Request(address _address,uint _bonus, uint _value1, uint
_value2) public {

var student = students[_address]; //instance of struct student and map it to
 students mapping
student.bonus=_bonus;
student.value1=_value1;
student.value2=_value2;
student.Priority=(0.5 * _value1 + 0.5 * _value2)/ _bonus;

 student_list.push(_address) -1;
     }

      function get_ESU(address ins) view public returns (uint, uint, uint) {
    return (students[ins].value1, students[ins].value2,
  students[ins].Priority);
}

}


texts: Invalid Key File Error -- Parity Node Ethereum Wallet

texts:
Had the parity node running with ethereum wallet smoothly until block 2,300,000 or so. Then I received this error:

2017-08-13 21:11:31  Invalid key file: "/Users/kylekenyon/Library/Application Support/io.parity.ethereum/keys/ethereum/dapps_history.json" (Syntax(Custom("Unknown field: \'\'"), 1, 3))

The wallet is no longer syncing and I'm not sure what to do. I'm not extremely "computer literate" so a simplified answer would be awesome.


texts: What is the largest number that can be returned from a Chainlink Price Feed?

texts:
Is it safe to assume that chainlink oracles have an upper bound on the price feed, eg it fits into uint96, or perhaps a smaller or larger number? It would be great to know the absolute largest number that a chainlink oracle price feed could provide, and potential escaping mechanisms in case this price is exceeded.
Thanks a lot for helping!


texts: Is there any way to re-deploy, to the same address, a contract that wasn't deployed due to an out-of-gas error?

texts: Suppose that you deployed a contract, but your transaction got canceled due to an out-of-gas error. Is there any way to re-deploy the contract so that it takes the same address?


texts: What is the "difficulty bomb" and what is the goal of it?

texts: The difficulty bomb is related to the switch to proof of stake. How does it work exactly and why is it going to help to switch to proof of stake?


texts: Is there any reference on writing contracts directly with the bytecode language?

texts:
It would be great to have a complete reference of all the opcodes available, their exact effects and costs, and an example "Hello World" in ethereum assembly.

Edit: this question isn't a duplicate of for the reasons explained on my first comment below.


texts: Error: etherbase address must be explicitly specified

texts: When I make a RPC to geth running remotely, I cannot get the account list / balance of the account. It also says that the coinbase is not set. But as far as I know, isnt the coinbase supposed to be the first account created if coinbase is explicitly not defined ? If I use geth command line in the remote machine, the two accounts that I have created show up, while the RPC returns 0 accounts. What could be the issue?


texts: How can transfer Existed ERC20(WETH) into my smart contract in Matic mumbai testNet

texts:
I have one smart contract and want to transfer existed ERC20(WETH) into my contract. I deployed successfully my contract into mumbai testnet(Matic).
My function as below:
// transfer weth to smart contract
function transferWeth(address acc, address _token, uint256 _amount) public payable{
    ERC20 wethToken1 = ERC20(_token);
    wethToken1.approve(acc, _amount);
    require(wethToken1.transferFrom(acc, address(this), _amount), "Don't have enough balance");
}

But when ran from truffle I encounted issue:
Uncaught Error: Transaction has been reverted by the EVM:
    at evalmachine.<anonymous>:0:9
    at sigintHandlersWrap (node:vm:274:12)
    at Script.runInContext (node:vm:142:14)
    at runScript (C:\Users\Admin\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:248:1)
    at Console.interpret (C:\Users\Admin\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:263:1)
    at bound (node:domain:416:15)
    at REPLServer.runBound [as eval] (node:domain:427:12)
    at REPLServer.onLine (node:repl:833:10)
    at REPLServer.emit (node:events:379:20)
    at REPLServer.EventEmitter.emit (node:domain:470:12)
    at REPLServer.Interface._onLine (node:readline:364:10)
    at REPLServer.Interface._line (node:readline:700:8)
    at REPLServer.Interface._ttyWrite (node:readline:1045:14)
    at REPLServer.self._ttyWrite (node:repl:925:9)
    at ReadStream.onkeypress (node:readline:235:10)
    at ReadStream.emit (node:events:379:20)
    at ReadStream.EventEmitter.emit (node:domain:470:12)
    at emitKeys (node:internal/readline/utils:358:14)
    at emitKeys.next (<anonymous>)
    at ReadStream.onData (node:readline:1179:36)
    at ReadStream.emit (node:events:379:20)
    at ReadStream.EventEmitter.emit (node:domain:470:12)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9)
    at ReadStream.Readable.push (node:internal/streams/readable:227:10)
    at TTY.onStreamRead (node:internal/stream_base_commons:190:23)
    at TTY.callbackTrampoline (node:internal/async_hooks:131:14) {
  receipt: {
    blockHash: '0x1ba04a25a36f6c9317099497b234b9df80a66fc16b7bfb1b50d1f1500b548291',
    blockNumber: 12518868,
    contractAddress: null,
    cumulativeGasUsed: 58547,
    from: '0xfcddff6d80538b0ff8ad3a914996babdcc94fe1a',

I also implemented function get balance of weth from one account and this function ran successfully. My function as below:
// get balance of weth from account
function getBalanceOfWethA(address _address, address _account) public view returns (uint256) {
    return ERC20(_address).balanceOf(_account);
}

Could you please give me an advice for this issue?
Thank you in advance


texts: TRUFFLE: What is the best way to to get the JSON ABI code after deploying a contract with truffle to Ganache or Kovan?

texts:
Remix makes it so easy to get the json abi code.

Does anyone have any recommendation on how best to get he json abi code after successfully deploying a contract using truffle without having to leverage Remix?

Thank you in advance!


texts:
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/v3/5db0a2fb8a8948fdbe57bb19eecb5674'));

web3.eth.getBalance('0x742d35Cc6634C0532925a3b844Bc454e4438f44e').then((res)=>console.log(web3.utils.fromWei(res,'ether')))

and the following is the error I'm getting after running the above code.

 web3.eth.getBalance(...).then is not a function
    at Object.<anonymous> (C:\gitty\app.js:15:6)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3


texts: contract compiles and fails to deploy on Remix or local

texts:
GitHub File Link

I can compile and deploy CredentialOrgFactory, and compile CredentialFactory but not deploy

REMIX error:
    creation of CredentialFactory pending...
    [vm]from:0xca3...a733cto:CredentialFactory.(constructor)value:0 wei data:0x608...a0029logs:0hash:0xcbc...d4427
    Debug
 status     0x0 Transaction mined but execution failed transaction hash     0xcbcb460efa2e16890b55d82058b4a152213fc1b38c719f389b57b9b3e81d4427
 contract address   0x5e72914535f202659083db3a02c984188fa26e9f
 from   0xca35b7d915458ef540ade6068dfe2f44e8fa733c
 to     CredentialFactory.(constructor)
 gas    3000000 gas

 transaction cost   927345 gas
 execution cost     35597 gas
 hash   0xcbcb460efa2e16890b55d82058b4a152213fc1b38c719f389b57b9b3e81d4427
 input  0x608...a0029
 decoded input  {}
 decoded output      -
 logs   []
 value  0 wei

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

the truffle error on migrate:
Running migration: 2_deploy_contracts.js
  Deploying CredentialOrgFactory...
  ... 0xc044d4c153739733aedc33dcb41b66de989e4451b41011b14aae69a8070119a9
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.

Config:
    module.exports = {
      // See <http://truffleframework.com/docs/advanced/configuration>
      // for more about customizing your Truffle configuration!
      networks: {
        development: {
          host: "127.0.0.1",
          port: 8545,
          network_id: "*" // Match any network id
        }
      }
};

Deploy file:
var CredentialOrgFactory = artifacts.require("CredentialOrgFactory");
var CredentialFactory = artifacts.require("CredentialFactory");
var ApplicantFactory = artifacts.require("ApplicantFactory");
module.exports = async function(deployer) {
    let aInst, bInst;

    await Promise.all([
      deployer.deploy(CredentialOrgFactory),
      deployer.deploy(CredentialFactory)
    ]);

    instances = await Promise.all([
        CredentialOrgFactory.deployed(),
        CredentialFactory.deployed()
    ])

    aInst = instances[0];
    bInst = instances[1];

    results = await Promise.all([
      bInst.setAddress(aInst.address)
    ]);


texts: Deploy smart contract to mainnet with Infura and MetaMask

texts:
I am trying to deploy my smart contract to the main net using the following code:

truffle.js:

module.exports = {
  networks: {
    live: {
      provider: new HDWalletProvider("mnemonic from metamask", "https://mainnet.infura.io/<infuraKey>"),
      network_id: 1, // Main net
    }
  }
};

However, when executing truffle migrate --network live, I get the following error:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
insufficient funds for gas * price + value

Anyone an idea what causes this error?
On the account I use on MetaMask I have 1ETH for deployment.
I also tried to add a gas amount to the live network, but this did not solve the problem.


texts: In MetaMask, I have my seed phrase but I didn't export my private keys. How do I recover my wallet?

texts:
So, I've been using MetaMask to try app.compound.finance and everything went well. I've deposited a small sum and connected the app to the wallet. But a few weeks later I decided to deleted the chrome extension fearing any type of security threat as I am spending a lot of time in the internet.

But, to my surprise, deleting the extension and using the seed phrase to recover the account did not bring back the wallet I used for Compound Finance. I can still see that my address has the money I left there. But I just don't have access to this wallet anymore like I used to.

I've contacted MetaMask support e-mail for assistance over how to get access to the wallet back using my seed phrase. But they are taking a bit longer than expected to respond the emails. In other wallets, and other crypto projects, all you need is your seed phrase and you would be safe losing your password, your mobile deviced used for 2FA, and any other security resource. For this, I have only exported my seed phrase and not all the private keys for each wallet inside MetaMask.

But I was caught off guard with MetaMask. I thought having a seed phrase is everything I would need to get it back. Apparently it wasn't and I was looking for anyone who went through the same problem in order to figure out how they proceded.


texts: How off-chain Tx reduce the cost and problems?

texts:
X and Y locked up 1 ETH each on-chain.

Balance: X (1 ETH) & Y (1 ETH).

X signed off-chain Tx sending 0.1 ETH to Y.

Balance: X (0.9) & Y (1.1).

X signed off-chain Tx sending 0.2 ETH to Y.

Balance: X (0.7) & Y (1.3).

Y signed off-chain Tx sending 0.5 ETH to X.

Balance: X (1.2) & Y (0.8).

Now, if we send all 3 of above off-chain tx on blockchain, it will consume similar gas as if we had send them at the time of signing the tx. How does it reduce the cost?

And if X and Y are signing a new balance status of both the party everytime then what prevents them from uploading the previously off-chain transaction (which doesn't reflect the actual balance) to blockchain?

What if I signed an off-chain with nonce 102 and then make an seperate on-chain transaction with nonce 102? The off-chain signed tx will become obsolete because same nonce tx are consider invalid.

Please clarify.


texts: Truffle migrate stuck at first migration

texts:
i am running a private Quorum node, which is basically normal ethereum node, via geth.

Then i tried to do deploy contract using migrate from truffle. but it got stuck here :

Running migration: 1_initial_migration.js
  Replacing Migrations...
  ... 0xbe63f4d73fa716a96b3e91792b24e789598978c7e93f396f0898e27dfb651c2a

this is my geth "command" :
qgeth --rpc --rpcport 22000 (qgeth is justan alias for quorum geth)

and this is the output of the terminal i am running the geth on

NFO [03-05|16:55:51] Starting peer-to-peer node               instance=Geth/v1.7.2-stable-df4267a2/linux-amd64/go1.10
INFO [03-05|16:55:51] Allocated cache and file handles         database=/home/user/.ethereum/geth/chaindata cache=128 handles=1024
INFO [03-05|16:55:51] Initialised chain configuration          config="{ChainID: <nil> Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: <nil> EIP158: <nil> Byzantium: <nil> IsQuorum: true Engine: unknown}"
INFO [03-05|16:55:51] Disk storage enabled for ethash caches   dir=/home/user/.ethereum/geth/ethash count=3
INFO [03-05|16:55:51] Disk storage enabled for ethash DAGs     dir=/home/user/.ethash               count=2
INFO [03-05|16:55:51] Initialising Ethereum protocol           versions="[63 62]" network=1
INFO [03-05|16:55:51] Loaded most recent local header          number=0 hash=9ff7ff…ad72b2 td=0
INFO [03-05|16:55:51] Loaded most recent local full block      number=0 hash=9ff7ff…ad72b2 td=0
INFO [03-05|16:55:51] Loaded most recent local fast block      number=0 hash=9ff7ff…ad72b2 td=0
WARN [03-05|16:55:51] Failed to journal local transaction      err="no active journal"
WARN [03-05|16:55:51] Failed to journal local transaction      err="no active journal"
INFO [03-05|16:55:51] Loaded local transaction journal         transactions=2 dropped=0
INFO [03-05|16:55:51] Regenerated local transaction journal    transactions=2 accounts=1
INFO [03-05|16:55:51] Starting P2P networking
INFO [03-05|16:55:53] UDP listener up                          self=enode://5f7a8e81143054d8aecdfcc6a93b6d2d2a8fe0300a48a35af6dadab6cf364da9a5ea0e2dc8b75239f01a9e1cea22f6529a8308cdf447adaa2fe4e674aa3c580c@[::]:30303
INFO [03-05|16:55:53] RLPx listener up                         self=enode://5f7a8e81143054d8aecdfcc6a93b6d2d2a8fe0300a48a35af6dadab6cf364da9a5ea0e2dc8b75239f01a9e1cea22f6529a8308cdf447adaa2fe4e674aa3c580c@[::]:30303
INFO [03-05|16:55:53] IPC endpoint opened: /home/user/.ethereum/geth.ipc
INFO [03-05|16:55:53] HTTP endpoint opened: http://127.0.0.1:22000
INFO [03-05|17:00:01] Submitted contract creation              fullhash=0x78b4cf12fc34b32ea4d174fa2bb4d8fba5e4c018722105eb5453fc8fc0979776 to=0xA8879FfBe2f4bAea1b37D00Bb2EFF38629B94EF4
INFO [03-05|17:01:21] Submitted contract creation              fullhash=0x24f4ea4dd9f3a41bfd019381c2d630fa63a9f365615397932bf9db5c450c4c22 to=0x18EBcB24F6074147DF24C39df3b833288b0e686b
INFO [03-05|17:01:46] Submitted contract creation              fullhash=0xbe63f4d73fa716a96b3e91792b24e789598978c7e93f396f0898e27dfb651c2a to=0x7D8e4ea6319e950c5400A60ab18f305bAcAA2F12
WARN [03-05|17:06:30] System clock seems off by -72h0m7.633984816s, which can prevent network connectivity
WARN [03-05|17:06:30] Please enable network time synchronisation in system settings.

Why would this happen ?


texts: mapping with struct array, gas or performance issue?

texts:
I have a question regarding iterating a mapping with struct array. There is a for loop that iterates over a few thousands times trying to find a matching properties inside the struct.

Ex:

struct MatchBettingInfo {
    address better;
    uint matchId;
    uint homeScore;
    uint awayScore;
}

mapping(uint => MatchBettingInfo[]) public matchBettingInfo;

function claimPrizes(uint _matchId, uint _homeScore, uint _awayScore) public returns (bool) {
    uint totalNumBetters = matchBettingInfo[_matchId].length;

    // Find matching scores among betters who betted for this match
    for (uint i = 0; i < totalNumBetters; i++) {
        if (matchBettingInfo[_matchId][i].homeScore == _homeScore &&
            matchBettingInfo[_matchId][i].awayScore == _awayScore) {
            numOfWinners++;
        }
    }

    ... more codes
}

This iteration is not inside a view nor constant function. So it takes up some gas while calling it. I'm just worrying the function could be running out of gas if the loop iterates over a huge numbers (over ten thousands?)

Are there any suggestions in terms of optimization?


texts: How can i setup a web3 webservice that listens for events from my smart contract?

texts:
I have a smart contract that broadcasts events to web3 clients, upon each event being broadcast, the listening client makes a tx call to my contract.

I would like to set up an 'always on' event listener - so some sort of web service and all it does is listen for events being broadcast from my smart contract and make tx calls. This way the browser would not have to be open to fire off tx to my contract when it 'hears' an event.

In my mind, obviously this webservice would need to have its own local node running, and have a coinbase with enough funds in it to run the tx.

How could I accomplish this scenario?

Basically, I need a web3 file to always be listening - with no one visiting the actual page in browser that has the js listeners.

Is this achievable? Would something like nodejs be able to do this?

Please help it is crucial to my smart contract application.


texts:
For some reason solidity doesn't allow to push values into memory array

  Member "push" is not available in bytes32[] memory outside of
  storage.

Here is sample contract code:

pragma solidity ^0.4.21;

contract Foo {
    function getRange(uint n) public pure returns(uint[]) {
        uint[] memory result;
        for (uint i = 0; i < n; i++)
            if (someCondition(i))
               result.push(i);
        return result;
    }
}

I could allocate maximum possible array of size n and then shrink it, but it may hurt performance (n could be in order of magnitude of 100000 while final length of result is 0..100). For example, someCondition could be isPrime. In this case we have large N (which makes impossible to preallocate an array) and small list of resulting prime numbers.

How could it be done?

I ended up with preallicating array of size n and then shrinking it once I know it's final length:

function getRange(uint n) public pure returns(uint[]) {
    uint tookCount = 0;
    uint[] memory result = new uint[](n);
    for (uint i = 0; i < n; i++)
        if (someCondition(i)) {
            result.push(i);
            tookCount++;
        }

    uint[] memory trimmedResult = new uint[](tookCount);
    for (uint j = 0; j < trimmedResult.length; j++) {
        trimmedResult[j] = result[j];
    }
    return trimmedResult;
}


texts: Problem with ether mining, stuck in DAG generation loop

texts:
i am completely new to ether mining, recently attempted to mine some ether using my desktop.
I came across a comprehensive guide from this link: https://www.cryptocompare.com/mining/guides/how-to-mine-ethereum/ and i followed every step mentioned. Everything was going smoothly. However, after the block got synchronised, i ran the ethminer -G command, DAG generation keep repeating (when it reaches 100%, it restarted from 0% again).
Has anyone encountered problems like this and how do you go about solving it? Appreciate all your help and thanks


texts: I'll never reach final block updating with geth, it's too slow

texts:
I´m updating my ethereum blockchain with geth. But I feel it is going really slowly.

Each block is done in 1 minute, sometimes 30 seconds, but at this pace I'll never reach the final block, because every 17 seconds there is a new block.

Basically blocks are generating at a higher speed than my geth. I'll never finish. Am I doing something wrong? Or probably is my perception and I'm going fine?

It may be a network problem, a processor problem, any tip would help.

Thanks in advance.


texts: Some info of contract when price of something reach some level

texts:
I'm total newbie. Let's assume I want to create a contract that sell BTC when price reach 20.000$ for example, how can I do that? How smart contract check the price? How many times? I don't understand how smart contract can see the price of BTC and how many times check it.

Thank you


texts: How does the token get onto this contract address?

texts:
So I was looking at the source code for the Fucktoken ICO. This is the smart contract account code, but I was wondering; how does the owner get the Fucktokens on the account/contract, and how can he control the actual contract once it's running, this one specifically.

pragma solidity ^0.4.11;

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

contract Crowdsale {
address public beneficiary;
uint public fundingGoal; uint public amountRaised; uint public deadline; uint public price;
token public tokenReward;
mapping(address => uint256) public balanceOf;
bool fundingGoalReached = false;
event GoalReached(address beneficiary, uint amountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);
bool crowdsaleClosed = false;

/* Data structure to hold information about campaign contributors */

/*  At initialization, setup the owner */
function Crowdsale(
    address ifSuccessfulSendTo,
    uint fundingGoalInEthers,
    uint durationInMinutes,
    uint weiCostOfEachToken,
    token addressOfTokenUsedAsReward
) {
    beneficiary = ifSuccessfulSendTo;
    fundingGoal = fundingGoalInEthers * 1 ether;
    deadline = now + durationInMinutes * 1 minutes;
    price = weiCostOfEachToken * 1 wei;
    tokenReward = token(addressOfTokenUsedAsReward);
}

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

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

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

function safeWithdrawal() afterDeadline {
    if (!fundingGoalReached) {
        uint amount = balanceOf[msg.sender];
        balanceOf[msg.sender] = 0;
        if (amount > 0) {
            if (msg.sender.send(amount)) {
                FundTransfer(msg.sender, amount, false);
            } else {
                balanceOf[msg.sender] = amount;
            }
        }
    }

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

}


texts: Error from Remix: "ParserError: Expected primary expression"

texts:
This is my code:

pragma solidity>0.4.99<0.6.0;

contract Election {

struct Candidate {
    string name;
    uint voteCount;
}

struct Voter {
    bool authorized;
    bool voted;
    uint vote;
}

address public owner;
string public electionName;

mapping(address => Voter) public voters;
Candidate[] public candidates;
uint public totalVotes;

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

function Election(string _name) public {
    owner = msg.sender;
    electionName = _name;
}

function addCanditate(string _name) ownerOnly public {
    candidates.push(Candidate(_name, 0));
}

function getNameCandidate() public view returns(uint){
    returns Candidate.length;
}

function authorize (address _person) ownerOnly public {
    voters[_person].authorized = true;
}

function vote (uint _voteIndex) public {
    require(!voters[msg.sender].voted);
    require(voters[msg.sender].authorized);

    voters[msg.sender].vote = _voteIndex;
    voters[msg.sender].voted = true;

    Candidates[_voteIndex].voteCount += 1;
    totalVotes += 1;
}
function end() ownerOnly public {
    selfdestruct(owner);
}

}

I am facing a problem here:

function getNameCandidate() public view returns(uint){
    returns Candidate.length;
}

it's showing me this error:

browser/Test.sol:38:5: ParserError: Expected primary expression.
    returns Candidate.length;
    ^-----^

How do I solve this problem? Thanks in advance.


texts:
I'm quite aware of the standard way to approve and transferFrom standard ERC20 tokens from a user to a contract but the process does not seem the same with ERC677. The approval is the same but then I see a transferAndCall function which requires three inputs.
function transferAndCall(address to, uint value, bytes data) returns (bool success);

I have no idea what to put in for the bytes data data and can't seem to find any online resources. So, how do I initate and transfer ERC677 formatted tokens to a contract, from within that contract, from a user. For that matter, if you have advice for ERC277, that would be greatly appreciated as well.


texts:
For the past 7 days I've been trying to make the greeter contract, I've been through 4 different physical computers in 2 different locations and have tried multiple different ways on 3 different operating systems.

I've attempted all the tries above with both the geth and c++ eth client, I've also made attempts with the online web compiler and mix.

After 7 days, I have not been able to create any contract yet, I'm attempting to follow the https://www.ethereum.org/greeter page so I can move onto the other tutorial exercises to complete the exercises on the ethereum.org page.

I'm following the page instructions verbatim line-by-line and directly copying what it tells me to copy, and I've managed to get as far as compiling the contract and telling it to deploy. It asks me for my account password and I enter it which it then completes. My account does have ethereum in it.

But the problem is the instructions say the greeter variable is suppose to contain an address you can track on the network as its being mined or completed and it does contain an address but the address is undefined, it remains undefined indefinitely. Also my account is never deducted any currency, the account value remains the same. Of course this means

eth.getCode(greeter.address)

Also errors out as it can't get a code to an undefined address. This baffles me and so far I haven't been able to find any help anywhere on this. I just assumed it was a software bug and that probably not very many people have created contracts but then I saw a ethereum youtube video saying there were like 500,000 contracts and it seems the community is very vibrant with contract design so what could I possibly be missing thats causing this error.

In case your wondering, my latest attempt is on Mac OSX with the geth client but I have access to Windows and Linux as well as the c++ eth client if need be.


texts:
On https://theethereum.wiki/w/index.php/ERC20_Token_Standard there is a function which goes as follows: -

  // Owner can transfer out any accidentally sent ERC20 tokens

function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
       return ERC20Interface(tokenAddress).transfer(owner, tokens);
}

My reading that if this is called then the owner will receive the ERC20 tokens in the contract address - is this correct?


texts: Retrieve the value returned by a function which was invoked with 'transact'

texts:
I am using Python web3 in order to deploy and test a Solidity contract.

Here are my initial steps:

from web3 import Web3
from web3 import RPCProvider
from json import loads

eth = Web3(RPCProvider()).eth
abi = open(ABI_FILE_NAME).read()
bin = open(BIN_FILE_NAME).read()
transaction = {'from':eth.accounts[0]}

contract = eth.contract(abi=loads(abi),bytecode=bin)
tx_hash  = contract.deploy(transaction=transaction)
address  = eth.getTransactionReceipt(tx_hash)['contractAddress']
handle   = contract(address).transact(transaction)

At this point, I invoke a function in the contract:

tx_hash = handle.some_func()

And this is what I get when I call eth.getTransactionReceipt(tx_hash):

{
    'transactionHash'   : '0x...',
    'transactionIndex'  : 0,
    'blockHash'         : '0x...',
    'blockNumber'       : 3710,
    'gasUsed'           : 72597,
    'cumulativeGasUsed' : 72597,
    'contractAddress'   : None,
    'logs'              : [],
    'status'            : 1
}

How can I retrieve the actual value that some_func has returned?

I found a very detailed answer which seems to refer to this issue, but I have not been able to conclude the actual steps required.

Thank you.


texts: How large are the Ethereum block headers?

texts: I am interested in knowing the block header size to estimate the overhead of running an Ethereum light client.


texts: How to see event name in etherscan.io transaction event log?

texts:
In etherscan.io, I want to be able to see the event name (signature) in the transaction page event log, like here.
Currently, I don't see it here.

I'll note that the transaction is indeed sent to a verified contract, etc.
Is it possible this is a feature enabled only on mainnet?

Edit: I do see an event signature in Ropsten, for example here.
So I'm interested to know the difference between the two occurrences...


texts:
I have a really strange problem. When I deploy a contract in JavaScriptVM using Remix including the following function:

function setLoanStatus(address _loan, bytes1 _newStatus) public {
    // "A" = 0x41 / "I" = 0x49 / "S" = 0x53
    var check = (_newStatus == 0x41 || _newStatus == 0x49 || _newStatus == 0x53);
    if (check)
        {
        // Only update status if it is a valid value
        loanStatusList[_loan] = _newStatus;
        } // if (check)

} // function setLoanStatus(address _loan, bytes1 _newStatus) public {

the contract appears to deploy, but if I try to look at any value I get the message:

error: Failed to decode output: TypeError: Cannot read property 'length' of undefined

If I change the visibility to internal it will deploy properly AND if I deploy the contract with original function in Injected Web3 it works properly. I am using the Ropsten testnet.

Any ideas why this behavior is happening?


texts:
I am syncing the ETH blockchain on a VPS with a 1TB hard drive/  It has taken a week so far and progress is now going at a snail's pace.  It seems like it's never going to finish.

I'm also syncing on another VPS (also HDD) with the --fast option and it's taking just as long.

Is this normal?  More than a week sync time and no end in sight?


texts: Syncing slow to a crawl (2048 blocks in 2 hours)

texts:
I had no issues before, but my syncing has gotten incredibly slow with geth. My system time and date are good (set by ntp) so that shouldn't be the issue and my Internet connexion works fine.

It took 2 hours to get 2048 blocks. Even the highest block parameter is wrong! (as of now, etherchain.org reports that the highest block is 1953411) What gives?

  I0725 18:40:30.199394 core/blockchain.go:972] imported 2048 block(s) (0 queued 0 ignored) including 13408 txs in 2h8m18.691083833s. #1888377 [6328a321 / 2ab5bd5c]

  eth.syncing
  {
    currentBlock: 1889280,
    highestBlock: 1947463,
    knownStates: 0,
    pulledStates: 0,
    startingBlock: 1849273
  }

Any idea on how to troubleshoot this, or avoid the issue?

EDIT: running with 1.5.0 seems to be the problem. Downgrading to 1.4.10 fixed the issue


texts: Set curator of split in case of the 17 June 2016 attack

texts:
When creating a proposal for a split, the recipient is the new curator.

splitDAO() has 2 arguments :

proposalID: The proposal ID.
newCurator: The address of the new Curator of
the new DAO.

As I understand, anyone can join an existing split, and then call the splitDAO() function with himself as newCurator.

The questions are :

If I set myself as the curator in the proposal, others people who wanted to join the split will also have to call splitDAO() with the same curator address, or another one ?
Vitalik said they are in touch with the proposal #59 curator, so the attacker did not split with himself as curator ?

Thank you


texts: Gas requirement of a function: unknown or not constant

texts:
This is a function in my contract. There is noting complex about this it shows a warning that the gas requirement is large on remix. I speculate this might be a reason why I had gas issues while trying to deploy using truffle.
First of all I need to understand the issue.
function sendEther(string data) payable {
  address sender = msg.sender;
  uint value = msg.value;
  voter[sender].data = data;
  voter[sender].amount = value;
  voterIndex[voter_count] = sender;
  voter_count = voter_count + 1;
  Deposit(sender, value);
}

Note: I found a similar issue where the user was trying to send a transaction which could be a normal address or a contract and thus had the issue. No idea why it happens to me.
EDIT: The constant keyword was a typos. But the actual question was answered precisely below.


texts: Cannot deploy contract on private network with truffle: gas required exceeds allowance or always failing transaction

texts:
I'm writing a contract based on the ring mixer contract from here https://ropsten.etherscan.io/address/0x5e10d764314040b04ac7d96610b9851c8bc02815

I've tested it with ganache. Everything worked fine until I tried to deploy it on my private network. Truffle gave me the following error:

  "RingMixerV2" received a generic error from Geth that
  can be caused by hitting revert in a contract constructor or running out of gas.
     * Returned error: gas required exceeds allowance or always failing transaction.
     * Try: + using the '--dry-run' option to reproduce this failure with clearer errors.
            + verifying that your gas is adequate for this deployment.`

I've cut down the codes as below but there's no luck. I was able to deploy it on Ropsten with Remix so I don't know what is wrong. I'm using truffle v5.0.2.

pragma solidity >0.4.99 <0.6.0;

contract RingMixerV2 {
    //Debug Code
    address public owner;
    constructor() public {
        //Debug Code
        owner = msg.sender;

        G1[0] = 1;
        G1[1] = 2;
        H = HashPoint(G1);
    }

    function Kill() public {
        if ( (msg.sender != owner) && (owner != address(0)) ) revert();

        selfdestruct(msg.sender);
    }

    //alt_bn128 constants
    uint256[2] public G1;
    uint256[2] public H;
    uint256 constant public N = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001;
    uint256 constant public P = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47;

    //Used for Point Compression/Decompression
    uint256 constant public ECSignMask = 0x8000000000000000000000000000000000000000000000000000000000000000;
    uint256 constant public a = 0xc19139cb84c680a6e14116da060561765e05aa45a1c72a34f082305b61f3f52; // (p+1)/4

    //Storage of Spent Key Images
    mapping (uint256 => bool) public KeyImageUsed;

    //Storage of Token Balances
    mapping (address => uint256) public token_balance;

    //Convenience tables for looking up acceptable mix-in keys
    mapping (uint256 => uint256[]) public lookup_pubkey_by_balance;
    mapping (uint256 => bool) public lookup_pubkey_by_balance_populated;
    mapping (uint256 => uint256) public lookup_pubkey_by_balance_count;

    function EvaluateCurve(uint256 x)
        public view returns (uint256 y, bool onCurve)
    {
        uint256 y_squared = mulmod(x,x, P);
        y_squared = mulmod(y_squared, x, P);
        y_squared = addmod(y_squared, 3, P);

        uint256 p_local = P;
        uint256 a_local = a;

        assembly {
            //Get Free Memory Pointer
            let p := mload(0x40)

            //Store Data for Big Int Mod Exp Call
            mstore(p, 0x20)                 //Length of Base
            mstore(add(p, 0x20), 0x20)      //Length of Exponent
            mstore(add(p, 0x40), 0x20)      //Length of Modulus
            mstore(add(p, 0x60), y_squared) //Base
            mstore(add(p, 0x80), a_local)   //Exponent
            mstore(add(p, 0xA0), p_local)   //Modulus

            //Call Big Int Mod Exp
            let success := staticcall(sub(gas, 2000), 0x05, p, 0xC0, p, 0x20)

            // Use "invalid" to make gas estimation work
            //switch success case 0 { revert(p, 0xC0) }
            switch success case 0 { invalid()}

            //Store Return Data
            y := mload(p)
        }

        //Check Answer
        onCurve = (y_squared == mulmod(y, y, P));
    }

    //Return H = alt_bn128 evaluated at keccak256(p)
    function HashPoint(uint256[2] memory p)
        internal view returns (uint256[2] memory h)
    {
        bool onCurve;
        h[0] = uint256(keccak256(abi.encodePacked(p[0], p[1]))) % N;

        while(!onCurve) {
            (h[1], onCurve) = EvaluateCurve(h[0]);
            h[0]++;
        }
        h[0]--;
    }

}

Any help would be appreciated.


texts:
From the docs

  The version pragma is used as follows:

pragma solidity ^0.4.0;

  Such a source file will not compile with a compiler earlier than version 0.4.0 and it will also not work on a compiler starting from version 0.5.0 (this second condition is added by using ^).

Then what happens if we have two files: A.sol and B.sol where A.sol is declaring pragma ^0.4.15 and at the same time imports B.sol which declares pragma ^0.4.0? How the compiler manages this mismatch?


texts: What's the difference between 'msg.sender' and 'tx.origin'?

texts:
If either are used in the body of a Solidity function that may change the state of a contract (write call), what's the primary difference and/or benefit of using one over the other.  For example:

   function setOwner() {
      owner = msg.sender;
   }

vs.

   function setOwner() {
      owner = tx.origin;
   }

What's the difference?


texts:
This is the first time using infura with a Web3j HttpClient. I have seen people use a code after the url like this: "infura.io/--here--". Am I using Infura correctly?

This is my code. (web3j v3.5.0)

Web3j web3 = Web3j.build(new HttpService("https://rinkeby.infura.io/"));
Web3ClientVersion web3ClientVersion = null;

try {
    web3ClientVersion = web3.web3ClientVersion().send();
} catch(IOException e) {
    e.printStackTrace();
}

String web3ClientVersionString = web3ClientVersion.getWeb3ClientVersion();
System.out.println("Web3 client version: " + web3ClientVersionString);


texts: How to find a specific event if it has no indexed params

texts:
I understand that I can filter for logs with indexed events like so:
event Transfer(address indexed src, address indexed dst, uint wad);

whereby, I can search for all Transfer events with src=anAddress etc.
How can I find specific events that DO NOT have any indexed params, like so:
event Mint(address minter, uint mintAmount, uint mintTokens);

I know that each event will have topic0 hardcoded to its function signature but is there a way to find all Mint events where minter=anAddress without crawling through all events matching the mint function signature on RPC?
Cheers


texts: Do the different ethereum clients (geth, parity, etc) behave as equal peers to one another?

texts:
Do clients differentiate their peers based upon what language they are implemented in or do they all work together without discrimination?

For example does a geth node seek out other geth nodes? ...or will it just as easily use a parity node to sync with?

If it doesn’t discriminate, are the nodes even aware of what the peer client is written in?  Or from that level of interaction are they “blind” to that info?


texts: What is the well accepted and active Ruby library for Ethereum? This article  lists quite a few libraries but none of them seems to be actively maintained. I am looking for an Ruby library for my Ethereum Dapp with Ruby on Rails as web framework and MetaMaks as browser extension.


texts: How problematic is transitioning Augur's full-Serpent smart contract suite?

texts: I read here that Augur's smart contract suite is actually written in Serpent. I'm aware that it is a relatively well supported language at the moment (at least compared to Mutan and LLL), but given that Solidity is thought to overtake all other languages at some point in the future, how problematic is the transition between the two languages likely to be for a platform like Augur?


texts: Difference in cost between external contract as state variable vs. instantiation of contract?

texts:
For
pragma solidity ^0.6.0;

interface ExternalContract {
    function initialize() external;
}

contract Test {
  ExternalContract c;

  constructor(address externalContractAddress) public {
      c = ExternalContract(externalContractAddress);
  }

  function testA() public {
    c.initialize();
  }

  function testB(address externalContractAddress) public {
    ExternalContract(externalContractAddress).initialize();
  }
}

Is there a preferred option in terms of cost between testA and testB? I can see that B allows you to save on a state variable, but don't know whether on the spot instantiation is somehow more expensive.


texts: Archival node from a certain block or for certain addresses

texts: does anybody know if it's possible to run archival from a certain block or only for transactions interacting with a list of contracts? I recently deployed some contracts for which I want to run graph node and I would like to save some resources by not having to keep all the archival data. Thanks


texts: How can you call a payable function in another contract with arguments and send funds?

texts:
I have a contract named Call:

contract Call {
  ...
  function () payable {
    // TODO: Call the call function in the main contract
    // and forward all funds (msg.value) sent to this contract
    // and passing in the following data: msg.sender
  }
}

Here is the Main contract:

contract Main {
  ...
  function call(address senderAddress) public {
    // Make the code in here run when someone sends ethers to the Call contract
  }
}

So, I want to have it so that whenever someone sends ethers the Call contract, it forwards all the ethers to the Main contract while running the call function in the Main contract with the necessary arguments.

Can this be done?


texts: Oraclize a restfullAPI using a specific number represented by the variable z

texts:
Hello I made a restfull API on my own (python file jsonify + localtunnel) on a localhost using a specific number (in this case 141) represented by the variable z. This variable should go into DevCoin function balances[msg.sender] and should be displayed on localhost:8080 as: You have 141 DVC. For this purpose I use ganache-cli (Listening on 127.0.0.1:8545) , ethereum-bridge(node bridge -a 9 -H 127.0.0.1 -p 8545 --dev) as well as truffle.js (8545). Using: truffle compile, truffle migrate --development --reset and npm run dev leading to no error. The problem is now, when I connect the index.html(where my variable should be displayed) with a private network on metamask on localhost:8545, I got: You have 0 DVC. I don't know why. If I pass instead of z a number, the chosen number is displayed. Have anyone any idea to help me out?enter image description here
Truffle console:

App.js

truffle.js

2_deploy_contracts.js

index.html


texts: How can I get the value of an account created in mocha test?

texts:
I am new to ethereum and am using truffle and mocha for development. I am writing an app that is sending ethereum to a contract. The ether stored in the contract is then used later.

I have a function that creates a ticket by calling to a seperate contract: TicketAccount (which holds all the tickets in an account).

function createTicket(bytes32 _name, uint _cost) public payable returns(address ticket) {
    var setBalance = _cost * 2;
    var ticketAddress = accounts[msg.sender].createTicket.value(setBalance)(_name, _cost);
    return ticketAddress;
  }

I am referring to the docs here
This is the function it is calling to. A user must have registered an account to be considered an owner.

function createTicket(bytes32 _name, uint _cost) public payable isOwner() returns (address ticketTransaction) {
    // ... code here
  }

I am writing a mocha test where service is my original contract where the createTicket can be called from.

it("should create ticket", function() {

    var newTicket = service.createTicket.value(20)("Ticket Name", 20);
    return newTicket.then(function(newTicket) {
      assert.isOk(newTicket);
    });
  });

This is the error that the test is giving

TypeError: service.createTicket.value is not a function

UPDATE: I have also tried this method to no avail. This gives me the dreaded invalid opcode

var newTicket = service.createTicket.sendTransaction("Ticket Name", 20, {from: accountOne, value: 40});


texts: How to stop listening to all events of contract

texts:
I am using the JavaScript API in my truffle tests to get the events from the contract:
https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-allevents

          const allEvents = instance.allEvents({
            fromBlock: 0,
            toBlock: 'latest'
          });
          allEvents.watch((err, res) => {
            console.log(res);
          });

It never stops listening so I tried adding this to the end:

          allEvents.stopWatching()

The listening stops, but nothing is ever logged, so I tried adding a delay:

          setTimeout(allEvents.stopWatching, 1000);

But the listening doesn't stop.

How do I stop listening after all the events emitted till now have been retrieved?


texts: Fungible tokens owned by non-fungible tokens

texts:
I'm quite a Noob when it comes to smart contracts, and I'm trying to design a market place.
I will tokenise existing real world assets into ERC 721 tokens. The owner of each ERC721 will be eligible to mint x-amount of ERC-20 tokens, depending on it's unique characteristics.
Does that sound sensible, or does any part of that sound unreasonable?
It might make sense for the 721 to own the erc-20s initially - is that possible, does it have to be the owner of the 721, or is there a better way?
Are there similar use-cases out there already that I can look at?


texts:
When I run these two contracts, I first deploy habibconcert and then changer. When I call displayTickets_numbers, the IDE crashes.

Here is the contract source code:

pragma solidity ^0.4.0;

contract changer{

       habibconcert firstObject =    habibconcert(0x692a70d2e424a56d2c6c27aa97d1a86395877b3a);

       interfacer public changers;

      function changeTickets(uint new_tickets)  {

       //   changers = interfacer();

          changers.changeTickets_numberTicket(new_tickets);

        //  firstObject.tickets = new_tickets;
        //   uint updateTickets =  firstObject.tickets  = firstObject.tickets + new_tickets;
        //   return ( updateTickets);
  }

    function displayTickets_numbers()constant returns(uint){

               return displayTickets_numbers();
    }

    }

interface interfacer{

    function changeTickets_numberTicket(uint new_tickets);

    function displayTickets_numbers() constant returns(uint);

}

contract habibconcert{

      uint  public tickets = 6;

      address owner_of_tickets;

      uint constant price = 1 ether;

       mapping(address=>uint) public purchasers;

      function habibconcert()payable{

            owner_of_tickets =  msg.sender;
      }

                function  displayTickets_numbers()constant returns(uint){

                    return tickets;

                }

              function changeTickets_numberTicket (uint newtickets) {

                         tickets +=newtickets;

                   }

        modifier ownLycreature(){

            require(msg.sender ==  owner_of_tickets) ;

            //   && tickets == 0
            _;

            }

               function changeTickets_number (uint newtickets) ownLycreature{

                         tickets +=newtickets;

                   }

    function buytickets(uint amount)payable{

          if(msg.value!=(amount*price) || amount>tickets){

              throw;
          }

          purchasers[msg.sender] +=amount;

          tickets -=amount;

        // if(tickets == 0){

        //     //selfdestruct(owner_of_tickets);

        // }

    }

}


texts: How can you tell if a mined transaction made permanent changes?

texts: I have set up a private ethereum blockchain and I have defined a new coin. When I send coins from one account to another through the smart contract the transaction is always mined even when the coins are not moved. Is there a way to use the blockchain data to verify if a transaction made permanent changes or not?


texts: What is the cheapest and most efficient way to send data to a struct, and why?

texts:
I'm struggling to find which way to send data to a struct is cheaper and most efficient. I came up with these 2 different styles:

struct Database
{
   string name;
   string addressPerson;
}

mapping (string => Database) idToDatabase;

function setPerson(string _id, string _name, string _address) external {
   Database storage person = idToDatabase[_id];
   person.name = _name;
   person.addressPerson = _address;
}

and

struct Database
{
   string name;
   string addressPerson;
}

Database[] public people;

mapping (string => uint) idToPerson;

function setPerson(string _id, string _name, string _address) external {
   people.push(Database(_name,_address));
   idToPerson[_id] = people.length-1;
}

Which should I use and why? I researched a lot and couldn't find an answer. Thank you.


texts: How to use solidity library with truffle

texts:
I'm using truffle V5.1.13 and when I run truffle test the res variable contains a transaction receipt rather than the expected 2. I notice if I remove everything that has to do with the library things work as expected.

Why is this happening? How can I use my library?

Contract code:

pragma solidity ^0.5.1;

library TestLib{
    struct DataSet {
        uint a;
    }

    function assign(DataSet storage self) internal {
        self.a = 2;
    }

    function getA(DataSet storage self) internal view returns(uint) {
        return self.a;
    }
}

contract TestContract {
    using TestLib for TestLib.DataSet;
    TestLib.DataSet set;

    function getBalanceInEth() public returns(uint) {
        set.assign();
        return set.getA();
    }
}

Test code:

    const TestContract = artifacts.require('TestContract')

    contract('TestContract', async accounts => {
        let TestContractInstance

        beforeEach('setup contract for each test', async function() {
           TestContractInstance = await TestContract.deployed()
        })

        it('Should return 2', async () => {
           let res = await TestContractInstance.getBalanceInEth()
           console.log(res)
           assert.equal(res, 2)
        })
    })

Migration Code:

const TestContract = artifacts.require('TestContract')
const TestLib = artifacts.require('TestLib')
module.exports = function(deployer) {
  deployer.deploy(TestLib)
  deployer.link(TestLib, TestContract)
  deployer.deploy(TestContract)
}

console.log(res) gives:

{
  tx: '0x1f05b5fa7ed635aaa619cc548a0a37ff9d9d57398d85ecb3f8000ed7e124373c',
  receipt: {
    transactionHash: '0x1f05b5fa7ed635aaa619cc548a0a37ff9d9d57398d85ecb3f8000ed7e124373c',
    transactionIndex: 0,
    blockHash: '0xe6bc488fce167970b781588d1c70c0b4a452834c78daf4f052c1a045575fd959',
    blockNumber: 3,
    from: '0x627306090abab3a6e1400e9345bc60c78a8bef57',
    to: '0xf12b5dd4ead5f743c6baa640b0216200e89b60da',
    gasUsed: 42158,
    cumulativeGasUsed: 42158,
    contractAddress: null,
    logs: [],
    status: true,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    rawLogs: []
  },
  logs: []
}


texts:
`pragma solidity ^0.6.6;

contract timeBound{

uint256 timeLocked = 1589026500;

event Transfer(address _from, address _to, uint256);

mapping(address => uint256) private balance;

modifier timeChecker{
    require(block.timestamp >= timeLocked, "ERC20: time locked for certain period");
    _;
}

function lockCall() public timeChecker {
    uint256 value = 10;
    address receiver = 0xDd395D13d892Fb482e5E7392e0f58BC4F55c9d69;

    require(msg.sender != address(0));

    balance[receiver] = balance[receiver] + value;
    emit Transfer(address(msg.sender), address(receiver), value);
}

//This balanceOf() function not returns the token balance of this contract
function balanceOf(address account) public view returns(uint256){
    return balance[account];
}

}`

in the above contract timeLocked variable is used for next 15 minutes, and require(block.timestamp >= timestamp) is checking, when i deployed it on ropsten testnet, the receiver gets tokens immediately before the desire time. how to counter this issue?

balanceOf function not returns the contract token balance but the contract has tokens which will transfer in the lockCall function to the given address.


texts: Can a contract copy itself? [Circular reference for contract creation (cannot create instance of derived or same contract)]

texts:
I've got a contract that I'd like to be able to create a copy of the same contract, then have the child be able to retrieve data from the parent.  When I try to compile the following, which is a simplified version of what I'm trying to make:

contract Example {

    uint256 num;
    address parent;

    function Example(uint256 _num, address _parent) {
        num = _num;
        parent = _parent;
    }

    function createChild() {
        uint256 childNum = num + 1;
        Example child = new Example(childNum, this);
    }

    function getNumber() constant returns (uint256) {
        return num;
    }

    function getParentNumber() constant returns (uint256) {
        Example e = Example(parent);
        return e.getNumber();
    }

}

...the solidity compiler understandably complains:

example.sol:15:25: Error: Circular reference for contract creation (cannot create instance of derived or same contract).
        Example child = new Example(childNum, this);

This matches what the docs say will happen: http://solidity.readthedocs.io/en/develop/contracts.html#multiple-inheritance-and-linearization

So it makes sense that I can't do it that way. But is there a (preferably clean) way to accomplish a contract creating a contract with the same code as itself, then call methods on it and get data back?


texts: Failed to load events from Block 0 on page refresh in Vue app

texts:
I'm trying to get event data from the web3 API using events method. In my Vue app methods, I have a method, newDsoValue, that will watch for the events from the beginning and also for every newly fired event.

The method works perfectly fine only for the first time (when I change something in the block of code and save).

But if I refresh the browser tab, it does not load past event instead it will only load new fired events.

The method I'm using to load event data is used to get events from smart contracts written in solidity and deployed on Ethereum blockchain. The API is web3:1.0.0-beta.37 to get the event data.

I already tried mounted hook but no luck.

I also tried clearing browser cache, using another browser but no luck.

If I manually call this method, using a button click, then it also works fine.

I used to log some value in the console just before and after the API call inside the method, the value is perfectly logged in the console on every page refresh. Only the past data is not loaded.

Inside my method, I'm pushing data into an array. From debugging, I came to know that array is loaded with events only first time and if I refresh the page, the array becomes empty.

This is the method:

newDsoValue() {
      AssetLoggingContract.events
        .RejectSetValue({
          fromBlock: 0
        })
        .on("data", event => {
          this.testEvents.push(event);
          console.log(this.testEvents.length);
        })
        .on("error", console.error);
    },

I'm calling this method inside the created as:

created() {
    this.newDsoValue();
  }

I want to run this method on page load and every time I refresh the page it should load all the previous events and also the newly fired events. any help to achieve this? thanks

GitHub repo


texts: Verifying ethereum message signatures with java

texts:
I am using web3j to verify message signatures but there are some false negative results.
For example this signature should be right, but it seems like the address could not be recovered:
     final String address = "0x638aF69053892CDD7Ad295fC2482d1a11Fe5a9B7";
     final String signature = "0x6c26935cc03e4e93c0bd1c3d068a54eb961bbc7db4ecf6c7b55b5b9bb073d32b61fcabeabd028322401ea62202726b520b84fd27aa7f8a8050dff728e064cebf1c";
     final String message = "5893";

    boolean isSignatureValid(final String address, final String signature, final String message) {
        log.info("isSignatureValid invoked for Address {} with Signature {} and Message {} ", address, signature,
                message);

        final String personalMessagePrefix = "\u0019Ethereum Signed Message:\n";
        boolean match = false;

        final String prefix = personalMessagePrefix + message.length();
        final byte[] msgHash = Hash.sha3((prefix + message).getBytes());
        final byte[] signatureBytes = Numeric.hexStringToByteArray(signature);
        byte v = signatureBytes[64];
        if (v < 27) {
            v += 27;
        }

        final SignatureData sd = new SignatureData(v,
                Arrays.copyOfRange(signatureBytes, 0, 32),
                Arrays.copyOfRange(signatureBytes, 32, 64));

        String addressRecovered = null;

        // Iterate for each possible key to recover
        for (int i = 0; i < 4; i++) {
            final BigInteger publicKey = Sign.recoverFromSignature((byte) i, new ECDSASignature(
                            new BigInteger(1, sd.getR()),
                            new BigInteger(1, sd.getS())), msgHash);

            if (publicKey != null) {
                addressRecovered = "0x" + Keys.getAddress(publicKey);

                if (addressRecovered.equals(address)) {
                    match = true;
                    break;
                }
            }
        }

        return match;
    }
}

I am still new in this area.


texts: trying to use web3-utils but not working

texts:
Trying to use web3-utils.

I installed the package via NPM , however, I am getting the error that sha3 is undefined..

TypeError: Cannot read property 'sha3' of undefined
    at C:\block2\deliver.js:12:28
    at Layer.handle [as handle_request] (C:\block2\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\block2\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\block2\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\block2\node_modules\express\lib\router\layer.js:95:5)
    at C:\block2\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\block2\node_modules\express\lib\router\index.js:335:12)
    at next (C:\block2\node_modules\express\lib\router\index.js:275:10)
    at expressInit (C:\block2\node_modules\express\lib\middleware\init.js:40:5)
    at Layer.handle [as handle_request] (C:\block2\node_modules\express\lib\router\layer.js:95:5)

CODE:

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

var util = require('web3-utils');

app.get('/endpoint', function(request, response) {
    var id = request.query.id;
    response.end(web3.utils.sha3('test'));
});

app.listen(3000, '127.0.0.1', function() {
    console.log('Listening to port:  ' + 3000);
});


texts: Drawbacks Query Logs of Parity Node in Fast Mode

texts:
We need to query all the past transfer events of a contract to identify all historic token holder addresses. Am I right that for this we need a full node and can't use fast mode?

I've read that fast mode prunes old blocks and querying past events seems to work like this using fromBlock=0. So I expect transfer events that wouldn't show up in the future using fast mode, right?

I just wanted this confirmed because hosting a full-node is quite a bit more expensive. Any ideas how to solve this without full node are welcome.


texts: Can't retrieve public array members with web3

texts:
I'm building a web interface for my dapp, but can't seem to retrieve individual struct items from a public array.

I'm trying to retrieve a Proposal struct from the proposals() public function in my contract (I have a Proposal[] public proposals; array).

So the user enters a particular proposalID and they should be returned the Proposal struct. The method works fine on Remix.

However, I'm getting this alert:

error BigNumber Error: new BigNumber() not a base 16 number

I've verified the ABI is correct when I initialize my JS myContract object.

What's causing this error? Here's the code that's resulting in an error:

            myContract.proposals(propID, function(error, result) {
                if(!error) {
                    alert("Result: " + result);
                } else {
                    alert("There was a problem: " + error);
                }
            });

All the other functions work (ie. myContract.owner etc).


texts: Need help signing a raw transaction with "ethereumjs-tx"

texts:
Here's a NodeJS script where I'm trying to send a raw transaction. I've tried changing params in a lot of different ways and always get the same error. What am I missing? I'm following an example from here.

Script:

const Web3 = require('web3');
const Tx = require('ethereumjs-tx');
const config = require('./config');

const web3 = new Web3(new Web3.providers.HttpProvider(config.provider));
web3.eth.defaultAccount = "0x15568faf1cd21041acbb9f99d94dbe40e7f1a479";

const rawTx = {
  nonce: '0x00',                                     // 0
  gasPrice: '0x6FC23AC00',                           //30 GWei | 30 000 000 000 wei
  gasLimit: '0xF4240',                               //1 000 000
  to: '0x203D17B4a1725E001426b7Ab3193E6657b0dBcc6',
  value: '0x00',                                     // 0
  data: '0x00',                                      // 0
  chainId: '0x03'                                    // Ropsten
}

const tx = new Tx(rawTx);
const privateKey = Buffer.from("f7ef8432857eb502f9406282b6cb86219ea4973f5f9bb0605099cfc2c63a516a", 'hex');
tx.sign(privateKey);

const serializedTx = tx.serialize();
console.log(serializedTx.toString('hex')); //f865808506fc23ac00830f424094203d17b4a1725e001426b7ab3193e6657b0dbcc680002aa070f37febb101867fe6b5abb4b4a0bf6daadba43736164a08cd0413c4b29d4e05a0204248c3e9a826cac72e7be29a8cacce924e33b36a0a7e7096f6a86684884f18

web3.eth.sendRawTransaction(serializedTx.toString('hex'), function(err, hash) {
    console.log('Error:', err);
    console.log('Hash:', hash);
});

Error:

Error: Error: Invalid params
    at Object.InvalidResponse (/home/manid/Рабочий стол/test/Ethereum/send-raw-transaction/node_modules/web3/lib/web3/errors.js:35:16)
    at /home/manid/Рабочий стол/test/Ethereum/send-raw-transaction/node_modules/web3/lib/web3/requestmanager.js:86:36
    at XMLHttpRequest.request.onreadystatechange (/home/manid/Рабочий стол/test/Ethereum/send-raw-transaction/node_modules/web3/lib/web3/httpprovider.js:118:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/manid/Рабочий стол/test/Ethereum/send-raw-transaction/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/home/manid/Рабочий стол/test/Ethereum/send-raw-transaction/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/home/manid/Рабочий стол/test/Ethereum/send-raw-transaction/node_modules/xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/home/manid/Рабочий стол/test/Ethereum/send-raw-transaction/node_modules/xhr2/lib/xhr2.js:469:24)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)

When I try to broadcast this transaction using etherscan.io/pushTx I get the following error

Error! Unable to broadcast Tx : {"jsonrpc":"2.0","error":{"code":-32010,"message":"Invalid network id.","data":null},"id":1}.

Is it possible that the problem might be in that I use a private key generated for mainnet and specify ropsten as the chainId? I used keythereum to generate keys. Is there a difference in key pair generation for mainnet and ropsten?

When I change chainId field to "0x01" I get an error:

Error! Unable to broadcast Tx : {"jsonrpc":"2.0","error":{"code":-32010,"message":"Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 30000000000000000 and got: 0.","data":null},"id":1}

This error makes sense, because this address has balance only on ropsten.


texts: Is there an app to read QR code of smartcontract bytecode and trigger it?

texts:
I want to know if there is a workaround for a smartphone user to simply scan a QR code that would trigger a transaction using a custom smartcontract (not a native currency). The contract would behave differently depending on who calls it.

This question tells me how to generate the QR : Can any information beside the address be encoded into QR code?

What I don't is what app to read it with. Any idea ? The simpler, the better.

*FYI if it helps : The use case is waste management in a railway station. What I want is that when a bin is taken out, the guy scan the QR code and it generate an amount of a type waste. Then when the truck comes, the guy scan it too and the kg are transferred to this contractor accounts (with multiple contractors who picks up wastes). I need it to be the same QR code.

I have made small contracts and tokens that transfer kg of different kind of waste between accounts. I also have the contract that behaves correctly depending on who calls it (generate waste, transfer). We already have the guys on the field scanning codes… it sends me SMS and I input the transaction manually :D !*


texts: Deploy contract to Parity dev chain using Remix

texts:
I'm trying to deploy a contract via remix to my local development chain. However, the transaction never gets mined and is pending forever. When I use a node script it works (at least I receive the contracts address).

I've started a local Parity dev chain with the following command:
parity --config dev-insecure --jsonrpc-apis=personal,net,eth,rpc,private,parity --jsonrpc-cors "https://remix.ethereum.org"

Then I unlock the account:
curl --data '{"method":"personal_unlockAccount","params":["0x00a329c0648769a73afac7f9381e08fb43dbea72","",null],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

Now I open https://remix.ethereum.org and connect to my local web3 provider. This works and the unlocked account is preselected.

Then I use this test contract: https://pastebin.com/zyLjhJak
and click on deploy.

The transaction is pending forever.

I guess this has something to do with my Parity config. Any ideas what I'm missing?

Kind regards


texts: Myetherwallet, how can I find my Ethereum lost?

texts:
October 30, 2017 at myetherwallet

He participated in the Gladius Free Sale.

The quantity that you participated in was 37 ETH ...

But the ETH said the did not arrive at the Gladius Free Sale.

Unfortunately my Ethereum is still not coming back.

Myetherwallet does not accept e-mail.

I do not respond if I ask on Facebook or Twitter.

How can I find 37ETH?

mywallet :0x091597625737bc14e56D9f0f28b85F1Bb7a82e5d

my E-mail: xmmx@hanmail.net

Please.


texts: How to get a contract's balance in Solidity?

texts:
How do I get the balance of a contract with solidity?
I know geth has web3.eth.getBalance(), but that's to get the contract balance after it has been deployed.

Is there a standard way of doing this, or do I have to have a separate var that uint256 that keeps track of the total balance?


texts: Instantiate Constant variable in solidity

texts:
What is the right way to instantiate a constant variable in Solidity?
The following code give me errors when I compile:

pragma solidity ^0.4.4;

contract LearnSol {

    function LearnSol() {

    }

    function basicSyntax() returns(uint) {

        uint constant a = 8;
        return 1;
    }
}

The error:

Compiling ./contracts/LearnSol.sol...

/usr/local/lib/node_modules/truffle/node_modules/solc/wrapper.js:48
        throw e;
        ^
abort(5) at Error
    at jsStackTrace (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:1:19718)
    at stackTrace (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:1:19901)
    at abort (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:19:15285)
    at Array.dXb (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:11:585101)
    at Array.tX (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:8:557453)
    at Array.eea (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:6:495332)
    at Object.wOb [as dynCall_ii] (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:11:540050)
    at invoke_ii (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:1:1275129)
    at Array.ixa (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:7:494308)
    at Object.bVb [as dynCall_viii] (/usr/local/lib/node_modules/truffle/node_modules/solc/soljson.js:11:577232)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

I'm following this reference: https://learnxinyminutes.com/docs/solidity/


texts:
I am looking for an alternative to MyEtherWallet.
I am facing some issues with MEW, thus I am looking for alternative, preferably with more advanced functions - like for example allow me to "speed up" transaction, or that will not consider transaction over 750 seconds as failed (or even better, allow me edit nonce manually)
Beeing able to send raw transactions (vintage mew's "offline" mode) would be a great addition.
I'm not here to hate MEW, it's great project. It's just not for me.
Right now for my needs Im using mixture of localhost vintage mew, current mew, and raw javascript on web3js. It's not.. the most convinient setup, but I can get the work done.
I would appriciate remote node wallet, as I don't have enough storage to run local node.
All I need in terms of logging in is json keystore, or in case of Kovan I just have few plain priv keys for easier/faster testing.


texts: How to use function arguments of payable function for require statement?

texts:
function createCampaign(uint deposit, address ll) public payable{
    dpst = deposit;
    require(msg.value > (40*dpst)/100 wei);
    address newCampaign = address((new Campaign).value(msg.value)(deposit, ll, token_address, 1));
    token_instance.setAllowance(dpst, token_holder, newCampaign);
    deployedCampaigns.push(newCampaign);
}

Here's a piece of my code. In this payable function minimum amount of wei to be sent should be at least 40% of deposit.
Is the require function implemented correctly?


texts:
I'm not able to deploy any contract (the greeter contract does not work either) using Mist 0.8.6 in Windows. The deployment just hangs there and nothing really happens. Is there a way to figure out what is going on? I've tried restarting Mist but that had no effect.

Thanks.

Edit:

This is the information from one of the contracts: https://testnet.etherscan.io/tx/0x3abd39f86738318ad93d9f183903dc678a77b0b2259a5d7dd3a7079e984e52bc

I'm no expert but it does seem the contract was successfully created. However, it does not show in the Mist browser.


texts: Was Uniswap a DAO even before it had it's governance token, the UNI?

texts:
A Decentralised Autonomous Organization is governed by a governance token. So democratically, everybody who owns the token could vote on proposals and submit proposals too for the whole DAO.
Uniswap didn't always had it's UNI token, how did it work before that?
Also, can a DAO really be a DAO without a governance token?


texts: Possible to use Hashcat to crack Ethereum password?

texts:
I have a Ethereum presale wallet and the password i recorded for it doesn't work.
I now have a list of over 200 possible passwords for it.
Is it simply a matter of trying to use SHA3 in Hashcat with the bkp part of the wallet.json file or am I deluded and it is much more complicated than that?


texts: Error when executing transfer with sufficient funds

texts:
When executing a function which buys a loan from a portfolio (sellPortfolio in the code here), I get the following error:

I am using Remix 0.5.2 and I have tried to run this from the Java front-end as well as directly from Remix. I checked that there were enough funds for the transfer. I also use exactly the same syntax in another function/contract which works fine.

function buyLoan(Loan _sellLoan, Portfolio _sellPortfolio, uint _tradePrice) public {

            uint tradePrice = _tradePrice;

            // Get Sell Portfolio for transfer
            Portfolio sp = _sellPortfolio;

            // Now send funds
            address(sp).transfer(tradePrice);

            // Add loan to portfolio
            _sellLoan.setPrice(tradePrice);
            loans.push(Loan(_sellLoan)) -1;
            portfolioLoanBalance += _sellLoan.getBalance();

            // Now add loan to buying portfolio - "A"=Active=0x41 / "I"=Inactive=0x49 / "S"=Sold=0x53
            portfolioLoanStatus[address(_sellLoan)] = 0x41;

            // Delete loan from selling portfolio
            sp.setLoanStatus(_sellLoan, 0x53);

        } // function buyLoan(Loan _sellLoan, Portfolio _sellPortfolio) public

and here is the fallback function for Portfolio:

function () payable external {
    // fallback function to receive funds
    received = msg.value;
    availableFunds += received;
    } // function () payable external {

Can anyone help me please?


texts: ETC transaction doesn't reflect in myetherwallet -help

texts:
I just transfer ETC from my POLO account to the ledger nano s using
myetherwallet,

Ans something wired happend :

Here i dont see that i got anything

https://etherscan.io/address/0xc0fb24490fbf9daa9101e95bc3cf50b87dcf8ce0

but on that one i do see my transaction made successfully

http://gastracker.io/addr/0xc0fb24490fbf9daa9101e95bc3cf50b87dcf8ce0
but still doesnt reflect on myetherwallet ETC

Thanks for the help.


texts:
I was hoping somebody could help me to withdraw ETH from the DAO Extrabalance withdraw contract. I followed the instructions in this thread:
How do I get a refund for the amount I paid in excess of 1 ether to 100 The DAO tokens

When I submit the Approve transaction it runs, but the Withdraw function fails: "invalid jump destination (PUSH1) 2". I checked and I should be entitled to 49 Eth.

https://etherscan.io/tx/0x3c37cc4517327bfebab0bf7119ef21380dbc6a63d525dcec9f30f0bf3999c1af

Any suggestions? Thanks a lot.


texts: What is 'dangling vote' in the geth clique POA algorithm?

texts:
I am reading the code implementation for clique POA algorithm(consensus/clique), and encountered this line of comment in consensus/clique/snapshot.go:

// uncast removes a previously cast vote from the tally.
func (s *Snapshot) uncast(address common.Address, authorize bool) bool {
    // If there's no tally, it's a dangling vote, just drop
    tally, ok := s.Tally[address]
    if !ok {
        return false
    }
    (...)
}

What is this 'dangling vote'? In what case does dangling vote created?


texts:
I have a struct

    struct lineItem {
        string idNo;
        string date;
        string code;
        string docCode;
        string vendorNumber;
        string invoiceDate;
        string typeOfTransaction;
    }

I have a mapping

    mapping(string => lineItem[]) lineItems;//here string will be the user who adds data to this

So i have to filter the mapping according to the username given and after that i have to filter those data having idNo same as the input

      function getByInternalDocNo(string memory creator,string memory docNo,string memory typeOfFilter) public view returns(lineItem[] memory,vatDetails[] memory){
        uint count = 0;
        // bool[] memory res = new bool[](lineItems[creator].length);
        for (uint index = 0;index<lineItems[creator].length;index++){
            if(keccak256(bytes(lineItems[creator][index].idNo))==keccak256(bytes(docNo))) {
                count++;
            }
        }
        lineItem[] memory res1 = new lineItem[](count+1);
        vatDetails[] memory res2 = new vatDetails[](count+1);
        count = 0;
        for (uint index = 0;index<lineItems[creator].length;index++){
            if(keccak256(bytes(lineItems[creator][index].idNo))==keccak256(bytes(docNo))) {
                res1[count] = lineItems[creator][index];
                res2[count] = vatDetail[creator][index];
                count++;
            }
        }
        return (res1,res2);
    }

Now i want to make this function a bit more generic for all type of filters i.e. to check whether coCode is equal to given value or not.So,i wanted to do something like this

lineItems[creator][index][typeOfFilter]// will give error

and use this to compare it with the input value.So how do i do this?


texts: Dual boot Ubuntu and Windows - Keep Ubuntu offline as backup - is it safe?

texts:
If I want to put my Ether (Or any other cryptocurrency for that matter), in an offline backup, is it safe to do it by making a transaction first to an Ubuntu (When it's online at first), and then disable networking there, and use my main machine on Windows with dual boot?
Or, if Windows is connected to the internet, I still compromise the wallet in the Ubuntu installatin even though it's not connected?

Maybe hackers can use the Windows internet connection to do stuff on the Ubuntu somehow?


texts: Is the 17 June 2016 operation legaly illigitimate?

texts:
It has been stated that since the creator of the DAO have called the contracts code as the only legal statement, all things that the code allows are legitimate.
As a counterargument it was said that code can't be a legal contract in most juristictions.
What is true?
http://pastebin.com/CcGUBgDG


texts: How can a server except a signed tx and pay the gas?

texts:
I have a contract where users can buy "credits".
With that credit, users can post a message to a server (a route set up in ExpressJS).
I have the buying of credits working.
But my question is how can the code running on the server know the user actually has a credit?
I'm guessing that the user..

signs a tx
POSTs tx to a route on ExpressJS.
That route calls a provider (like Infura) to check if the user has a credit.
If they have credit, change contract state (remove one credit)
Depending on the result, ExpressJS code allows the user to make a post or not.

Question 1
The piece that is most confusing is how the user (client-side) will sign the transaction, and NOT send it to the provider — but post the tx to Express JS/server. How is this accomplished?
Question 2
I would like to pay the gas for the user.
How would I take in a client-side signed tx (necessary to prove the user is who they really are — to check their credits). But at the same time, pay the gas.
Would this mean I would need a 'signer' (with a private key available) in the server environment? How would this work?
Is this the correct way to go about it? Any pointers, articles, etc.. on this topic would be greatly appreciated!


texts:
I need to store a number 4D security hashes. For example:
CCHdU3mFEYPpa-CYeDSooeZtYSG-CD9czobepa4a9-CRmVpX3Tegakr

I am storing number of these hashes in array of string i.e. string[] using

pragma experimental ABIEncoderV2;

I also need to view these in Etherscan by passing it as an event:

event onSubmissionBoth(bytes32[] indexed docHash, string[] indexed
doc4DHash);

function submitHash(bytes32[] calldata docHash,string[] calldata doc4DHash) external onlyOwner() {
       emit onSubmissionBoth(docHash,doc4DHash);
    }

The problem is I dont think the Etherscan supports the experimental string[]. As I get this when I decode the string[]
#b�r�����i��ZI�5�V������f%����

But bytes32[] works fine.

Is there an alternative to String[] to view it in good form in Etherscan?
Also if not, how should I implement the 4D hashes so that I get it in
good form in Etherscan