texts: How to achieve inheritance support using web3j wrapper?

texts:
I have two types of smart contracts. One parent contract to store the type and other child contracts which inherits the parent contract.

The problem is, I can't generate java wrapper class (Child1Manager.java) which inherits wrapper class CompositeManager.java, it inherits only the Contract class.

pragma solidity >=0.5.0 <0.7.0;

contract CompositeManager {
    uint private conType;

     /**
     * @notice This method returns the contract type
     * @return _type - type of contract
     **/
    function getType() external view
                       returns(uint)
    {
        return conType;
    }

    constructor(uint _type) public {
        conType = _type;
    }
}

The child contract

pragma solidity >=0.5.0 <0.7.0;
import "./CompositeManager.sol";
contract Child1Manager is CompositeManager(1) {
....
....
...
}

I can create the bin and abi and wrapper using solc compiler, web3j, solidity, it creates 4 separate abi and bin for two types of contract and one java wrapper for Child1 contract.

solc Child1Manager.sol --bin --abi --optimize -o ./abi_bin

web3j solidity generate -b ./abi_bin/Child1Manager.bin -a ./abi_bin/Child1Manager.abi -o ./ -p package.name.of.my.project

Is there any way to generate this?

public class CompositeManager extends Contract {
.....
...
...
}

public class Child1Manager extends CompositeManager {
.....
...
...
}

Thanks


texts: Remote Hosts don't recognise all peers on a private ethereum network

texts:
We are running geth on Ubuntu in virtualBox on Windows for all hosts. We are all relative NOOBS on this although have successfully set up and transacted remotely already.

I have set up private blockchains on a local network and transacted between nodes. I also managed to get a private blockchain running between 2 remote hosts and was able to transact between these nodes. I've now extended the peers to 3 remote hosts and have started to run into problems. The node in London is able to recognise all peers. There are 2 nodes in Poland (on the same local network) these can all connect to London node and their local node. There are 2 nodes in NY on seperate machines and these can connect to London but not to anyone else.

The custom genesis blocks are the same across all peers. They are all synced with the blockchain so show the same blockNumber. We've tried launching the remote nodes with --bootnode pointing to the london host and all are launching without --nodiscovery so should be able to get the peers from the London host.

I think the issue is with the public port and listening port ids. My London host goes through a virgin router that only allows remote connection through port 8443 so I also set my listening port to 8443 when I launched geth. The remote peers generate a different port id within their remote addresses each time they connect to London which I think is related to their router set ups. see below for the remoteAddress peer information from London node. N.B. from the remote hosts the London remoteAddress is always 77.999.999.19:8443

remoteAddress: 76.999.999.76:32846

remoteAddress: 85.999.999.166:50004

remoteAddress: 85.999.999.166:56442

remoteAddress: 76.999.999.11:51126

we've tried admin.addPeer on the remote nodes with different port combinations enode://pubkey1@ip1:port1 and enode://pubkey1@ip1:port1?discport=remoteAddressPort without success. We've also tried using different listening ports on the remote nodes.

We've tried resyncing the clocks in the remote hosts to London timezone.
We've tried using --extip when launching geth from the remote peers.

Why does the Listening port on the remoteAddress change when non London nodes connect to the London node.

How do we get the non London nodes able to recognise the other non London nodes.

Is there a way of getting the non London nodes to recognise the nodes that London is connected to automatically.


texts: geth mainnet fast sync appears stuck at around 100 blocks from highestBlock

texts:
I started syncing a geth node to the mainnet in fast sync mode 7 days ago. The status is still around 74 blocks behind the highestBlock, e.g. if I run the following:
eth.syncing.highestBlock - eth.syncing.currentBlock

Then I see something between 74 and 100 blocks behind mainnet.
I am running this node on a Digital Ocean droplet with a quad core processor, 8 GB RAM and a 500 GB SSD.
I tried restarting the service and it started off syncing pretty fast again and then got stuck at the same interval of between 74 and 100 blocks behind mainnet.
Can anyone help share some tips on how I might complete this syncing process please?
Any help much appreciated.


texts: Seeing a contract created contract in Mix

texts:
When a contract creates another contract on the Mix blockchain, I see the block with the function call but not the contract that was generated, i.e, it doesn't show in the 'Contract Accounts' section.

Is there any other way to see the created contract?


texts: How to find the name or type of a contract in Solidity

texts:
Suppose I have solidity contracts that inherit from another contract:

contract A {}
contract B is A {}
contract C is A {}

If I make an array of A objects and populate them with it's subclasses:

A[] memory examples = new A[3];
examples[0] = new A();
examples[1] = new B();
examples[2] = new C();

How can I dynamically determine which subtype of A is being referenced, if I were to loop over examples? I'm looking for an equivalent of JavaScript's typeof operator so that I might do:

if(typeof(example) == A) {
  // Do stuff
} else {
  // Do something else
}

I'd settle for even the name of the constructor. Is this possible?


texts: How many times can you try to create a candidate block/sec in Casper?

texts: According to this post, you can create only one candidate block/sec for next block in general POS formula. Same in Casper? If it's different, how many candidate blocks can you create in a second in Casper?


texts:
I have a slow computer, which has 2GB memory RAM. One geth app uses %60 percent of the RAM, which lead me to run only one geth node; I cannot run 2 geth nodes in parallel due to RAM overload.

[Q] Is it possible to decrease RAM usage of go-ethereum(geth)?

Thank you for your valuable time and help.


texts: Uncaught Reference Javascript Error when submitting data via html to contract

texts:
I created a contract (Freight) using the "ratings" tutorial template. The Freight contract is meant to store values entered in the html page (input.html) and submitted. Just like the "ratings" tutorial, though at the moment i get

JavaScript  error   12:49:31    input.html - line 99 - Uncaught ReferenceError: setFreight is not defined

whenever I hit the submit button. How do I solve this?

Link to git repository: https://github.com/Akiiki/Freight.git


texts:
I checked this but it does not help me. I am writing an inherited contract and I would like to hide the CheckValue function from the console. How do I go about this? I wish to check if the value I am entering in the withdrawal section is being verified on its own.

This is working, I just wish to hide the function from the console. Changing visibility throws an error and I only wish to hide CheckSum instead of the others.

Code below, I'm new to solidity :)

pragma solidity ^0.4.25;

interface Regulator{
        function CheckValue(uint amount) external returns(bool);

    function loan() external returns(bool);
}
contract PracticeInheritance is Regulator{
    uint private value;

    constructor (uint amount) public{
        value +=amount;
    }
    function deposit(uint amount) public{
        value += amount;
    }
    function withdraw(uint amount) public{
        if (CheckValue(amount)){
            value -= amount;
        }

    }

    function balance() view public returns(uint){
        return value;
    }

     function CheckValue(uint amount)public returns(bool){
            return amount <= value;
        }
        function loan()public returns(bool){
            return value >=0;
        }
}

contract PracticeContract is PracticeInheritance(500){
    string private name;
    uint private age;

    function setName(string _name) public{
        name = _name;
    }

    function setAge(uint _age) public{
        age = _age;
    }
    function getName() public constant returns(string){
        return name;}

        function getAge() public constant returns(uint){
        return age;}

}

I wish to hide it from here but the functionality must remain same i.e it should still check the value passed from withdraw but CheckValue should not show in the console here


texts:
pragma solidity ^0.5.0;

contract fisrtCoin {

    address deployer;
    mapping(address=>uint) balances;

    public function fisrtcoin() {
        deployer = msg.sender;
    }

    public function giveCoin(uint amount, address receiver) {
      if(msg.sender == deployer){
          balances[receiver] += amount;
      }
      else {
          throw;
      }
    }

    public function viewBalance() returns (uint) {
        return balances[msg.sender];
    }
}


texts: Want to deploy and operate a Decentralized Autonomous Organization (DAO) on Ethereum.  What are my options?


texts:
I am running geth with this command :

geth --fast --cache=512 --ws --wsorigins="*" --rpc --rpccorsdomain="*" --wsapi "db,eth.subscribe,net,ssh,miner,web3,personal,admin" --datadir /media/username/2TB_HDD/

and i have used web3js and created a nodejs app :

const express = require("express");
const app = express();
const net = require('net');
const Web3 = require("web3");
// const web3 = new Web3("ws://127.0.0.1:8546");
var web3 = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546"));

web3.eth.getBlock('latest')
.then(console.log);

var subscription = web3.eth.subscribe('newBlockHeaders', function(error, result){
    if (!error)
        console.log(error);
})
.on("data", function(blockHeader){
    console.log(blockHeader);
});

var subscription2 = web3.eth.subscribe('syncing', function(error, sync){
    if (!error)
        console.log(sync);
})
.on("data", function(sync){
    console.log(sync);
})
.on("changed", function(isSyncing){
    if(isSyncing) {
        console.log("stop app operation");
    } else {
        console.log("regain app operation");
    }
});

var subscription3 = web3.eth.subscribe('pendingTransactions', function(error, result){
    if (!error)
        console.log(result);
})
.on("data", function(transaction){
    console.log(transaction);
});

app.listen(3000);

In the console i am getting latest block number : 0. Here is output of eth.syncing :

> eth.syncing
{
  currentBlock: 5046326,
  highestBlock: 5046445,
  knownStates: 407842,
  pulledStates: 401021,
  startingBlock: 5046087
}

I think geth is synced fully? because the latest block number will always keeps increasing, I have these questions, please answer them :

Is there a way i can find out if blockchain is synced fully?
console.log(blockHeader) shows nothing, why? is it because blockchain is not synced fully ?
console.log(pendingTransaction) also not works, why? is it because
of the same reason, blockchain not synced fully?


texts: changing source of random number based on reward?

texts:
Would this be an acceptable way to produce a random number dependent on the reward?
Say if the reward is high enough to entice a miner to manipulate the block then the contract will utilize oraclize.

if (reward < x)
{randNumber = (uint(keccak256(abi.encodePacked(block.difficulty))) % 100;}
else {useOraclize();}


texts: How to reduce block time for existing ethreum blockchain network?

texts:
I had deployed my private blockchain network back in 2018-08-12 16:12:48 +0600 (1 year, 167 days ago). Since then it is working. At that time the block time was 20-30 seconds which was acceptable for our private transaction. But now a days the average block time has increased to 1 min and sometimes it takes 8-10 minutes to mine a  single block which seems crazy  ;(

NB: There are 7 running nodes and all them has 8 GB ram. You can check the geth version in the picture.

Is there any way so that I can reduce the blocktime ? Or can anybody tell me that upgrading the geth version will solve problem?

genesis.json looks like :-

{
    "config": {
        "chainId": 17,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "0x100",
    "gasLimit": "0x2100000",
    "alloc": {
        <ignored>
    }
}

And the command is:-

  geth --identity "node_name" --networkid 17  --rpc --rpcaddr
  "" --rpcport "8545" --rpccorsdomain "*" --datadir
  "node02"  --port "30301" --ipcdisable  --nodiscover  --rpcapi
  "db,eth,net,web3,personal,miner,admin"


texts: I have two contracts with variables and functions that each should need to reference/call. I would prefer to separate the contracts, as different user groups would be accessing each. Can two contracts import each other? Or is there an order of operations -so to speak- wherein only one contract can be dependent on another?


texts:
I have this contract that calculate average

pragma solidity ^0.4.24;

contract test{

uint average;
uint counter;

function calcAverage( uint _newValue) public
{
    average = ((average * counter) + _newValue)/(counter + 1);
}

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

I call to calcAverage function and I send 100, then i get the value and I recover 100. Fine. The problem is when I insert the new value. I insert 700 and the recalculate average is 700. Not the expected 400


texts: Solidity not updating value from delegate contract [SOLVED]

texts:
Assuming this contract:

contract getSome {

    finalizeToken token;

    constructor() {
        token = finalizeToken(0xdc0974e65e479fa587118eb7588f426229a39d31);
    }

    function testWrite() public returns (bool) {
        setval();
    }

    function setval()  {
        token.setEpoch(8000);
    }

}

interface fToken {
    function setEpoch(uint _blocks) external ;
}

contract finalizeToken is fToken {
    uint public epochCount;

    constructor() {}

    function setEpoch(uint _blocks) public {
        epochCount = _blocks;
    }

}

For whatever reason the value of epochCount on the finalizeToken is not being updated when called trough the getSome contract.

I've never encountered this before, so i'd appreciate some inputs

EDIT: Issue found, i was using ganache instead of ropsten and it need explicit sendTransaction for making a call. I was using Remix with Ganache as Web3 provider, causing this behaviour.

Thanks!


texts: Get allowance list after approve function in erc 20

texts:
A ➜ approve(spender, amount)
B ➜ transferFrom(sender, buyer, amount)

allowance(address tokenOwner, address spender)

I am seeing that this function can be call only if the person know the address of the tokenOwner and token of the spender. What if

1) I as a spender want to know the list of people who allow me to spend their token without they notify us?
2) I as an owner want to keep track of approve spender and amount list?

I am expecting something like getAllowanceList(tokenOwner) and getAllowanceList(spender)

Is that supported? If not, why is it not supported?


texts: Can running an Ethereum node at home be expected to completely crash a gigabit router?

texts:
I'm getting into the Ethereum ecosystem and have done some experiments with running a full node at home. So far, I've been able to run geth, connect to peers, and synchronize to the mainnet chain. I'm not mining yet (though I did try for a bit), but I am synchronizing transactions and getting new blocks.
However, several times during the time I've been running this node, my entire router has crashed and needed to be power cycled. My router (a two-and-a-half year old Linksys EA7500 (official website link) that I bought refurbished) doesn't usually experience this and handles my home's 1gig/1gig internet just fine for normal  traffic, but the router crashes within a few hours of running the full node. It's not just a loss of Internet - the entire thing goes offline and I can't connect to the gateway address (turns out the WiFi still works, see below).
Is this something that can be expected to happen when running a node at home with this class of router, or should my networking setup be able to handle it? Alternatively, is this a sign that I need to replace my router (i.e. a router of this caliber could handle this load when it was new, but my router can't handle it anymore due to age)?
EDIT: So, doing a little more testing, it turns out that the router does not completely crash. Instead, the router is disconnected from the Internet and it refuses to acknowledge messages from the Ethernet connection the node is connected to. The router's Wi-Fi still works, and I can still access its boot page from the Wi-Fi connection.
I need to reproduce the error again to figure out whether or not it's the Ethernet switch crashing, or the router intentionally quarantining my node device. If it's not the Ethernet switch, I'll have to factor in whether or not the ISP is purposefully taking the router offline (perhaps it sees me make all these peer connections and thinks I'm pirating?). Are these things to be expected of running an Ethereum node on this kind of router, and/or this age of router?


texts: Dynamic two-dimensional array initialisation

texts:
I want to initialise a two-dimensional dynamic array.
For a one-dimensional array it looks like that:
function verify(uint[50] memory input){
uint[] memory input_values = new uint[](input.length);
        for(uint i = 0; i < input.length; i++){
            input_values[i] = input[i];
        }
...
}

How would that code look like for a two dimensional array:
function verify(uint[50][2] memory input) {

uint[][] memory input_values = ??

}

Thank you and enjoy your day!


texts: Data in memory during a transaction is deleted when execution stops. This means this information is not stored in the contract state, but is the information that was in memory during the transaction still stored in the logs of the transaction?


texts: How can I set gas and/or gasPrice on a Token Contract ?

texts:
I copied this token contract from Ethereum.org, and after deploy to Rinkeby, I could not buy tokens. I really do not know why, but I think that's because I did not set the gas on contract.
is there any way to set gas on this contract?

The error:


texts: Difference between web3.eth.personal.getAccounts() with web3.eth.getAccounts()

texts:
What are the differences between web3.eth.personal.getAccounts() and web3.eth.getAccounts()?

environment

truffle: v5.1.7
using truffle console.


texts: What is the process to diagnose transaction execution problems?

texts:
In my private net the transactions periodically get stuck and I have no idea why. So, I am seeking a debug process to diagnose what could be wrong with a transaction. What would be the steps/functions to execute/call to trace what happens to a transaction?

For example, I submitted a transaction 1 hour ago, it is still pending but miners mine 1 block every 10 seconds with 0 transactions. I checked if this transaction has propagated to other nodes and on the nodes I own it is. But I created a new node, initialized genesis, downloaded the full blockchain and the transaction is NOT there. Why did it not propagate ? I can not get into the nodes that are mining because I don't own them, so how would I diagnose this problem?

This is how the tranaction looks like when I query it:

> eth.getTransaction("0x1ad26f1863aaa2b3920c6ed5729483e63b2f24ec3617b1957c73db88086bc4d2")
{
  blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  blockNumber: null,
  from: "0x986c12b8497a0a31055c1e67a98f629748d28151",
  gas: 90000,
  gasPrice: 18000000000,
  hash: "0x1ad25f1863aaa2b3920c6ed5729483e63b2f24ec3617b1957c73db88086bc4a2",
  input: "0x",
  nonce: 11,
  r: "0x882c6392c7c95557ac7eb467a66e8e8e90c7d431ea7e001cd341a45b08a3b514",
  s: "0x121ca55d4523070403ff2dcf182311bbec30653de04d336b6306a84fa3cb2063",
  to: "0xab8758481b7c64f3428f872daa5cf889d9dd930f",
  transactionIndex: 0,
  v: "0x1f6",
  value: 100000000000000000000
}
>

the node is in mining mode, but it doesn't have enough hashing power to process it.


texts:
I recently treated myself to a fresh install of Ubuntu, however did not separately back up my keys from metamask. I still have the old .config/google-chrome folder however from my home directory. I've read that metamask stores keys in encrypted format in this local storage folder (old metamask version, not local.storage), however after some poking around in the .ldb files I cannot seem to find anything resembling the encrypted keys.

I recall my password but not my seed words. Can I manually retrieve my encrypted key so I can use my password to decrypt?


texts: Storing access to encrypted data in non-fungible tokens

texts:
I am fairly new to ethereum, I want to develop a non-fungible token that can grant access to its owner access to encrypted data on IPFS.
The way I am thinking this can be done is, first the owner of the data encryptes the data using symmetric cryptography using a secret derived from a key derivation function f, where f(p,s) = key. Here p is the passphrase that only the owner knows and s is a random salt. This random salt s gets stored in the token.
When the owner wants to transfer ownership, they would first encrypt the passphrase p with the recipient's public key and store that on the token and transfer it. The recipient can then decrypt the passphrase p (and ideally change the key and re-encrypt the data) with which (paired with s) they can then use to access the IPFS data.
Is this a safe way to do it?


texts: Oraclize random number only works once, then doesn't trigger events and requires a lot of ETH

texts:
So I am using the following code

contract Damble is usingOraclize{

function Damble() {
    getRandomNumber();

}
    function __callback(bytes32 _queryId, string _result, bytes _proof) {
    if (msg.sender != oraclize_cbAddress()) throw;

    if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0) {
        // the proof verification has failed, do we need to take any action here? (depends on the use case)
    } else {
        // the proof verification has passed
        // now that we know that the random number was safely generated, let's use it..

        newRandomNumber_bytes(bytes(_result)); // this is the resulting random number (bytes)

        // for simplicity of use, let's also convert the random bytes to uint if we need
        uint maxRange = 10000000; // this is the highest uint we want to get. It should never be greater than 2^(8*N), where N is the number of random bytes we had asked the datasource to return
        uint randomNumber = uint(sha3(_result)) % maxRange; // this is an efficient way to get the uint out in the [0, maxRange] range

        newRandomNumber_uint(randomNumber); // this is the resulting random number (uint)
    }
}

function getRandomNumber() payable{
    oraclize_setProof(proofType_Ledger); // sets the Ledger authenticity proof
    uint N = 4; // number of random bytes we want the datasource to return
    uint delay = 0; // number of seconds to wait before the execution takes place
    uint callbackGas = 200000; // amount of gas we want Oraclize to set for the callback function
    bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);
}

The first time getRandomNumber() gets called from the constructor everything works fine.
When I want to call getRandomNumber manually with a certain value (to pay for the Oraclize value) I need to put in more than $5 worth of eth that doesnt get spend otherwise the transaction fails but it dilutes my contracts ether balance. Other than that when i call getRandomNumber() after the constructor called from the constructor no events get fired even though a transaction comes in from the Oraclize address.

EDIT: this is a link to my contract: https://ropsten.etherscan.io/address/0x92f0dbf8b218e03f288da42c0f6d4df7de40c3f2


texts: Quorum: Can't Connect To Nodes From External Sources

texts:
I have a Quorum (7nodes example) network up and successfully running. I can connect to any geth node using the following:

geth attach ipc:qdata/dd1/geth.ipc

I can also see that the ports opened in the startup script start.sh are listening:

tcp6    0   0 :::21000         :::*        LISTEN

I can see that a provider has been set:

> web3.providers
{
  host: "http://devserver01:21000",
  HttpProvider: function(host),
  IpcProvider: function(path, net)
}

However:

> web3.currentProvider.isConnected()

returns false. I also can't reach the node using web3.min.js from a web page. The error is:

Uncaught Error: CONNECTION ERROR: Couldn't connect to node

Any suggestions on how to troubleshoot? Thanks.


texts: retrieving web3 contract.ownerOf NFT ERC721

texts:
I'm playing around with web3 and frontend trying to read something off the ethereum blockchain. What i wanted to do is to verify the owner of a NFT (erc721).
I've used this piece of code here that enable me to check the balanceOf a certain ERC20 linked to the connected wallet address
  function getERC20TokenBalance(tokenAddress, walletAddress, callback) {

  let minABI = [
    // balanceOf
    {
      "constant":true,
      "inputs":[{"name":"_owner","type":"address"}],
      "name":"balanceOf",
      "outputs":[{"name":"balance","type":"uint256"}],
      "type":"function"
    },
    // decimals
    {
      "constant":true,
      "inputs":[],
      "name":"decimals",
      "outputs":[{"name":"","type":"uint8"}],
      "type":"function"
    }
  ];

  let contract = web3.eth.contract(minABI).at(tokenAddress);

  contract.balanceOf(walletAddress, (error, balance) => {
    // ERC20トークンの decimals を取得
    contract.decimals((error, decimals) => {
      balance = balance.div(10**decimals);
      console.log(balance.toString());
      callback(balance);
    });
  });

}

setInterval(function() {
  let tokenAddress = '0x50f5474724e0ee42d9a4e711ccfb275809fd6d4a';
    let walletAddress = web3.eth.accounts[0];
          if(tokenAddress != "" && walletAddress != "") {
        getERC20TokenBalance(tokenAddress, walletAddress, (balance) => {
          document.getElementById('text-bal').innerText = balance.toFixed(3);
        });
      };
        }, 100);

now i would like to verify a certain NFT, which i used 0x50f5474724e0ee42d9a4e711ccfb275809fd6d4a (a SANDBOX land contract). With balanceOf, it does show me this address has LAND NFT in it, but i wanted to check for the tokenID, by changing it to
let contract = web3.eth.contract(minABI).at(tokenAddress);
contract.ownerOf('18429');

it returns nothing, can you guys point me to the right direction :) ?


texts: Calculating the address for a soon-to-be-deployed contract

texts:
How is it possible to calculate the address for a soon-to-be-deployed contract?

Does anyone know?


texts: Solidity — refactor simple contracts to fix gas limit and avoid Checks-Effects-Interaction warning

texts:
The following pattern is something that recurs a lot in the contracts I am develping and when I run an analyser over it I get a couple of warning.

Say I have two contracts as follows:

pragma solidity ^0.4.18;

contract Candy {
    address public owner;

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

and

pragma solidity ^0.4.18;

import './Candy.sol';

contract Wrapper {

    Candy private candy;
    address public owner;

    function linkTest(Candy _candy) public {
        require(address(_candy) != 0x0);
        address candyOwner = _candy.owner();
        require(candyOwner != 0x0);
        owner = candyOwner;
        candy = _candy;
    }
}

The first warning is that linkTest includes a potential violation of the Checks-Effects-Interaction pattern.

My understanding of that is that if _candy was some unknown incoming address and not something explicitly castable to Candy then this might be an issue, but the two contracts are quite tightly coupled.

To mitigate this I ensure that any update to state is done after any require but the warning still shows and I am not sure how I'd refactor this to elimiate that.

The second warning is that the Gas requirement of linkTest is unknown or not constant. This is because of the call to _candy.owner().

How would I refactor this to elminate both warnings? Is there a way I can proscribe an upper bound to the gas requirement for _candy.owner()?


texts: I want to know how to quit the truffle console?

texts: just like the question!! I always kill the progress by kill the main shell. I want to change this way.


texts:
Is it possible to convert string to bytes32?

For example:

contract c {
    string public name;
    mapping (string => bytes32) str2bytes32;

    function test(string t) returns(bytes32){
        name = t;
        return str2bytes32[name];
    }
}

Upon deploying this contract and calling the function test always returns 0x, no matter what string I pass in. So just wondering what the issue is. However, changing the argument type from string to bytes32 in the function and changing the variable type for name helped ensuring the return value of bytes32. Any suggestions as to why the hash map didn't work would be helpful?


texts: I was using strings before I read that using bytes is gas cheaper. Now I changed my strings to bytes32 but I don't know how to compare them. I need to check if two bytes32 are equal in the require statement. How can I do it? Using normal == gives revert and surrouding it with keccak256 says it's invalid implicit conversion from bytes32 to bytes requested.


texts: Can Metamask read Ethereum Name Service (ENS) addresses?

texts: Is Metamask Chrome extension able to read an Ethereum Name Service (ENS) address?


texts: Why token value is getting changed on Ethereum?

texts:
I have created ERC20 token with 18 decimals. From web3 (application front end)  when I transfer 100 tokens, on etherscan it shows 0.0000000000000001 . When I call to get the balance then on UI it shows 100 tokens. How I can fix this?

Method signature:  function transfer(address _to, uint256 _value)  public returns (bool) { }

The following is a transaction link for reference.

https://kovan.etherscan.io/tx/0x7b50a2f1a013a0b15eb702f99d09d9a1c16a39bfa179329e246b6ba5b2318b12


texts:
I am new to solidity and trying to deploy a contract to see whether the address is EOA or Smart Contract. The code is listed below. I am not able to see the boolean value when I executed the contract in the mainnet.

pragma solidity ^0.4.0;
contract Ballot {

event isEOAOrNot(bool val);

function isContract(address addr) returns (bool) {
  uint size;

  assembly { size := extcodesize(addr) }
  bool val = size > 0;
  isEOAOrNot(val);
  return val;
}

}


texts: Does any such smart contract exist where the creator's private key is not required at the time of unlocking?

texts:
Is the following type of smart contract possible, and if so, what is it called?

Party A creates a smart contract with available funds for a secondary party and signs the transaction
Party B enters the correct the parameters to "unlock" the funds (parameters which are in no way related to Party A's private key) and signs the transaction


texts: What is the difference between coinbase address and normal address?

texts: i am unable to find the difference between these two addresses. Do coinbase address also change after each transaction?


texts: How are addresses generated for Smart Contracts?

texts:
How does ethereum generate Smart Contract addresses?  It is any different from Ethereum generating addresses for accounts, (which uses rightmost 160 bits of the  keccak256(Elliptic curve pub key) - see yellow paper). Does the ethereum contract
generation differ from account address generation?


texts: What happens when a contract has overlapping function selectors?

texts:
The method to execute a function on a contract in Ethereum is to use the JSON RPC protocol to make a request which has the details of which function you want to call.

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

When it's eg. a function called get() what will happen is:

Take the sha3 hash: sha3("get()")
Get the first 4 bytes: sha3("get()")[0:4] == 0x6d4ce63c
Add this function "selector" in the data field of your eth_sendTransaction call.

I am wondering what happens if you try to compile and deploy a contract with conflicting function selectors.

When 1 contract has 2 functions with the same selector:
a. There will be an error during the contract compilation
b. There will be an error during the contract deploy (but it will compile)
c. No errors but when a function is called you cannot know which function will be triggered.

Does anyone know?


texts: Maintain two different token balances in a contract

texts: How can we maintain the balances of two different bep-20 tokens in a single smart contract called Handler lets suppose? I am trying to write a function that transfers the second type and the first type on different occasions but I don't know how to access and transfer  them from the Handler contract i.e. how will be the general balances mapping be modified to handle this? I don't want to use the balances of the token contracts rather use the balance of my own contract to transfer these separate tokens is it possible?


texts: How can I modify bytes32 result to uint?

texts:
I want to separate three last digits of the most recent block header hash and get the result as uint.

I can get the answer as bytes32 by this code, but how can I change this result to uint?

contract test
{
    bytes32 lastblockhashused;
    uint lastblocknumberused;

    function test()
    {
        lastblocknumberused = (block.number-1)  ;
        lastblockhashused = block.blockhash(lastblocknumberused);
    }

    function getTest1() constant returns (bytes32) {
        bytes32 number1 =lastblockhashused;
        return number1 & 0xfff;
    }
}


texts: The most gas-efficient way to convert msg.data to int128?

texts:
Is there any more gas-efficient way to convert msg.data to int128?

Here is some suggested impl:

function bytesToBytes16(bytes b, uint offset) private pure returns (bytes16) {
  bytes16 out;

  for (uint i = 0; i < 16; i++) {
    out |= bytes16(b[offset + i] & 0xFF) >> (i * 8);
  }
  return out;
}

...
int128 id = int128(bytesToBytes16(msg.data, 0));

Any assembler alternative available?


texts: Can I solo mine ethereum instead of pool?

texts: I am running a single rx 480 at 22mh/s, this rig is not geared towards mining and I’m doing it for fun. Would I be able to solo mine ethereum blocks for a higher payout? Or should I stick to pool mining from the difficulty being too high?


texts:
Web3.js throws an error "Transaction w/ invalid nonce." when I try to call contract methods from JavaScript console.
The same methods from the same contracts work fine from Mist, or, what is strange when I 'geth attach' to geth started by Mist - web3.js works with the same mehtods, but on 'pure' Mist - not.
It's not a problem of Mist, I tried the same wit geth on the server without Mist.

For example:

I have a contract on https://etherscan.io/address/0x80f84866d4872f1ea412ddf10e2ed7af0b8ca8fb

Contract code: https://etherscan.io/address/0x80f84866d4872f1ea412ddf10e2ed7af0b8ca8fb#code

In JavaScript console I have a contract object ProofOfExistence (web3.eth.contract -  https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract ). When I try to call contact function from JavaScript console using web3.js I get an error like this:

Transaction w/ invalid nonce. tx=0  state=3)

web3.eth.getTransactionCount(web3.eth.accounts[0]) returns 3

I tried (https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-methods):

ProofOfExistence.docIndex();

or

ProofOfExistence.docIndex({nonce: web3.eth.getTransactionCount(web3.eth.accounts[0])});

or

ProofOfExistence.docIndex.call();

or

ProofOfExistence.docIndex.call({nonce: web3.eth.getTransactionCount(web3.eth.accounts[0])});

with the same error: Transaction w/ invalid nonce. tx=0  state=3)

How to access contract methods from web3.js to avoid this error?


texts: Problems connecting Remix with Web3 Provider

texts:
Trying to connect to my ethereum private instance (CentOS VirtualMachine) with Remix IDE I´m getting a error and I don´t now how to solve it. Using geth in the power shell i can conect but in via web I can´t.

Searching in the internet people says to change the remix url from https to http. But instead of that still having the issue

Any idea about what I can doing bad?

EDIT

If I connect with Ganache it works. What can be bad in my VM ?


texts: Regarding Issue in retrieval data from mapping

texts:
Here's the smart contract.

pragma solidity ^0.4.8;

contract RecordCreation {

uint public count;
mapping (address => string) public usertype;
struct Patientdetails{

}
Patientdetails[] public patientdetails;

mapping (address => uint[]) public PatientDocuments;
function RecordCreation(){

}
//Function user type definition
function userDefinition(string utype1) payable returns(bool result) {

}
 //Data Submission Function
 function patientDataSubmission() payable returns (bool result){

 }
 //Documents Count Retrieval Function for  a Patient
 function countOfDataSubmission(address patientaddress) payable returns (uint result){

 }
 function getPatientsCount(address patientaddress)
    constant returns (uint count) {

 }

}

How can I define the contract for usecase -Patient holds any number of documents?


texts: Simple Truffle tests timeout "before all" hook: prepare suite

texts:
I'm trying to write my first tests for truffle, but I run in a timeout each time I want to execute the tests.

  Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

Contract deployment with truffle deploy to ganache and a parity node works fine, but when I run truffle test, truffle hangs for 2min and then runs into a timeout:

C:\Development\solidity>truffle test
Using network 'development'.

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

  Contract: MyContract
    1) "before all" hook: prepare suite

  0 passing (2m)
  1 failing

  1) Contract: MyContract
       "before all" hook: prepare suite:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\Development\solidity\test\first-tests.js)

truffle test run fine without any tests (0 passing (1ms)), but as soon as I create a test-file with a contract() as described in the docs truffle does not respond for 2 minutes, then runs into the timeout error shown above.

My test file in test/my_test.js:

const MyContract = artifacts.require("MyContract")

contract("MyContract", async () => {
  it("count should be zero after deployment", async () => {
    MyContract.deployed().then(instance => {
      assert.equal(0, 0)
    })
  })
})

My truffle-config.js:

const HDWalletProvider = require("truffle-hdwallet-provider")

module.exports = {
  networks: {
    development: {
      provider: new HDWalletProvider('aa bb cc .. xx yy zz', 'http://127.0.0.1:7545'),
      network_id: 5777,
    },
  },

  mocha: { enableTimeouts: false },
  compilers: { solc: {} },
}

Am I missing some important configuration used for running the tests? or why does it run into a timeout? If there's another error causing this timeout, is there a way to debug this in more detail to get a better error description?

The post I found here addresses problems with contract deployments that took too long, but my contract is deploy within 10 seconds, so that doesn't seem to be the same problem here.

Things I tried:

Updating my truffle-config.js to include mocha: { enableTimeouts: false } as suggested didn't change anything, still same behaviour.
Create an empty project and start from scratch. Same Behaviour.
( I did truffle init, write contract, add to migrations, add truffle-config, add test-file, run truffle build|deploy|test.)

Any hint on what to do to get my very basic test working would be highly appreciated.


texts: In the geth codebase where is the smart contract function executed

texts:
I'm looking to add some logging code to Geth.
I have a vm created with a single geth node and private blockchain running. I've deployed a smart contract to it.
I want to initiate a transaction on smart contract function and in the geth codebase I want to add some logging code before and after the EVM executes the function.
I've been looking through the code base and am unsure of where the entry and exit points of the EVM are.


texts: A good way to decode transaction hash content on public Ethereum blockchain?

texts:
I want to check if there are some good tools available to decode the transaction hash to know the content on public Ethereum Blockchain? Primarily to validate the data stored by the dapp.
Thanks


texts: What is the best way to store a hexadecimal value in an array in Solidity?

texts:
I am attempting to store a hash (web3.sha3) into an array in a smart contract.

What is the best way to do that?


texts: Hi I'm sorry is there a way to easily track the creator of the nft? Because if it is not possible, then how could I know the nft is genuine and not a copy thank you


texts:
Is there a way to determine the version of the currently installed MetaMask extension from web3.js?

I can't find it by inspecting the Web3 instance.


texts: How to derive the storage key of mapping to an account?


texts: How to switch bitcoin to ether in coinbase

texts: I have btc in coinbase, how do I switch some of it to ethers? I don't have a bank account attached to it, and don't want to. I tried the coinbase information, but it says I have to attach a bank account.


texts: Issue "grabbing DAG" for ethminer (but not for expanse)

texts:
I installed Geth, and successfully synced the blockchain.  However, regardless of whether I use Ethminer, Ethminer with Stratum Proxy, or qtMiner; I always get the same error.  It doesn't really throw an error; the mining application just crashes.  For ethminer, the command I used is:

ethminer -U -F http://eth-eu.dwarfpool.com:80/0xc780f6a9de1cca4e3e5bb25e9dfe0ee52d6d87a6 (source)

The output I get is:

Forked from github.com/ethereum/cpp-ethereum
CUDA kernel ported from Tim Hughes' OpenCL kernel
With contributions from RoBiK, tpruvot and sp_

Please consider a donation to:
ETH: 0xeb9310b185455f863f526dab3d245809f6854b4d

Using grid size 8192, block size 128

Found suitable CUDA device [GeForce GTX 980 Ti] with 6442450944 bytes of GPU memory
miner  15:47:47|main  Getting work package...
miner  15:47:47|main  Grabbing DAG for #129656acΓÇª

When I use ethminer with Stratum Proxy, I get this line of output while ethminer is running:

2017-06-22 16:48:19,914 INFO proxy # Hashrate for 2130706433 is 0.0 MHs

Here's the troubleshooting I've tried so far:

Using different miners (qtminer, ethminer, etc.)
Using different mining pools (dwarfpool, ethermine, etc.)
Clearing the blockchain and resyncing more times than I
can count

I am attempting to mine on my Windows 10 machine with a NVIDIA GeForce GTX 980 Ti card.  At this point, I've spent several days reading/trying everything I can.  I suspect there's something dumb that I overlooked.  Any thoughts?  Thanks!

____________UPDATE:____________

Two observations:

If I switch ethminer to mine Expanse (change eth-eu.dwarfpool.com:80 to exp-eu.dwarfpool.com:81), then everything works perfectly.
I tried claymore miner, and it works.  However, it was much slower than mining EXP with ethminer; so I would prefer to figure out how to get ethminer mining ETH properly.


texts: Is web3.js an Ethereum blockchain client?

texts:
Reason is that I wanted to know what Ethereum blockchain client uPort uses and someone said it's web3.js.

I haven't understood this concept enough since I was expecting something like eth, geth or pyethapp. This may be a noob question but I just wanted to ask to clarify some things.


texts: mist wallet automatically connects to privatenet instead of testnet

texts:
I downloaded the mist wallet for ethereum and when i open up the program it sometimes connects me automatically to the private-net instead of the test-net. In this case i don't know how to change back and connect to the test-net. The option from the tab develop>network>testnet is grey (disabled).
In addition is there a way to change the setting of mist wallet and connect to ropsten testnet instead of morden?
thanks in advance


texts: What is the purpose of EVM tags, their haphazard arrangement and their relationship to functions?

texts:
I want to understand the purpose of tags in EVM assembly and their relationship with Solidity function.
pragma solidity ^0.5.1;
   import './Mod.sol';
   contract MOFTest{
       ModifiedBank mb;
       constructor(address payable addressOfBank, uint amount) public {}
       function deposit (uint amount )  payable public {
       }
}

For the above contract, I have downloaded the assembly part from the Remix IDE and attached it with the post.
I found that if I have a constructor then Remix IDE will have only 2 tags but now I have 2 functions and I found that there are 5 tags. Kindly explain me what is the purpose of tags and what is their relationship with Solidity functions? Also the tags are appearing in a haphazard manner, first tag1 and tag2 , then again tag1 and tag2, after that Remix IDE shows tag4, and then tag3 & tag5.
Zulfi.


texts: How to concat different parameters type in one parameter (bytes) and extract them?

texts:
I have a function that take 3 parameters

function askForHelp (string id, uint256 times, bytes32 signature)  {
  //do something
}

I want to change it to:

function askForHelp(bytes data) {
   string id = extractId(data);
   uint256 times = extractTimes(data);
   bytes32 signature = extractSig(data);

   //do something
}

//to implement
function extractId (bytes data) ;
//to implement
function extractTimes (bytes data) ;
//to implement
function extractSig (bytes data) ;

EDIT :
for concatination I am plannig to make it by this way:

//signature is already hex
//convert **id**: string  has a fixed size = 12 characters => fix hex size

let data = signature+web3.toHex(id)+web3.toHex(times);


texts: Is there any library to estimate timestamp of future block?

texts:
I am in need of a library that estimates a date or some sort of timestamp when fed with a future block number (on mainnet or any major testnet).

For instance, https://etherscan.io/block/countdown/9950000 shows up like this:

Unfortunately, I emailed Etherscan and the countdown feature is not available in their API (I probably could reverse engineer it by parsing the HTML response, but seems overkill).

Is there any library that does this?


texts: How to decrypt an encrypted message using metamask?

texts:
I have a message encrypted with the public key. Metamask has its corresponding private key (account). How can I decrypt it with the metamask? Does metamask provide such feature?

What I meant is just like while performing the web3.eth.sign function, metamask provides us the window to sign a message does it also provide some functionality to decrypt a message?

In my application server stores a code (text) encrypted with user's public key. In the client side (javascript) user first needs to decrypt this code to do some task. So, either I prompt user to enter its private key (which is considered a bad practice) or I use some wallet or account management like Metamask.

Please suggest.


texts: What does web3.eth.getStorageAt() return?

texts:
I want to know how this works: web3.eth.getStorageAt(addressHexString, position [, defaultBlock] [, callback])

What data we can store at any address and how? And what will this eth API return?


texts: How to retrieve "contract creation transaction" info for a particular contract using Etherscan API?

texts:
Assume i have the address of a contract, and now i would like to retrieve the information for its creation transaction. I used getCode(), but return bytecode for the contract, which is different. If i could get the hash of the creation transaction, i could easily retrieve its information.

Any idea of how to retrieve, at least, the hash of the transaction that created the contract, given only the address of the contract?.


texts: How to make truffle test work with ethers.js

texts:
I prefer the ethers.js library to web3. Is there a way to configure truffle test to use ethers.js instead of web3?

Thanks!


texts: Contract: Iterate each char inside string and numerical value check

texts:
For example I have following string, which will be given as input from a user:

string str = "0-00:03"

Inside my contract I would like to check that:

str[1] should be "-"
str[4] should be ":"
and the remaining
characters have to be numeric value.

This operation is easy to do C where with pointer I can iterate each character and check its char value. But I was not able to operate this inside my contract under Solidity language.


texts:
I'm blindly trying to implement OpenGSN in my contracts. I'm still not sure how it works. Do I need a special application running and scanning for signed messages on my computer to make it working?
I have an ERC20 contract which also contains a special payable function.
The payable function can't be split from token, it depends on balance.
Is it possible to make getEther function free for users but other functions like transfer will be via client's costs? I would like only let users to call this one function without costs. Also, how can I prevent from a situation where somebody calls 500x getEther and thus generates me only empty calls with costs?
Let's say here's my simplified contract
pragma solidity ^0.8.0;

contract MyContract
{
    receive()
        external
        payable
    {

    }

    function getEther()
        external
    {
        payable(msg.sender).transfer(1 ether);
    }

    function doSomethingButYouPay()
        external
    {

    }
}

It's easy to extend this with BaseRelayRecipient but I don't quite understand about next steps, like Forwarder, Paymaster, also how can I install OpenGSN on normal html + JS website...


texts: Is it safe to use pragma experimental "v0.5.0" in production ready code

texts:
Is is safe to use pragma experimental “v0.5.0”; in production ready code
As per solidity docs-:

Also try to enable the “0.5.0” safety features as early as possible by adding pragma experimental "v0.5.0"; . Note that in this case, the word experimental does not mean that the safety features are in any way risky, it is just a way to enable some features that are not yet part of the latest version of Solidity due to backwards compatibility.

I am just concerned whether we should use it in production ready code or not?


texts: Truffle: Why is my "onlyOwner" modifier not running in truffle?

texts:
I'm using a simplified version of a contract provided by Solidity website. My contract is as follows:

pragma solidity ^0.4.4;

import "./ConvertLib.sol";
contract MetaCoin {
   address owner;
   uint val;

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

    modifier onlyOwner {
    require (msg.sender==owner);
    _;
  }
  function change() onlyOwner{
  val=55;
 }
 function get_owner() returns (address){
 return owner;
 }
}

And my test contract is as below:

pragma solidity ^0.4.2;

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

 contract TestMetacoin {

 function test1(){
 MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());
 meta.change();
 }

 function test2(){
 MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());
 Assert.equal(meta.get_owner(), msg.sender, "I must be the owner");
}
}

I'm using testrpc. So first I deploy the 1st contract: "truffle deploy" and then I run the test one: "truffle test".

Problem: test2 passes but test1 cannot. If I remove "onlyOwner" from change() then test1 can pass.

Question: Why cannot test1 pass and what is the solution?

Please note that both contracts are compiled without any error.


texts:
In the following code, I am returning a wrong value but there is no syntax error:

pragma solidity ^0.5.1;
contract C1 {
  function g(uint a) public returns (uint) {  f(a); }
  function f(uint) public returns(bool) { }
}

function f(..) returns a boolean value but function g(..) requires uint.

Somebody please guide me why I am not getting any syntax error?


texts: What if a dishonest node execute a different program on EVM?

texts:
I want to create a program (on the Ethereum Virtual Machine), that can access some data under certains condition (only if authorized).
So the program checks the authorization, and then (eventually) accesses the data.

What if a dishonest node execute a different program that accesses the data without checking authorizations? Does Ethereum offer some protection against node that want to execute a program "alone"?
Or should I implement something that allows accessing that data only if a large part of nodes achieve consensus?

I hope I explained it clear.
Thank you


texts:
I have started working in blockchain for the last few weeks. I have created a private blockchain in my system using geth and added peers by using admin.addPeer() command. I have also created an application that uses this blockchain. In my application, I have used web3 to connect to the blockchain from front-end and I have also written some smart contracts which controls the activities of that application. After all this, I have also written a smart contract(ERC Tokens) to create cryptocurrencies which is used for payments in that application. It works well when I hosted in my private network. But now I want to host it to another server so that we can use that application from anywhere. Is truffle an option?

Can anyone help me to do this? And I would also like to know the system requirements or architecture of the server where the blockchain applications has to be hosted and also how to connect peers to a network by using the public IP address instead of local IP address. As local IP can change according the network it has connected.


texts:
We have seen the development of Private and Public blockchain (Permission vs Permission less). BitCoin the best example of a Public blockchain where any one can read the transactions, create transaction, become a node or miner.
How can we best describe Ethereum a Public or Private BC or it can be either any running the EVN in a closed environment.
Why I am asking this, as I am creating a dapp, which has all the supply chain parties as nodes in the Private, newly created chain (Monax BC).
So, it is possible to have out Private, Permission based BC in Ethereum also ?

And also how is the Microsoft Azure service BaaS which runs on top of Ethereum  provides a private BC ?


texts: Does it align with the base concept of blockchain, if one stores the hash value generated from IPFS network in a database?

texts: A friend of mine utilized IPFS to store data files regarding some user info.But for an android application of the same, he retrieved all hash values(same user but different files) and stored it in a database.I claimed that the security aspect was disrupted by it(since we use blockchain for security purpose) but he said that it's not the case. Could anyone comment on this?


texts: Function/Dataflow model or UML models of Ethereum

texts:
I am looking for models that are describing Ethereum or one of the clients, like geth (which basicly make up ethereum, right?)
Are there any of the common software models like function models or uml class diagramms as the picture below?   It would really help me understand how ethereum actually works.  Sorry if this question is too basic.  Thanks in advance]1


texts: Connect private blockchain to public blockchain

texts:
I need to connect my private blockchain to the public Ethereum blockchain, this is possible? Or this concept is the Consensus nodes?

Thank you,
Best Regards!


texts: Does Ethereum require miners to be a full nodes?

texts:
Does Ethereum require a miner to be a full node?

It is necessary for miners to be full nodes, i.e., they store all blocks and the entire state of Ethereum? Or can miners also be light nodes which fetch needed blockchain parts?


texts: Is it possible to create assets in ethereum which will automatically get linked with a particular address and will be able to send from one account to another without using a contract? I have seen that there is concept of tokens in ethereum, but what I want is to be able to create multiple assets and settle an exchange between them.


texts: Different comportement when bootnodes are set in command line and in static-nodes.json

texts:
I had a weird issue which was :

I have one bootnode:

bootnode -nodekey boot.key -verbosity 9 -addr :30310

Now I want to run my peers on the command line and I want them to add my bootnode as a peer to find each others, like that :

geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8501 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --networkid 1996 --gasprice '1' -unlock '0xcf767e1258bf88520634311fc45e77f6b4cdd72a' --password node1/pass.txt --mine --bootnodes "enode://3879643f63c5257485c10f41b3604023b9de7f96267f741fbac2cb6992a4071ba45544e4055181191ef31ab7b996211a690edbc44ed64951bc4a2e7dae2199a5@127.0.0.1:30310"

This was working.

But was not working anymore when I was setting my bootnode in node1/static-nodes.json like that (as it is described in the documentation) :

[
"enode://3879643f63c5257485c10f41b3604023b9de7f96267f741fbac2cb6992a4071ba45544e4055181191ef31ab7b996211a690edbc44ed64951bc4a2e7dae2199a5@127.0.0.1:30310"
]

and using this command (which the same as above without the bootnode flag):

geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8501 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --networkid 1996 --gasprice '1' -unlock '0xcf767e1258bf88520634311fc45e77f6b4cdd72a' --password node1/pass.txt --mine

After a lot of headache I solved my problem using sudo ntpdate -s time.nist.gov (which is also written in the documentation)

But does that mean that setting the bootnode on the file has a different action/meaning than setting it in the command line ? Why and is this an issue ?

Thanks,

Maxime


texts:
I'm starting programming. I wanted to do my first contract and I assigned totalSupply to 1000000.

pragma solidity ^0.5.8;

/**
 * The DappToken
  contract Constructor
  Set the total number of tokens
  Read the total number of tokens
 */

  contract DappToken {

    uint256 public totalSupply;

    function Supply () public {
    totalSupply = 1000000;
    }
}

When I run test it doesn't pass. It says actual totalSupply is set to zero. Here is the code:

var DappToken = artifacts.require ("DappToken");

contract("DappToken", function(accounts) {
    var tokenInstance;

    it("sets the total supply upon deployment", function() {
        return DappToken.deployed().then(function(instance) {
            tokenInstance = instance;
            return tokenInstance.totalSupply();
        })  .then(function(totalSupply) {
                assert.equal(totalSupply.toNumber(), 1000000, "sets the total supply to 1000000")
        });
    });
})

The result when I run truffle migrate is

Contract:DappToken
1) sets the total supply upon deployment
> No events were emitted

and doesn't pass saying
expected 1000000
actual 0


texts:
Why Transfer function doesn't check for allowance comparing to TransferFrom?
Do I need to call increaseAllowance each time before calling TransferFrom?

Ex implementation of Transfer without allowance check
    function transfer(address receiver, uint256 numTokens) public override returns (bool) {
        require(numTokens <= balances[msg.sender]);
        balances[msg.sender] = balances[msg.sender].sub(numTokens);
        balances[receiver] = balances[receiver].add(numTokens);
        emit Transfer(msg.sender, receiver, numTokens);
        return true;
    }


texts: What is the best way to store data/information while writing smartcontract?

texts:
Smart contracts are immutable. Unless we're 100% sure that our smart-contract is fully functional without any exception we never want to push that in the main net. That's why we have public test net.
I am writing a smart-contract that stores information in an array. I am worried about something after I deploy my contract in the main net and start using and saving information in the blockchain. Over time my requirement might change(which is hypothetical) and I had to update my contract and then re-deploy in main-net. Now how can I retrieve the information that was saved in the old contract address in the main net because now that I start using the newly deployed address?
Is there any way to link that saved information from the old contract address to the new one?
What is the best way to overcome this scenario?


texts: Do I need gas for each account to transfer ERC20 token?

texts:
I'm in the process of creating my own ERC20 Token.

The idea is similar to have a loyalty wallet where I'm able to send points to my customers. Also, the idea is to make some transfer functions to send points from one to another loyalty wallet (points transfer between customers) and from one loyalty wallet yo owner wallet (debiting points from one customer).

My question is... Do I have to send some ether to all my customers wallets? Or... Is it possible to have ether in the owner wallet to use it for all operations? (Even when the transfer is from a customer wallet and not from the owner wallet).

Thanks!


texts: Extremely simple factory contract works on testrpc/ganache-cli but not rinkeby

texts:
this very simple factory pattern is not working on rinkeby for some reason. Using truffle v3.4.5 and geth 1.7.3-stable. Here are the contracts:

pragma solidity ^0.4.11;

contract Factory {

  address[] public pizzas;

  function Factory() {
    // constructor
  }

  function cookPizza() returns (address _pizza) {
    Pizza newPizza = new Pizza();
    pizzas.push(newPizza);
    return newPizza;
  }

  function getPizzas() public constant returns (address[]) {
    return pizzas;
  }
}

contract Pizza {
  function Pizza() {
    // constructor
  }
}

When I deploy on ganache-cli and run:

truffle(development)> Factory.deployed().then(function(instance) { factory = instance})
undefined
truffle(development)> factory.cookPizza()
truffle(development)> factory.getPizzas()
[ '0xc4f8cf2d5a37e74981fffdab1b2108931822359a' ]

It creates a new address, appends and getPizzas shows me the addresses. When I deploy on rinkeby with the following:

Running migration: 1_initial_migration.js
  Deploying Migrations...
  Migrations: 0x42e40188763019dd09a6166b76805d329bd71111
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying Factory...
  Factory: 0xb9d60d9ddf16e3af3bce774a1e9286ecf5614166
Saving successful migration to network...
Saving artifacts...

In the console:

> sender = eth.accounts[0]
> abi = "abi"
> contract = eth.contract(abi)
> factory = contract.at("0xb9d60d9ddf16e3af3bce774a1e9286ecf5614166")
> factory.cookPizza({from:sender})
"0xf0ce6f4c0a9665f593d3d837eca4977b85d011dcb3620bf3a2428d25225db967"
> factory.getPizzas()
[]

Nothing. What could be causing this?


texts: I found there is a new metamask app on apple store, is this app open source and reliable? Since there are a lot of various wallets for app, which one is reliable?


texts: myContract.getPastEvents("allEvents") returns empty array

texts:
I want to get all past events from a contract I deployed on the Ropsten network.

Contract is:

pragma solidity ^0.5.1;

contract SampleContract {
    uint storageData;

    event MamboNumberTwo(uint _value);
    event MamboNumberFive(uint _value);
    event MamboNumberString(string _value);

    function test(uint x, uint y, string memory s) public {
        emit MamboNumberTwo(x);
        emit MamboNumberFive(y);
        emit MamboNumberString(s);
    }
}

It is deployed at 0xdd73A24Ef263D9bed42b0db60607F915194A7fbF, as you can see this contract has emitted nine events so far.
I would like to get them using web3's myContract.getPastEvents("allEvents"), but this returns a Promise resolving in an empty array, as though no event was emitted yet.

Full code:

web3 = new Web3(...) // Connect to Ropsten node via Websocket
var contract = new web3.eth.Contract([...], "0xdd73A24Ef263D9bed42b0db60607F915194A7fbF");
contract.getPastEvents("allEvents").then(console.log);

Any ideas? Thanks!


texts: Transaction executed through sendTransaction() not effective and not shown in Mist, private net

texts:
I am trying to execute a transaction in my private net using the Java
 Script console, with sendTransaction(), and the state variables that should change after the execution don't change, in other words it's not effective. When I execute it from Mist, it's effective. Any ideas?


texts: How to reduce blockchain size on a production node?

texts:
I have a production Geth node whose blockchain occupies around ~600 GB. I'm trying to figure out how to free up disk space. I know I can remove the blockchain and start fast sync from scratch, but that will take some time (probably more than a day) and it is not acceptable for a production node that is expected to be up 24/7. I can bring it down but for a couple of hours at the most. So my question is how to reduce blockchain size with a minimal downtime?

I was considering starting a new Geth node in parallel and have it fully sync, and then migrate the keys from the old node to the new one. But is there a better approach?


texts:
After succesfully setting up a POA network on azure (hurray for 1 click deployment), i wanted to set up a private Swarm cluster (well , 1 node will do for testing).

I took an AWS EC2 instance to save a little on my azure free credits (hue).

I've got the following ports opened for both IN and OUTbound traffic:

HTTP (8080) TCP
HTTPS (443) TCP
SSH (22) TCP
BZZ: (8500) TCP
BZZ: (8500) UDP

I've also opened up the port to ping the instance and can succesfully ping the public IP.

This is the command I'm using to start the instance. Please do note I've tried setting bzzapi to default, 0.0.0.0:8500 and the public IP.

ubuntu@ip-172-31-35-99:~$
swarm --bzzaccount b84c12c07f155d4ca0e1d0178367f426943eb056  --datadir swarm --keystore swarm/keystore --bzzapi http://18.221.205.37:8500 --ens-api "" --bzzport 8500 -corsdomain "*"

I can't connect to the endpoint

I can ping the instance however:

ping 18.221.205.37

Pinging 18.221.205.37 with 32 bytes of data:
Reply from 18.221.205.37: bytes=32 time=108ms TTL=41
Reply from 18.221.205.37: bytes=32 time=109ms TTL=41
Reply from 18.221.205.37: bytes=32 time=108ms TTL=41
Reply from 18.221.205.37: bytes=32 time=108ms TTL=41

Any ideas? I feel like it's similar to this issue: Connection Error - Couldn't connect to ethereum node on AWS at http://xx.xxx.xx.xxx:8545


texts: How are transactions classified that cause a smart contract to send ether to an EOA?

texts:
Let's say I send a transaction to smart contract which functions cause Ether to be send to another EOA. The Ether that the EOA receives must obliviously stem from a transaction. How would that transaction look like in Etherscan? Who would be the sender?
I feel like I am basing my question on a false assumption...
Thanks!


texts:
I am using node with express to serve HTML and JS files to port 3000. Sometimes the injected web3 get's recognised and things work fine and other times it does not. Strange things is that after page is loaded the injected web3 is available (see image)

Relevant JS code is:

$(document).ready(function() {
    if (typeof web3 !== 'undefined') {
        console.warn("Using web3 detected from external source like Metamask")
        // Use Mist/MetaMask's provider
        window.web3 = new Web3(web3.currentProvider);

    } else {
        window.alert("No web3 detected. This site is a Web3 Dapp - to proceed you will need to get Metamask https://metamask.io/");
    }

});

How can I guarantee that the web3 is available in time every time the page loads?


texts: How do remote nodes fit into a Dapp architecture?

texts:
The eth-lightwallet  describes "remote nodes" in its implementation.

  This allows you to have full control over your private keys while
  still connecting to a remote node to relay signed transactions.

What are remote nodes and when are they used?

Are there examples of remote node providers?


texts:
Question on the following function:

function getEvens() pure external returns(uint[]) {
  uint[] memory evens = new uint[](5);
  // Keep track of the index in the new array:
  uint counter = 0;
  // Iterate 1 through 10 with a for loop:
  for (uint i = 1; i <= 10; i++) {
    // If `i` is even...
    if (i % 2 == 0) {
      // Add it to our array
      evens[counter] = i;
      // Increment counter to the next empty index in `evens`:
      counter++;
    }
  }
  return evens;
}

What is the point of keeping track of the index of the array instead of simply calling evens.push(i)


texts: How to read block propagation delay from ethstats.net?

texts:
I am wondering what is the average (or mdeian) time it takes to propagate a block in the Ethereum blockchain?

I found ethstats.net provides a cummlative graph for block block propagation but do not know how to extract the average or median time from it?

Is there any easy way to check it?


texts: What do these geth --rpcapi parameters mean: db and net?

texts:
Many times in different guides I met the following string to start geth:

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

Here we can find commands provided by admin, personal, eth options. But what do "db" and "net" mean and allow? And is "eth" option needed in case of web3j requests?


texts: What elements of a Dapp's backend are usually stored in a decentralised location?

texts:
I'm unclear as to what elements of a Dapp's backend code are actually decentralised.

The following link states that a Dapp's backend is stored entirely on the blockchain. However, if I was to create a Dapp web application, how much of what would usually be referred to in a web development sense as the "backend", actually be located on the blockchain?

For instance, if I was to develop a web app using Python, would the entire function of my Python code be replaced by a smart contract if I was developing a Dapp, or just the key elements of the business logic?


texts: transfer function is not working for the smart contract

texts:
Below is the Scenario of the problem: I made some changes in the real concept because it will hard to understand the problem so I try to make it real simple.
I make a contract to facilitate some buying and selling of goods. A user (Alice) will create the smart contract(say goods contract) to sell its goods by using some factory contract and initialize the goods contract with some variables, then Alice will call a function to set the properties of the goods where Alice need to transfer Y amount of token as a security of successful transfer of good. for doing so a token proxy contract get also created in the same functions and transfer all those Y tokens to that token proxy contract.
Another user(bob) will buy the good. and after buying bid he did not want any product or there may be many reasons and needs settlement. For settlement, Bob called some function called settlement of goods contract and then the number of tokens will get back to bob from the token proxy contract.
Here in settlement() there is an internal call to distributeStakes() function of tokenProxy contract which calls a transfer function of the token and transfers the stakes to respective account.
Below is the goods contract
function issueGoods(uint256 _assetsOffered, uint256 _premium, uint256 _expiry) public {
   require(createProxy(_expiry));
   uint256 assets = _assetsOffered * strikePrice * 10 ** uint256(DECIMAL_FACTOR);
   require(QT.transferFrom(buyer, tokenProxy, assets));
   balances[this] = _assetsOffered;
   assetsOffered = _assetsOffered;
   premium = _premium;
   expiry = _expiry;
   Transfer(0x0, this, _assetsOffered);

}
function createProxy(uint256 _expiry) internal returns(bool) {
   tokenProxy = new Proxy(baseToken, quoteToken, _expiry, price, buyer);
   require(addressHasCode(tokenProxy));
   proxy = IProxy(tokenProxy);
   return true;

}
function settlement(uint256 _amount) external returns (bool) {
   uint256 amount = _amount * 10 ** uint256(DECIMAL_FACTOR);
   require(proxy.distributeStakes(msg.sender, amount));
   // Provide allowance to this by the trader
   require(this.transferFrom(msg.sender, 0x0, _amount));
   return true;

Below is tokenProxy contract
contract Proxy is IProxy {
  IERC20 public BT;
  IERC20 public QT;
  address public option;
  address public buyer;
  uint256 public dealExpiry;
  uint256 public price;
   function Proxy(address _baseToken, address _quoteToken, uint256 _expiry, uint256 _strikePrice, address _buyer) public {
      BT = IERC20(_baseToken);
      QT = IERC20(_quoteToken);
      dealExpiry = _expiry;
      price = _price;
      buyer = _buyer;
 }

   function distributeStakes(address _to, uint256 _amount) public returns (bool success) {
        require(QT.transfer(to, amount));
        require(BT.transferFrom(_to, buyer, _amount));
     }
     return true;
 }

}
For some reason settlement call doesn't get executed successfully. When I debug the tx it went down at the distributeStakes() function line require(QT.transfer(to, amount)) by giving the revert error. I don't understand the reason. and at truffle debugging it me this.

debug(develop:0x9757d361...)>
(596) PUSH1 0x60
No data on stack.
? | 0x9efec315e368e8812025b85b399a69513cd0e716:
1: // No source code found.

Any help is very much appreciated.


texts: How can I calculate the Ethash of a Block

texts: Given a particular block number, how can I calculate the Ethash used by this block?


texts: how to generate multiple accounts that all debit one single account at the end

texts:
I know that it is not possible to create multiple addresses that are bound to one ethereum wallet unlike in bitcoin.

However, I am trying to create an ico page where each user should get unique ether address into which he can do payment.

an example is this page: https://tokensale.amon.tech

I want to do the exact same thing. How is it possible programmatically to achieve this?


texts: Choose Ethereum smart contracts or Cardano Plutus?

texts:
I am new to blockchain technology and exploring ways to build my own smart contracts or blockchain. I was initially exploring the PoS based Cardano platform but when I found that Smart Contracts in Cardano are still in develpment phase and yet to be released, I started looking for some other technology. Then I show Ethereum is a good platform to build Smart contracts but instead uses PoW with solidity which is easier to learn and many materials available online to learn(Plutus which is derivative of Haskell- which I found difficult to learn).
Now I am confused whether to use Ethereum or not to build my blockchain which has many scalability issues due to PoW that's why I was initially exploring Cardano. Is it worth it to concentrate my study on Ethereum?
It would be really helpful if someone could guide because I know very little about the field of Blockchain.
Thanks


texts: How can deploy contracts to the blockchain without having a full node?

texts: Synchronization Mist is going on for too long, how can I deploy a contract?


texts: Function and withdrawal does not recognize the address as payable

texts:
I have this withdrawal function but an error happens:
TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address". --> sd.sol:138:13: | 138 | msg.sender.transfer(withdrawAmount); | ^^^^^^^^^^^^^^^^^^^

Code:
function withdraw(uint withdrawAmount) public returns (uint remainingBal) {
    // Check enough balance available, otherwise just return balance
    if (withdrawAmount <= balances[msg.sender]) {
        balances[msg.sender] -= withdrawAmount;
        msg.sender.transfer(withdrawAmount);
    }
    return balances[msg.sender];
}

I can send WEI for my contract, so it stores the WEI but I want to be able to withdraw them.
Link do contrato


texts:
I made four accounts and lost the passwords to the first three. I am trying to run truffle migrate, but I am worried that truffle is trying to use the first address that I created rather than the latest one for which I still have the password. How can I either:

A) Delete the first 3 addresses without the passwords

or

B) Set the default address to the latest one?

References to errors:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: authentication needed: password or unlock


texts: What is the OP_CODE for getting another account (storage and/or code)?

texts:
I'm debugging solidity opcode by opcode. How do I tell when the compiler is referencing another smart contract through OpCode?

I know that you can do this in Browser Solidity. However I would just like to know the OpCode for "pointing" to data inside another contract, and how the contract's address is expressed into that opcode.


texts:
I read here that EIP-86 can allow transactions to be paid for by a contract being called. I understand how child-pays-for-parent works in Bitcoin, but EIP-86 does not appear to work at all in the same fashion. I feel like I could spend the time trying to grok the EIP and sort things out rather than skimming it like I just did, but there are a number of things that are unclear to me at first blush. For example, I'm not familiar with Serpent, so I don't know if the example account contract is an entire contract or an entry point for a method -- and, if so, which one; then there's the "(2) and (3) introduce a feature similar to bitcoin's P2SH, allowing users to send funds to addresses" -- but no (2) or (3) near by; I guess that refers to "ring signature mixers" and "custom cryptography".

Could someone please give a high level overview of how EIP-86 enables the contract to pay for the transaction so that I can go back and follow along in the original text? What I'm worried about is DoS attack models (the last part about miner strategies alludes to possible attacks) and would like to be able to assess if that's a real problem. No, I'm not trying to attack it, but I'm also not so knowledgeable that I think I can contribute anything of value to the EIP discussion :) Thanks!


texts: How do I make it so my token can be added to uniswap liquidity pool, but not traded until a set time?

texts: I got airdropped a token that did this, but I cannot recall what it was. I know it is possible. I have been told it might be something to do with the deadline variable in the permit function of the UniswapV2ERC20.sol contract, but I cannot figure it out for myself.


texts:
One thing I don't understand about the Ethereum protocol is how timestamps work. If I, as miner, have a reason to fiddle with timestamps (such as adding a few minutes to decrease the mining difficulty) I simply produce a block with a timestamp which is a few minutes larger than the current UNIX time.

I suppose that this is not possible, but I don't understand how this is enforced. Does the network simply not allow blocks which have a drift time which is too large compared to the current time? Or is there some kind of protocol in place which disencourages miners to create invalid timestamps?


texts: Is the "transfer" call in Solidity asynchronous?

texts:
I'm asking myself if the call to a function like transfer in solidity is asynchronous.
In other words, I'm working with the following contract
function count_and_pay() public {
    if (lockCon == true)
         return;
    if (positiveVote > negativeVote) {
        candidate.transfer(proprietyContract);
    } else {
        escrow.transfer(proprietyContract);
    }
    lockCon = true
}

I'm a little worried here because I'm not able to find any resource where it saying the call escrow.transfer(proprietyContract); make the transaction and will continue in the execution of the call.
In my knowledge the method is asynchronous and it will create only the transaction of the blockchain and will continue the execution. With this scenario, my code should be technically correct (but without meaning).


texts: Out of stack DUP2 1/1024 when adding string to parameter

texts:
The below function was working fine until I added a string parameter and saved the string to a mapping. Now when I call it it fails with an 'out of stack' exception. Is there something I'm doing wrong related to strings? What would cause an out of stack exception in this case?
https://kovan.etherscan.io/tx/0xacfe4ec5acbdf57da0fd099e94b03712eb1f537f9a794b4c42ad362478f1cb0e
 function launch(uint256 amount, address player, string memory name) public returns(bool){
    ...

    balances[player] = amount;
    names[player] = name;
    addresses.push(player);

    emit created(player, amount, name);
    return true;
}


texts:
What do you meant by settlement engine in ethereum? I need a payment settlement engine that to be based on ethereum for cryptos and security tokens.
Is the same as escrow ?
Any open source link for reference to analyze . Is the openbazaar works on the same concept.


texts:
I am a new！

code:

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

why the error is web3.isConnected is not a function?
thx!


texts: Can a contract duplicate another contract

texts: If a contract A is given an address of another contract B, can it duplicate B and produce B' that has the same code?


texts:
Hello to everyone I am quite new in the Ethereum. I am writing my Solidity contracts, deploy them using  Truffle on TestRPC. I have few questions regarding TestRPC in order to understand it.

When I install testRPC on my macbook, do I have my macbook as only node here?

Are testRPC accounts Externally Owned Accounts?

Does testRPC have mining option, or does my macbook do mining job?

Why the length of my transaction block is equals to one, and can I setup it on some other value?

Thank you for your answers!


texts:
I want to run a session for a product in auction , my product struct contains the time interval we need for being the session of the bidding.

While initializing a product, I need to take the input of how much time interval they want their product to be in active bidding.

How can I take the inputs ?


texts:
I was reading this thread:
What do the 3 different peer numbers represent in Parity?

And I realized that I don't understand the difference between active and connected regarding peers.

I have a private network I'm playing with, and three Parity nodes.  The readout on two of them is:

0/ 1/25

and the third:

0/ 2/25

I assume there is a firewall problem, but I also don't know how to get any of the 0s to be 1s or 2s.

Thank you.


texts: What are effective techniques to encrypt/decrypt data stored in a smart contract?

texts:
Rather than sending and storing plain text in a smart contract, the use case objective is to encrypt first and then subsequently access the data and decrypt at the point of use.

What is the most effective and efficient way of achieving this data security, ideally using web3js?


texts: How to avoid price dump inside the code of a token

texts:
I'm planning to create my own token (Binance Smart Chaine C.) my first attempt was succesfull. But I'm trying to figure out how to avoid price dumping by whales. A Solution would be if i could adjust the selling fee like safemoon does (10%) but i haven't found the line in the code to set the fee.
I know that this question is very general, but maybe someone could help me a bit fourther.
Thanks


texts:
How can I permission a quorum network?
Imagine I have 3 nodes in my network and I install another node in my friends house.

How can I prevent my friend add more nodes to my quorum network?

thanks


texts: what is a standard .gitignore for truffle?

texts:
I'm using the latest Truffle. Very nice, after having to roll my own dev environment in early 2016! But there is no obvious documentation as to what parts of the project need to be checked into Github.

For example, I'm unsure if the build directory needs to be checked in.  I think the answer is 'yes' because one would want to remember what the format of the contracts that have been deployed, but I'm unsure.


texts: Most efficient way of generating random ERC 721 NFT

texts:
I'm just getting into Solidity by building a first project around collectibles, ERC 721.

There's for example 1500 different collectibles, each has an available amount defined by a criteria. These collectibles will be distributed in packs of 5, totally randomly after an initial purchase. These collectibles will be generated from a database that has properties like "name", "image", "id", etc

How would one go about generating 1500 * availability tokens (amounting to a total of 150000 tokens)? Pass an array of ids to a function called only once from a specific private address and generate them and store them in a mapping storage? I'm anticipating this will require a lot of gas, how could I evaluate the costs of creating such a large number of tokens?


texts: Hi ,am getting Parsing Error :Primary Expected Exception

texts:
Could you please help me in resolving the error "Parsing Error :Primary Expected Exception " below is very simple code

contract TestString {
    function stringConcat(string a, string b) public returns (string) {
        bytes memory strA = bytes(a);
        bytes memory strB = bytes(b);

        string memory finalLength = new string(a.lenght + b.lenght);

        bytes memory finalStr = bytes[finalLength];

        uint k = 0;

        for(uint i = 0; i < a.lenght; i++) {
            finalStr[k++] = strA[i];
        }

        for(i = 0; i < b.lenght; i++) {
            finalStr[k++] = strB[i];
        }

        returns string(finalStr);
    }
}


texts: I want to maintain a datastore of key value pairs. For example, I have users of my dapp input their favorite food. I would like to map their account to the food name. It is my understanding that I can do this through a smart contract or I could store it on swarm. What are the distinctions between data stores on swarm and those that are within a smart contract? Do I get more privacy by storing my data on swarm rather than through EVM state?


texts: Cannot transfer ERC20 token, "Bad instruction" error

texts:
I'm trying to transfer an ERC20 token from account A to account B. Account A deployed the contract and owns all tokens.

Looks like I'm missing something very obvious.

Every time I try to transfer tokens from one account to another, I get a error. Here is an example of erroneous transaction.

Addresses in question:

Account A: 0xd8e05701eff33acfda0a8e24c04070347703c72c
Account B: 0x3a70ceac36c8111a95b573d76ad75b7ba898662b
Contract: 0x1caf5380b7adc2e4e93c2828f895693ff38c3947

I'm doing the following (the code is in Ruby, but should be self-explanatory):

require 'ethereum'

value = 14

account_a_address = "0xd8e05701eFf33acfDA0A8e24C04070347703c72C"
account_b_address = "0x3A70Ceac36c8111a95b573d76aD75B7ba898662b"
contract_address = "0x1caf5380b7adc2e4e93c2828f895693ff38c3947"

Ethereum::Singleton.setup do |c|
  c.default_account = account_a_address
end

Ethereum::Contract.create(
  file: "/Users/gmile/projects/ico-scripts/contracts/02-14-2018-1518620826/contract_text.sol",
  address: contract_address
)

contract = EugeneToken.new
tx = contract.transact.transfer(account_b_address, value * 1_000_000_00)

puts tx.id

For some reason the transaction is qualified as Contract Creation. Why?

I double-checked with the documentation for ethereum.rb Ruby gem. The readme states that I can use the contract from blockchain by specifying an address of the contract deployed, as well a path to .sol file as parameters to Ethereum::Contract.create() call.


texts: How much ether I should have in my wallet to send 1 ETH to an ICO

texts:
I need to send 1 ETH to an ICO. I have 1 ETH in my wallet. I am using myetherwallet.com

Question .

If I send 1ETH to the contract address, will it fail for insufficient fee amount ?
How much do I need to have in my wallet to send 1 ETH to the contract address ? Is it ( 1ETH +  transaction Fee i.e, Gas) ?


texts: What programs should a beginner solidity developers use?

texts: At this time I write code in the 'Solidity realtime ethereum compiler and runtime' chrome extension. And I test my codes on the main net. Are there better programs or how can I get test ether?


texts: How to call geth mining through java code manually ?

texts:
I am using web3j and Geth and created a private network. However, I want to do the mining manually whenever required, since don't want to jam the server when I am in the development phase. For that, I found JsonRpc2_0Geth update in web3j and used it. However, mining does not start. Please help me where I am going wrong.

pom.xml

<dependency>
        <groupId>org.web3j</groupId>
        <artifactId>core</artifactId>
        <version>4.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.web3j</groupId>
        <artifactId>geth</artifactId>
        <version>4.0.1</version>
    </dependency>

Then, i called the Geth aPI through my java file as follows:

static public Web3j web3j = Web3j.build(new HttpService("<geth ip>:<port>"));
static public JsonRpc2_0Geth geth = new JsonRpc2_0Geth(new HttpService("<geth ip>:<port>"));
geth.minerStart(1000);


texts:
I would like to set a default account for my web3 operations with web3js but it does not work.

I'm using web3@1.0.0-beta.29 and here is my code.

  const Web3 = require('web3')
  const Token = require('./Token.json')

  const web3 = new Web3(new Web3.providers.HttpProvider())//provider.web3
  web3.eth.defaultAccount = '0x4615ff6690a3bb23bd85051c5c69abba4092bbb4'
  const tkn = new web3.eth.Contract(Token.abi, '0xba9d4199fab4f26efe3551d490e3821486f135ba')

  tkn.methods.transfer('0x4615ff6690a3bb23bd85051c5c69abba4092bbb4', 1e9)
    .send()
    .then(console.log)
    .catch(console.log)

the output of this is

    Error: No "from" address specified in neither the given options, nor the default options.

the documentation says that this should not happen


texts: I am new to IPFS. Is there any need for checking where the IPFS file originates from for security purposes?

texts: I want to identify the ipfs source node. Is it necessary to do that in IPFS?


texts: How do I tell if initial geth sync is done in 'light' mode on testnet

texts:
I just installed geth on Windows 10. Then I did the initial sync in light mode on testnet, and my status is as shown on the screenshot below.

I have two questions (related):

How do I tell if the sync is done?
If it is done, can I now close this command window before I start my experiments, say a "Hello, World" smart contract.

Update:

I tried geth attach as suggested by abattia, and got this error:


texts: How to config geth node to get ERC-20 tokens balances

texts:
I'm trying to tune my geth node to get ERC-20 tokens balances, but y API call always returns

{'jsonrpc': '2.0', 'id': 1, 'result': '0x'}

My geth node version:

instance=Geth/v1.9.13-stable-cbc4ac26/windows-amd64/go1.14.2
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

I have fully synced node (200Gb size)

I've tried to connect my node from MyCrypto wallet. It works well (main balance), but I can't get token balances via my geth node.

Also i've tried to use python pyetherbalance module.

import pyetherbalance
ethbalance = pyetherbalance.PyEtherBalance(infura_url)
balance_omg = ethbalance.get_token_balance('USDT', ethereum_address)

eth_call retruns always {'jsonrpc': '2.0', 'id': 1, 'result': '0x'} if I connecting to my geth node, but it work well with infura node

eth.blockNumber = 10040830

Command line:

geth - -rpc - -rpcapi "db, txpool, ethash, eth,net,web3,personal" - -rpcaddr = "127.0.0.1" - -rpcport = "8545" - -rpccorsdomain = "*"

Api python code:

address = "0x......"
contract_address = "0xdac17f958d2ee523a2206206994597c13d831ec7" # USDT
abi = '0x70a08231000000000000000000000000' + address[2:]
params = [{"to": contract_address, "data": abi}, "latest"]
response = json_rpc_post('eth_call', params, 1)


texts: Difference between MythX and Mythril for security auditing

texts: I know that both mythrix and mythril are used for smart contracts auditing but I didn't figure out yet the difference between them. I'll appreciate any help.


texts: Deploying contract template using web interface & Metamask

texts:
I have a contract template. The idea is to enable visitors to my website to customise and deploy the contract using Metamask by providing a set of constructor variables and outputting the resulting contract address after the transaction has been mined.

Can anybody point me in the right direction?


texts: how to get the full list of block reward for the last 24 hours? Either via an API/JSON or Google BigQuery

texts:
I have spend a couple of days now trying to find a good source for the block rewards that will allow me to calculate block rewards and averages for the last 24h and since UTC0.
(I am aware of being able to query individual blocks via How to query the amount of mining reward from a certain block?, however I would kill that API, querying every block of the last 24 hours every time I run my script)
Does anyone know a good API / json file I can pull regularly to calculate those rewards, e.g. of all the blocks from the last 24 hours in one go and do the calc myself?
Been trying to manually reconstruct the block reward calculations in Google's public data set VIA bigquery-public-data.crypto_ethereum but its doing my head in. Or does anyone know the BigQuery SQL to calculate those rewards via the public data set? Not sure how if its possible via https://blog.cloudflare.com/cloudflare-ethereum-gateway/ there is not much documentation on it.
e.g. https://bitinfocharts.com/ethereum/ is a good starting point but their data is not updated frequently, wondering what their source is.
much appreciated


texts: Why are selfdestructs used in contract programming?

texts: I'm reading bits and pieces that selfdestructs within contracts are a good thing.  Can someone explain what the benefits are of doing a contract selfdestruct when it comes to Ethereum programming? Is there a difference if you're using different clients or implementations, or languages?


texts:
This is the code i'm using to send payment from one address to another. But why do i get this error?
TypeError: web3.eth.sendRawTransaction is not a function

Here is the code im using

var Web3 = require('web3');
var Tx = require('ethereumjs-tx');
// Show Web3 where it needs to look for a connection to Ethereum.
//web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545'));
web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/N6IIa2HvDYOovtgmPbhD'));
var gasPrice = "2";//or get with web3.eth.gasPrice
var gasLimit = 3000000;
var addr = "0x......................";
var toAddress = "0x..............................";
var amountToSend = "0.00192823123348952"; //$1
var nonce = web3.eth.getTransactionCount(addr); //211;
var rawTransaction = {
"from": addr,
"nonce": web3.utils.toHex(nonce),
"gasPrice": web3.utils.toHex(gasPrice * 1e9),
"gasLimit": web3.utils.toHex(gasLimit),
"to": toAddress,
"value": amountToSend ,
"chainId": 1 //remember to change this
};
var privateKey = ".........................................................";
var privKey = new Buffer(privateKey, 'hex');
console.log("privKey  : ", privKey);
var tx = new Tx(rawTransaction);
tx.sign(privKey);
var serializedTx = tx.serialize();
console.log('serializedTx : '+serializedTx);
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
if (!err)
{
console.log('Txn Sent and hash is '+hash);
}
else
{
console.error(err);
}
});


texts:
Is it possible to import a library into another library?
I give a simplified example below of what I'd like to achieve:

library structLib {
    struct Point {
        uint X;
        uint Y;
    }
}

import "./structLib.sol";

library ellipticCurveOperations {

    //adds point p1 to point p2
    function addition(Point p1, Point p2) internal returns (Point r) {

        //convert struct to array for use in precompiles
        uint[4] memory input;
        input[0] = p1.X;
        input[1] = p1.Y;
        input[2] = p2.X;
        input[3] = p2.Y;
        bool success;

        //use assembly to call Elliptic Curve precompile
        assembly {
            success := call(sub(gas, 2000), 6, 0, input, 0xc0, r, 0x60)
            switch success case 0 { invalid() }
        }
        require(success, "EC addition failed");
    }

import "./ellipticCurveOperations.sol" as Ops

contract addThings{
    using Ops for *;

    function add(Ops.Point a, Ops.Point b) public returns (Ops.Point){
        return Ops.addition(a, b);
    }
}

Would this work? Is there any syntax I need to change?

Many thanks!


texts: What is the strength of Mist wallet encryption?

texts:
I would like to know what is the strength of the encryption the Mist wallet provides with the password-protected files, and if I can just throw these files around (even uploading them to the internet) if my password is strong enough.

What I mean to ask is: If my password is 304 bit key, is the encryption on the key files is 304 as well?

Thanks.


texts: If everyone runs the same transaction, why does only the miner get gas?

texts:
If I understand Ethereum correctly, the result of a transaction is known and verified by everyone because everyone runs the code using their own copy of the blockchain. If that is indeed the case, why is it that only the miner of a block gets the gas for the transactions in that block? I would understand if it was because of the resources they used to complete the proof of work, but if that were the case then the amount of gas would not depend on the VM instructions executed. I also have heard that the main purpose of gas is not so much to reward the miner as it is to provide mitigation and/or a disincentive to infinite loops and whatnot. In this case, I can see two scenarios:

The cost of the gas far outweighs the resources needed to execute the code, i.e. it is only there as a protection from denial of service attacks, etc.
The cost of gas is in fact proportional to the cost of running the code, and thus is also there to provide an incentive to the miner to run it.

If scenario 1 is accurate, wouldn't miners prioritize more CPU-intensive contracts in order to get the most gas, as opposed to prioritizing contracts with the highest cost per unit of gas?

If scenario 2 is accurate, what is the incentive for non-miners to run the code?