texts: mismatch when testing fund withdrawal with truffle + testrpc

texts:
I'm trying to test a withdrawal function of my contract through truffle over testrpc. The function is following the "withdrawal from contracts" patter described here. Essentially a notifyPayment() function is invoked to fire an event and put some funds in a pendingWithdrawls[address] mapping; the recipient can then invoke a withdraw function to attempt to retrieve the funds. This seems to work, but the amount the recipient gets is slightly less than what expected, even taking transaction fees into account. Here's the testing code in truffle:

it("should allow withdrawal and remove pending funds when withdraw", function() {
  var account_one_starting_balance;
  var account_one_ending_balance;
  var account_one_starting_pending;
  return SLA.deployed().then(function(inst) {
    instance = inst;
    account_one_starting_balance = web3.fromWei(web3.eth.getBalance(accounts[1]));
    console.log("starting balance", account_one_starting_balance.toString(10));
    return instance.pendingWithdrawals.call(accounts[1]);
  }).then(function(pending){
    account_one_starting_pending = web3.fromWei(pending);
    console.log("pending withdrawal", account_one_starting_pending.toString(10));
    return instance.increaseFunds({from: accounts[0], value: 2*pending});
  }).then(function(funds_txid){
    return instance.withdraw({from: accounts[1]});
  }).then(function(withdraw_txid){
    var tx_cost = web3.fromWei(web3.toBigNumber(withdraw_txid.receipt.gasUsed).times(web3.eth.gasPrice));
    console.log("transaction cost", tx_cost.toString(10));
    account_one_ending_balance = web3.fromWei(web3.eth.getBalance(accounts[1]));
    console.log("ending balance", account_one_ending_balance.toString(10));
    var account_one_credit = account_one_ending_balance.minus(account_one_starting_balance);
    // the next assertion fails
    assert.equal(account_one_credit, account_one_starting_pending.minus(tx_cost), "account one was not credited");
    return instance.pendingWithdrawals.call(accounts[1]);
  }).then(function(newPending){
    assert.equal(newPending.toNumber(), 0);
  }).catch(function(error){
    console.log(error);
    assert.fail();
  });
});

notice that I went a bit overboard with big number conversion as I thought it could be a rounding problem. Here is the result of the test:

starting balance 100.030220199999944206
pending withdrawal 0.01
transaction cost 0.00037196
ending balance 100.038360399999944206
{ AssertionError: account one was not credited: expected { Object (s, e, ...) } to equal { Object (s, e, ...) }
    at /home/-/src/sla-solidity/test/sla.js:128:14
    at process._tickCallback (internal/process/next_tick.js:109:7)
  message: 'account one was not credited: expected { Object (s, e, ...) } to equal { Object (s, e, ...) }',
  showDiff: false,
  actual: { [String: '0.0081402'] s: 1, e: -3, c: [ 814020000000 ] },
  expected: { [String: '0.00962804'] s: 1, e: -3, c: [ 962804000000 ]
} }

commenting out that assertion makes the test pass. What causes the difference in the credited amount? I'm sure I must be missing something trivial...


texts: How does mining software choose transactions?

texts:
How does mining software choose transactions from a memory pool to include them in a block?
Does mining software just include transactions in order each time it receives them? Or they choose transactions which has higher fees?


texts: Best practices on testing an orchestrated contract

texts:
Let's define an orchestrated contract as one that contains at least one function that can be called by another contract - and that contract only.
The function would implement the restriction like this:
function foo() external {
  require(msg.sender == someOtherContract, "ERR_NOT_AUTHORIZED");
  ...
}

How would one go about writing a unit test for such a function?
I see two possible solutions:

Replace msg.sender with a getMsgSender() function that is moved to a library, which is stubbed while testing
Stub msg.sender, but no Ethereum development framework I'm aware of (Truffle, Waffle or Hardhat) can do this

Is there a third solution? None of the above excite me. For the latter I'm at the mercy of the framework devs.


texts: I think I should have several tokens in my account, but I can only see Ether. Is a wallet contract necessary to see ERC-20 tokens?


texts: How to map an address with a string array in solidity?

texts:
Goal: I wish to store an array of names with an address in a smart contract. It's more like Key-Value pairs where addresses are paired with a list of type strings.

Can I use mapping to implement this? See below for instance.

mapping(address => strings[]) userAddress2UserNames;

Or, there is a different approach to it?

Experiments I performed

I got no error when I compiled the above code but when I call a method which returns string[] from this mapping I got an error stated below.

TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.

I'm not much aware of this version but I am assuming I should not do production level implementation with it because may be it's not stable. (Please correct me if I am wrong)

Please suggest me a way to achieve my goal.


texts:
Dear all, I am very new to Ethereum, noob-new. This might anger many but, i have to ask, why is pragma solidity not functioning correctly. I have seem countless examples where pragma solidity ^0.4.0; works, but why doesn't it work for me? I tried this out on remix.ethereum.org, the ethereum browser based compiler.

I receive this error, help please, anyone!

browser/Untitled.sol:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition.
pragma solidity ^0.4.0;

Here is the code:

pragma solidity ^0.4.0;
contract MyfirstContract{
    string private name;
    uint private age;

    function setName(string newName){
        name=newName;
    }
    fucntion getName() returns (string){
        return;

    }

}


texts: How to manually approve a token for swap on Uniswap (direct contract interaction)

texts:
I want to approve token spending on Uniswap for a token I don't own. Uniswap UI won't let me do that (instead it displays a gray out button "insufficient balance").
Seems the only option would be to manually approve the token using Etherscan.
Which Uniswap contract should I interact with? (v2)
What are the required parameters and what is the uint for infinite approval?


texts: Error:gas required exceeds allowance (9975570) or always failing transaction

texts:
I am trying to calculate the gas limit, to conduct an erc20 token transaction from 1 address to another and get this error:Returned error: gas required exceeds allowance (9975570) or always failing transaction can you help interpret it?

    let contract = new web3.eth.Contract(ABI, token_contract_Address, {
    from: Address
})
const acc_balance= contractInstance.methods.balanceOf(walletAddress).call(async function(err, result) {

    await web3.eth.estimateGas({

        "to": token_contract_Address,
        'data': contract.methods.transfer(fromAddress, web3.utils.toHex(result)).encodeABI(),

    }).then((value) => {
        console.log("gas limit: " + value);
    })
})


texts: unable to write transactions on rinkeby from javascript file

texts:
I have written a contract which read and write data into blockchain using truffle.
when i deployed that contract on rinkeby and called functions using web3.js the read functions works fine.
but write function does not work.
On reading i came to know that each transaction has to be signed by private key , but could not find proer tutorial or steps on this.

I have checked web3 provider and it seems to be ok and isConnected() returns true.


texts: How to upgrade solidity compiler in truffle

texts:
I couldn't find a way to upgrade a version of truffle solidity compiler.
Also curious how to see that information for deployed contracts in truffle console


texts: How can the "Random Beacon" proposal guard against bribes?

texts:
The Random Beacon proposal suggests a scheme where K-of-N signatures are used to sign a random number. It suggests that the only way for a random number to be corrupted if all K signers are corrupt; it takes only one honest signer to make the signature valid.

My question is: why would there be a honest signer? Game theoretically, if the value of the random number is high enough, it makes rational sense that the K signers make a deal to corrupt the random number and split the reward between themselves - i.e., it takes one interested party to bribe all the others, making all signers dishonest. Why should an outsider trust one of the K signers is honest?


texts: How can I force a redownload of the entire blockchain on the mist wallet?

texts:
I'm having an invalid date issue on mist. (https://github.com/ethereum/mist/issues/525)

I'd like to just try to redownload the blockchain again.

How can I do that ?


texts: Problem with decimals when setting price for ico

texts:
/// @notice Constructor of the contract
function startToken() {
    IcoIsRunning = true;
    minimalGoalReached = false;
    icoIsClosed = false;
    tokenBalanceOf[this] += _totalSupply;
    allowed[this][owner] = _totalSupply;
    currentTokenPrice = 1;  // CURRENT price of 1 Token
    ICOprice = 1;               // ICO price
    updatePrices();
}

How do I set this if I want an exchange rate of 1 token for 0.001 ETH?
On this code, it's 1 ETH per 1 token(ICOprice)
I tried many different ways with no success.


texts:
In web3JS, when I get past events, I can see the event and the tx hash, I can then do getTransaction on the corresponding tx hash and then see the sender address, but this is wasteful as I have to iterate over all the events and compare it with a desired address (say browser client address).

Is it possible through web3js to access who triggered the event in the filtering itself ?


texts: Can't access smart contract published with truffle in testrpc from javascript

texts:
I'm trying to develop a simple smart contract that sends Ether from one address to another and I can't make it work.

I'm using Ubuntu 16.04, truffle 3.4.7, node 7.10.1 and solidity 0.4.13.

The contract is compiled and published in a local testrpc, but when I try to access it, it just doesn't seem to work.

I've searched for solutions everywhere, but I just can't figure out what's wrong, so I hope anyone here can help me :)

The smart contract code goes like this:

contract Transfer {
    function Transfer () {
        owner = msg.sender;
    }
    function sendEther (address dst) payable {
        if(msg.value<=0) revert();
        dst.transfer(msg.value);
    }
}

The sequence I follow to deploy it is as follows:

testrpc
truffle compile
truffle deploy

Then I have a simple html file which includes a js file which should make the transfer:

< script src="/usr/local/lib/node_modules/ethereum-console/node_modules/web3/dist/web3.min.js" >< /script >
< script src="test.js" >< /script >
< /head >
< body >
< /body >
< /html >

And here's the contents of the test.js file:

var Web3 = require('web3');
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var account_one = web3.eth.accounts[0]; // testrpc address
var account_two = web3.eth.accounts[9]; // testrpc address
/*
// This works fine, makes the transfer:
web3.eth.sendTransaction({from: account_two, to: account_one, value: 100000000000});
*/
// These don't work:
try
{
// First try:
    obj = Transfer.deployed();
    obj.sendEther(account_two, {from: account_one, to: objTransfer, value: 100000000000});
// Second try:
    Transfer.deployed().then(
        function(instance) {
            obj = instance;
            return obj.sendEther.call(account_two, {from: account_one, to: objTransfer, value: 100000000000});
        }
    );
} catch (e) {
    document.write("< br/ >< b >Error: ");
    document.write(e.message);
    document.write("< /b >");
}

Of course, first and second tries are the two things I've tried, not executed both at the same time, when trying one of them, the other one is commented.

Either way, the output I get when I display the html file in a browser is:

Error: Transfer is not defined

Obviously, the Transfer smart contract cannot be created, but I just don't understand why. Any help on how I can make this work?

Thank you so much in advance! :)


texts: Calling a Solidity function automatically in realtime

texts:
I have an oracle with a 'getPrice' function that returns the latest ETH/USD price.

Let's say, I am implementing a stablecoin contract which requires over-collateralization with ETH. How will I automatically dissolve a collateralized position when the margin falls below the minimum specified amount if Ether prices fall?


texts:
I try to send eth from one address to another, but I get an error:Error: Returned error: nonce too low
What could be the problem?

const Web3 = require('web3')

const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io'))
var Tx = require('ethereumjs-tx').Transaction;
var privateKey = Buffer.from('private_key', 'hex');

var rawTx = {
  nonce: '0x000',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: 'to_address',
  value: '0x00',
}

var tx = new Tx(rawTx);
tx.sign(privateKey);

var serializedTx = tx.serialize();

web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);


texts: Hi I was trying to set my ethminer to less that 100% of my GPU. By accident I typed it into my cmd. Does anybody know what the default percent is or if I can set it to default?


texts:
I am trying to automatically wrap ETH when a user deposit ETH on my dapp. Therefore I am trying to call the WETH contract (on the Kovan Testnet for now). I wrote this code :

WETH9_ WETH = WETH9_(0xd0a1e359811322d97991e03f863a0c30c2cf029c);
address WETHAddress = 0xd0a1e359811322d97991e03f863a0c30c2cf029c;

//Deposit ETH to the user account on the app, the value is in wei
function depositETH() public payable{
    require(etherBalance[msg.sender] + msg.value>etherBalance[msg.sender], "Overflow in the Ether Balance");
    WETH.deposit(); //who is paying the fees ?
   // WETH.deposit.value(msg.value);
    //WETHAddress.call.value(msg.value).gas(3000000);
    //WETHAddress.transfer(msg.value);
   // WETHAddress.delegatecall();
    emit Deposit(msg.sender, msg.value);
    etherBalance[msg.sender] += msg.value;
}

The other contract I am trying to call have this code :

pragma solidity ^0.4.18;

contract WETH9_ {
string public name     = "Wrapped Ether";
string public symbol   = "WETH";
uint8  public decimals = 18;

event  Approval(address indexed src, address indexed guy, uint wad);
event  Transfer(address indexed src, address indexed dst, uint wad);
event  Deposit(address indexed dst, uint wad);
event  Withdrawal(address indexed src, uint wad);

mapping (address => uint)                       public  balanceOf;
mapping (address => mapping (address => uint))  public  allowance;

function() public payable {
    deposit();
}
function deposit() public payable {
    balanceOf[msg.sender] += msg.value;
    Deposit(msg.sender, msg.value);
}
function withdraw(uint wad) public {
    require(balanceOf[msg.sender] >= wad);
    balanceOf[msg.sender] -= wad;
    msg.sender.transfer(wad);
    Withdrawal(msg.sender, wad);
}

function totalSupply() public view returns (uint) {
    return this.balance;
}

function approve(address guy, uint wad) public returns (bool) {
    allowance[msg.sender][guy] = wad;
    Approval(msg.sender, guy, wad);
    return true;
}

function transfer(address dst, uint wad) public returns (bool) {
    return transferFrom(msg.sender, dst, wad);
}

function transferFrom(address src, address dst, uint wad)
    public
    returns (bool)
{
    require(balanceOf[src] >= wad);

    if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
        require(allowance[src][msg.sender] >= wad);
        allowance[src][msg.sender] -= wad;
    }

    balanceOf[src] -= wad;
    balanceOf[dst] += wad;

    Transfer(src, dst, wad);

    return true;
}

}

I have tried all the options with commentaries on my code, none seems to work. The only one which seems to call the other contract at some point is WETH.deposit() but the msg.value is 0 even thought the first msg.sender send a msg.value of 0.1 ETH

It does not seem like a very difficult task but I am lost :(
Thank you for any kind of help


texts: Modify storage in Ganache or Hardhat Network?

texts:
I have an orchestrated contract with a function that can only be called by another contract.
While struggling to find an elegant solution for writing a unit test, I realised that I could circumvent the issue by directly modifying the storage of one of my contracts.
I saw that Hardhat Network has a getStorageAt JSON-RPC method, which accepts a contract address and a position as arguments. But I found no equivalent setStorageAt method.
Is there one in Hardhat, Ganache, or any other test RPC network?


texts: Why is it so much cheaper to buy/sell/convert on CoinBase than Coinbase Wallet or Uniswap?

texts:
I just recently started using Coinbase Wallet (which I will from now on refer to as just Wallet) and connected it to Uniswap to be able to buy some Celsius. I have some various coins on Coinbase (not Wallet), so I sent ~60 USD worth of ETH to my Wallet. Then I went to convert it to Celsius, and it says mining fees are high and my 60 USD worth of ETH won't even cover the mining fees to convert 1 USD of ETH to Celsius...
However, back on Coinbase, I can buy, sell or convert ETH into almost any other crypto for very low fees (I think the fee to buy/sell is ~1 USD, conversion seems free?).
Why is this? Are there no blockchain transactions involved when buying/selling/converting on Coinbase?


texts: What to do with a wallet stuck in "Creating..." state in Mist?

texts:
On a Windows Ethereum Wallet client I tried to create a new wallet contract. I used default values for fee. The contract got stuck in "creating" state:

I cannot click on it, it survives Ethereum Wallet application restart.

I tried to create another wallet contract and it succeeded:

What could be the reason for first contract still having "creating..." status?

What can I do about it now? For example how to get rid of the wallet?


texts: How to deploy contract with vanity address using truffle?

texts:
I'm not sure I'm going in the right direction at all, so maybe you know totally different solution for deploying contract with vanity addresses?
My current approach is this:

generate private key such that create contract with nonce = 0 will have vanity address
fund this account with ETH
deploy the contract

But I have a problem, my truffle migrations have 12 different contracts so I want to deploy only one of them using specific private key.
I managed to generate an ethereum private key which will create contract with desirable, let say 0x33333... address when CRATE with nonce 0:
"address":"0xad571ff7001055b9737826215548b3043a365e27",
"privKey":"b0c40801e0ef4e440541c2fa9e38f2e80297e8b73772d4fb8f7e361b3ee395f7",
"contract":"0x33333cea349b04af9cfe399a053203e3d70c2bba"

but if I do
module.exports = function(deployer, network, accounts) {
    deployer.then(async () => {
        await deployer.deploy(ContractA);
        // deploy many other contracts
        const privateKey = "b0c40801e0ef4e440541c2fa9e38f2e80297e8b73772d4fb8f7e361b3ee395f7";
        const accountCreate33333 = await web3.eth.accounts.privateKeyToAccount(privateKey);
        await deployer.deploy(ContractB, {from: accountCreate33333});
    });
}

returns the error: "ContractB" -- Returned error: sender account not recognized.


texts: how to use private keys when working with smart contract

texts:
Here is my scenario .
We have wallets (accounts) with private keys . In case of raw transaction I know how I can use private keys for signing tx  . How I can use private key for an account when I am calling smart contract methods ?
Thanks


texts:
I'm working on something that is almost exclusively using a private blockchain.  We're using Ethereum because of its support for smart contracts.

While developing the contracts, I constantly run into issues with out-of-gas errors, especially in testing.  For instance, with truffle's Assert library, little by little I have to comment out more and more functions to avoid getting an error deploying my test contract.

I'm wondering first, whether there's a configuration where I could tell Ethereum (ganache, say) that gas just doesn't matter?  I tried setting its maximum gas extremely high, and even that didn't do the trick.

Second, is it possible that the issue isn't actually gas, but that's a red herring, and instead it's some inherent limitation on the size of a contract?

I tried asking about this on the truffle gitter, and got a bit of help, but mostly suggestions to raise the gas limit (only marginal change) and to remove Assert functions.


texts: Smart contracts that interact with swarm content

texts: Is it possible for a smart contract to access swarm-content to perform an operation? For example, lets say a user uploads a document to swarm. I would then like to take access the contents of the document from a smart contract to perform some computation on the contents of the document.


texts: ACCESSING BLOCKCHAIN ON "ESP8266" USING THE "NODEMCU BOARD"

texts: I have read this example where it tries to interact with the Ethereum blockchain via a micro-controller (ESP8266 and NODEMCU board). However, I do not understand if an Ethereum client (Geth or Parity) has been installed on this device? If yes, exactly on ESP8266  or NODEMCU? And if no, how this device can interact directly with the blockchain without installing an Ethereum node client?


texts: Stack too deep | Use memory array to store many "local" variables?

texts:
I have a contract that's doing a fairly complex calculation with some intermediate calculations, and I'm running into the "stack too deep" problem.

I've tried to use a memory array within the function to save temporary "local variables" instead of creating new local variables.

For example, instead of:

function usingLocalVars() {
  // Get 3 uint values from a getter function call from another contract
  // and save as local variables uint a, uint b, uint c:
  var(a, b, c) = otherContract.getter(param);

  // Perform some computation an a, b, and c and save as another variable d
  uint d = someOperation(a, b, c);

  /** other code with a return **/

}

Re-written using memory array:

function usingMemoryArray() {
  // Get 3 uint values from a getter function call from another contract
  // and store into memory array temp:

  // create memory array
  uint[4] memory temp;

  // save values into memory array
  (temp[0], temp[1], temp[2]) = otherContract.getter(param);

  // Perform some computation an a, b, and c and save into temp[3]
  temp[3] = someOperation(temp[0], temp[1], temp[2]);

  /** other code with a return **/
}

So what I've tried to do:

Eliminate almost all local variables by doing the above (memory
array)
Removed all named return variables, i.e. returns (uint x, uint y, uint z) => returns (uint, uint, uint)

Current function summary:

1x function input paramater
memory array of length 17 (all my "temp" variables)
1x int local variable
The function does call some other methods within the contract (such as someOperation()) above.  Would this potentially be another cause of this problem?  Needing to limit the local var used in other method calls (e.g. someOperation())?

Does using a memory array as I mentioned above actually help for this problem (stack too deep)?


texts:
I am getting a python version error while installing web3js from npm

gyp ERR! stack Error: Python executable "/anaconda3/bin/python" is v3.6.4, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.

Is there any way of installing web@1.0.0 and better version while working on python3 only


texts: Truffle, Error: Invalid number of arguments to Solidity function

texts:
I have a smart contract that is exposing a list of addresses:

contract AddressBook {

    uint public val = 1000;
    address[] public addresses;

}

Then I do truffle compile && truffle migrate --reset
After that, I run truffle console.

In the console, I bind the contract to a variable:

AddressBook.deployed().then(function(i){ab=i})

Now when I run:

ab.val.call()

It gives me back the proper result.

But when I run:

ab.addresses.call()

It responds with:

Error: Invalid number of arguments to Solidity function

I don't know why. Please help.


texts:
In the go-ethereum codebase, there's a type called CallMsg that's used in a number of cases, and the documentation says

  // input data, usually an ABI-encoded contract method invocation

and it takes a byte array. As far as I can tell, if you want to interact with contracts programmatically with Go, using this type is usually involved. Given a Solidity contract, how would I use this to invoke a method on that Solidity contract?


texts:
I have been trying to figure out how to interact with whisper using web3. I have been able to successfully send (and receive) a message using geth console, but have been unable to do the same using web3.js.

Would you provide a short JavaScript snippet that successfully sends and receives a whisper message?


texts:
I'm looking for a light IFPS library that I can include on the front-end.

I only need to save files and retrieve the hash.

Using Browserify on https://github.com/ipfs/js-ipfs-api is about 2.2mb, which seems high.

https://www.npmjs.com/package/browser-ipfs Looks good but hasn't been updated in two years.


texts: Are Variables passed by reference to libraries?

texts:
I understand from my reading that a library in solidity receives variables by reference and then updates directly the calling contract's variables.

Is it then correct to state then for all library calls the variables are passed by reference only and then local or state variables are updated in the calling contract by the library?

I assume the variable address is passed to the library for state variables, and for local variables, the memory address is passed. Is that correct?


texts: what happens to the transactions inside an uncle block And what if a contract creation end up in an uncle block

texts:
Can anyone  suggest  what happens to the transactions inside an uncle block ?
And what if a contract creation end up in an uncle block.

The whitepaper(ethereum) does not give any information whether the tx in uncle blocks go to the mempool or not. But I am sure that the uncle block transactions do not contribute to the state tree change. Still unsure whether they are automatically reverted and taken to the mempool as pending ones

And also, is the uncle reward being shared if there are children to an uncle block ?


texts: Lib to sign messages using the same version of ECDSA of Ethereum

texts:
I want to sign a message using the private key of my physical RSA digital certificate and I want to validate this signature onchain.

Does anyone know a lib that can sign messages offchain using the same version of ECDSA of Ethereum? The private key used to sign this message will be from my digital certificate.

It would be nicer if there is one in Javascript.


texts: Custom Chain only allow one account to submit smart contracts

texts: Can you lock down a distributed custom chain where only one user account can submit smart contracts? I don't want anyone filling my chain with data unrelated to my dApp


texts: How can a contract send a fee to another contract?

texts:
Here is the code confusing me:

function createRelay () returns (bool success) {
    relay = new Relay()
    bool success = Relay(relay).setRelay(someInt, someAddress);

    if (success) {
        msg.sender.send(fee);
    }
}

I'm trying to send a predetermined fee to the new instance of a Relay contract.

Who is msg.sender? How do I point to the Relay I want to send the fee to?


texts: Update on the projected coin inflation for ethereum?

texts:
I've seen this question:
What is Ethereum's inflation rate? (how quickly will new ether be created)

but the answers are vague and out-of date

I know that Bitcoin is halving and all coins will be mined at some point. But with ethereum the number of coins to be mined is less clear. What is the best determination of the projected outstanding coins for ethereum?

What is the latest on this topic? Thanks


texts: Transfere from Coinbase to Ethereum wallet did not show up?

texts:
I recently transfered my Ether from coinbase to Mist (ethereum wallet)
i used the ethereum wallet address and sent to that from my coinbase account.
coinbase says that the task is complete and has removed all my ether from the account, however it has not shwn up in my ether wallet?
iv signed up to eterscan to check if there is a transaction pending but it also shows 0.00 ether in my posession.

how can i resolve this issue?


texts: Parameters for deploying ballet smart contract using ethereum wallet

texts:
What are the parameters required to deploy the Ballot contract given in the solidity manual http://solidity.readthedocs.io/en/develop/solidity-by-example.html?

When I deploy new contract using Ethereum Wallet it asks me to enter constructor parameters as below:

I have tried option ['ballot1', 111] and the contract is successfully deployed. But when I check the contract info with 111 its not showing up any info of that proposal

I'm not understanding what parameters to be given and how to check the working of Ballot contract.


texts: Is there an online service where I can find a web3 cli?

texts: I need this when im on a new machine or my node messed up and needs a resync. I know that Id to trust the service as the source of truth but I only need to do some quick queries.


texts: operator == not compatible with type string storage ref and literal_string

texts:
can someone help out with the stated error, i am trying to run a code to check the status of a String variable. while compiling using the online solidity compiler i am getting two errors on customcheck and portcheck. see the code below:

contract tradefin {

    uint public prodcode;
    address public seller;
    address public buyer;
    uint public price;
    uint public units;
    address public port;
    address public customs;
    address public delivery;
    string public portcheck;
    string public customscheck;
    string public deliverycheck;
    string public msg1;

    function initiate(uint code, address vendor, address applicant,
        uint amount, uint quantity, address p, address c, address d) {
        prodcode = code;
        seller = vendor;
        buyer = applicant;
        price = amount;
        units = quantity;
        port = p;
        customs = c;
        delivery = d;
    }

    function review() constant returns (uint retval) {
        return uint(prodcode);
    }

    function finall() constant returns (string retval) {
        return string(deliverycheck);
    }

    function approve() constant returns (string retval) {
        if (msg.sender == port) {
            portcheck = "signed";
        }

        if (msg.sender == customs) {
            if (portcheck == "signed")
                customscheck = "signed";
            else
                msg1 = "Port yet to sign";
            return msg1;
        }

        if (msg.sender == delivery) {
            if (customscheck == "signed")
                deliverycheck = "signed";
            else
                msg1 = "Custom yet to sign";
            return msg1;
        }
    }
}


texts: Execution of Fallback function with more 2300 gas

texts: I have tested a contract having a fallback function which updated a state variable (cost 5000 gas). I sent an amount of Ether to this contract with 100000 gas limit. The transaction is valid. As explained in solidity considerations, it should be fail because gas stipend is 2300. Can someone help me explain?


texts:
Assuming I have deployed my ERC20 token, and the supply has been dispersed, is there any method of creating a separate contract that accepts that ERC20 token as payment and has user fields that send particular information to the contract?

Kind of like a contract that takes the token along with some information.


texts: Can solidity alone suitable for ICO project?

texts:
I know solidity codes and coded one smart contract.I want to know is if I want to list this contract on one exchange.is it ok or not.
can this exchange accept this codes to exchange with other coins?


texts: Solidity - can I get information about a specific transaction within a contract?

texts:
What I'm hoping to do is get information about a specific transaction in my solidity contract.
For example, let's say I have transaction 0x0xxx, I would like to be able to pass that into a function, and get information about the transaction, specifically the sender address and the tokens transferred.
I know that I can get the blockHash:
blockhash(number)

But can I go a step further and get information about transactions within that block.
I've also read that you can only get info about the last 256 blocks, and that is not an issue at all.
I'm trying to figure out a way to do this without setting up an oracle.
I just couldn't find much documentation about this specific use case.
Thanks very much;


texts: web3.py provider error -- 'Web3' has no 'eth' member

texts:
Hi I am trying to use web3.py to connect some python code to a solidity contract and I am getting an error -- Web3 instance has no eth member.

    w3 = Web3(EthereumTesterProvider())

contract_source_path = r'\tournament.sol'
compiled_sol = compile_source_file(contract_source_path)

contract_id, contract_interface = compiled_sol.popitem()

address = deploy_contract(w3, contract_interface)
print("Deployed {0} to: {1}\n".format(contract_id, address))

tournament_contract = w3.eth.contract(
    address = address,
    abi=contract_interface['abi']
)

I am not sure why this is happening as the w3 variable holds Web3(EthereumTesterProvider()) which should have an eth member object.


texts: How do you make a function in Solidity that is only visible if condition is met in web3?

texts: How does one make a function in Solidity that you can only call if a requirement is met outside the smartcontract (e.g. web3)?


texts: How can a contract accept some ether and send a stablecoin in return

texts:
My contract has to take ETH as a collateral and send some stablecoins ( like USDC) to user.
How can I use any stablecoin into my contract , assuming contract has an infinite supply of USDC ?
I too some clue from
https://ethereum.org/en/developers/tutorials/transfers-and-approval-of-erc-20-tokens-from-a-solidity-smart-contract/
pragma solidity ^0.5.0;

contract Loan is USDC {

    USDC public usdc;

    uint16 price;
    // Manually update price of token to Eth
    function currentPrice(uint16 _price) public {
        price = _price;
    }

    function borrow() public payable {
        require ( msg.value > 0 , "You need to send some ether");
        uint amount = msg.value*price*80/100;   // No. of token transfer is 80% of the value of ether
        usdc.transfer(amount);

    }

    function returnAmt(uint _amount) public payable {
        require (_amount > 0 , "You need to send some token");
        uint ramount = _amount*100/(80*price);

        usdc.transfer(address(this), _amount);
        msg.sender.transfer(ramount);

    }
}

Can you please check the error in usage inside functions ?


texts: Wallets report 0 balance for address but balanceOf is right

texts:
Given this contract using Openzeppelin lib:

contract Token is StandardToken, Ownable {

    string public name = "";
    string public symbol = "";
    uint8 public decimals = 18;

    constructor(string _name, string _symbol, uint256 _supply, address creator) public {
        owner = creator;
        name = _name;
        symbol = _symbol;
        totalSupply_ = _supply;
        balances[owner] = totalSupply_;
        Transfer(0x0, owner, balances[owner]);
    }

  truffle(rinkeby)> Token.at('0xdc190d1ac0355bc3b9b4bba96738484cd07690ea').balanceOf.call('0xD587f68bE865c8a4F34CC2a53150dE0DA5771957'); BigNumber { s: 1, e: 2, c: [ 665 ] }

Metamask and Coinbase wallet report 0 balance when you add it as a custom token with the owner address.

Running truffle console, the owner is indeed correct and running balanceOf reports correct balance.

Is it a problem because it is assigned in the constructor and there is no transfer tx? So the problem is with the wallets or in my code?

The code passes all truffle tests for balances etc before deployed.

Note that this contract is deployed from a "mother" contract that's why owner is not msg.sender but why would that be a problem?

Tried updating with a Transfer event to be compatible with the ERC20 protocol but didn't change anything.


texts: How does a smart contract fetch stored data (for example, EmployeeName) from the node? Does it search through the entire chain? But searching through the entire chain would take just too long. There must be a quicker way.


texts:
So casper testnet is out and I have a few questions!
From previous discussions it seems that light nodes cannot be validators.

If this is correct, then what will the purpose of light nodes be as part of the ethereum network?
Will everyone who wants to participate need to run a full node in order to stake?
If I am mistaken and light nodes CAN participate in PoS and validate transactions, will the reward be a percentage of what a full node would get?

Thanks!


texts: Which miner gets the gas fee for each transaction?

texts:
I'm guessing that miners are randomly selected, but I'm curious as to which miner receives the fee for gas paid for each transaction?

In hindsight, the answer to this question is obvious: of course it is the miner that also solves the PoWhash.  They get the block reward AND the gas.

The suggested duplicate answer (the questions are also very different actually) does not hone in on the PoW incentive and why a miner is rewarded. The answer for this question targets exactly how the gas is rewarded to the miner.


texts:
I have 5 nodes with quite different block numbers( one is stuck at 201504, another at 280432 and so on) , they don't seem to be syncing. No particular error in Quorum Logs as well. Any transaction going in ends up in the pending queue.

Any thoughts?


texts: How can I create a copy of an existent contract in Javascript ?

texts:
I'm trying to create a copy of an contract existent contract using web3.js 1.0. I'm trying to use the functions clone and deploy but without success.

        contract2 = contract1.clone();

        contract2.deploy().send({from : web3.eth.defaultAccount})
        .on('error', function(error){
             alert(error);
         })
         .then(function(result){
            alert(result);
            }
        );


texts: A contract function can be called after a certain time?

texts: Let's say for bidding implementation of blockchain for a time bound process how it will be executed


texts: How does Quorum or any private ethereum deal with failing/unavailable nodes, Single Point of Failure (SPOF) and Settlement/Transaction finality?

texts:
How does Quorum or private ethereum deal with failing/unavailable nodes, Single Point of Failure (SPOF) and Settlement/Transaction finality?

It seems to me that only ethereum main net is truly decentralised and without a single point of failure and truly censorship free as transactions cannot be reversed.

Nathan Aw


texts: Why does zero to non-zero in storage take higher gas?

texts: According to EIP-1087 https://eips.ethereum.org/EIPS/eip-1087 , it take 20,000 gas to set a slot from 0 to non-zero with SSTORE while it takes only 5000 gas for any other change. Why does 0 to non-0 change take higher gas than any other change?


texts:
Is there a way to reinstantiate a stateDB after saving the output of state.Dump()?

My problem is the following : I create a new StateDB object using :

db := ethdb.NewMemDatabase()
state, _ := state.New(common.Hash{}, state.NewDatabase(db))

and then execute multiple operations (state.SetBalance(...)) as in the statedb_test.go file.

Is it possible to recover the state object afterwards?
i.e having a persistence in the balances and accounts that were changed during the operations?

Any help really appreciated,

Thanks


texts:
Yesterday i made my transfer from one wallet to another and finally understood the meaning and usage of gas. I made the transfer from my exodus wallet and around that time the low gas price was around 85 gwei. I put 76 not knowing any better since i didn't want to pay high fees and exodus marked my transfer as slow. Originally i intended to do the very slow setting but it warned me that it might not go though at all so i changed it.
Now the low gas price is up and my transaction has been pending for over 20 hours. My question is, is there a way to calculate the average time it will take to complete ? What happens if it keeps pending for example for over a month ? Does it get canceled automatically at some point ?
And one more thing. As soon as i hit my withdraw limit on ethermine, the system made out an automated payment to me using 1 gwei. How come they get to use 1 gwei and their transfer to my wallet is instant but mine with 76 isn't ? Thanks a lot in advance!
https://etherscan.io/tx/0x456ae3747724b197f70b877d80af2c12fc12f6a528a82b5e36369528fd569b5b


texts: Can my friend sell an 'Eiffel Tower' with NFT

texts:
Suppose I know someone who has ownership over a landmark. Not quite the Eiffel Tower, but to ensure he remains anonymous we could say it is a similar asset. Perhaps simpler because it just sits there without people going inside.
Can he now sell an NFT for this? Does he have to provide proof to someone that he has the rightful ownership of the landmark before creating the NFT?


texts: how to withdraw the ethereum from the wallet created programmatically

texts:
I need to create ethereum wallets in my web project for each user. The scenario is as below:

1.The user creates an account.
2.The project automatically Create an ethereum wallet for each user.
3.The project automatically send some ethereum to the user's wallet.

The questions are:

1.Is it an appropriate to use ethereumj to create the wallet for each user?
2.How can the user back up the ethereum wallet?
3.how can the user take out the ethereums from the wallet?


texts: trouble while installing dependencies using NPM install for Ethereum based Project

texts:
I downloaded the following repository from Github
https://github.com/pipy/Ethereum-based-Rating-and-Review-Management-System-for-E-commerce
there is a folder by the name USAGE I followed all the steps. when I use
npm install

it starts downloading dependencies but in the end, it's given me the below error.
I am using
Node version: v14.15.3
npm version = 6.14.9
npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t https://github.com/cgewecke/provider-engine.git
npm ERR!
npm ERR! fatal: unable to access 'https://github.com/cgewecke/provider-engine.git/': OpenSSL SSL_read: Connection was reset, errno 10054
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\scholar\AppData\Roaming\npm-cache_logs\2021-05-21T05_21_56_676Z-debug.log


texts: bad instruction error when sending ether to contract

texts:
I am following the tutorial at https://medium.com/@gus_tavo_guim/reentrancy-attack-on-smart-contracts-how-to-identify-the-exploitable-and-an-example-of-an-attack-4470a2d8dfe4 and deploying the following contract:

pragma solidity ^0.4.16;
contract HoneyPot {
  mapping (address => uint) public balances;
  function HoneyPot() payable {
    put();
  }
  function put() payable {
    balances[msg.sender] = msg.value;
  }
  function get() {
    if (!msg.sender.call.value(balances[msg.sender])()) {
      revert();
    }
      balances[msg.sender] = 0;
  }
  function() {
    revert();
  }
}

When this contract receives ether, the HoneyPot() constructor should be executed, which will call the put() function and run the balances[msg.sender] = msg.value; line. However, when I send ether to this contract I get a "bad instruction" error on etherscan (after waiting a couple of minutes and using the ropsten test network). What might the issue be here? as both HoneyPot() and put() functions are payable (as is required when receiving ether).


texts: I have seen many pre ico sites needs a login page to be created . Would like to know why is that created and where do they store the information ?


texts: How can I let TestRpc reveil the public key of a generated account

texts:
I suffer a steep learning curve at the beginning. My current goal is to set up a testing environment with TestRpc, Truffle and Web3j (wow).

Web3j worked as expected and generated a Java wrapper for the famous HelloWorld contract. TestRpc also works as expected and shows as in the Image.

https://goo.gl/images/V96znv
Image: I took this from the web, but it is the same

The image shows the addresses and the private keys. If you use TestRpc, I assume that you have seen it many times.

So back to my simple question. Where or how do I get the public key for the accounts that show in the TestRpc console?


texts: Is there a functional equivalent to Factom in Ethereum?

texts: Factom is a distributed data and records management and audit system. How easily can what Factom does be done in Ethereum? Are there any working DAPPS doing this? Could a simple smart contract take care of such a function?


texts:
I have seen various projects linking tokens to Fiat currency to maintain some stability. This link has some commentary - https://themerkle.com/what-is-a-pegged-cryptocurrency/.

For ERC20 has anyone any idea how this can done?


texts:
Is there a way to find the total gas that will be used by the transaction before a tx actually takes place?

Does the gas used depend on the amount of tx size in kb?


texts: Can I use my own coin in 3rd party contracts?

texts: I know you can create your own coins in ethereum but can they be used in 3rd party contracts that normally use ether?


texts: Use Ledger Wallet as etherbase for mining on private network

texts:
I would like to use my ledger as the wallet that will validate blocks on a private network with a geth client.

I can have access to my ledger account from geth. But i can't start the mining process.

> miner.start()
...
null
> WARN [04-03|10:21:02.553] Block sealing failed     err="not supported"
...

I look for what caused this error in the source code and i think it's here

Is it technically possible but not implemented yet / never will be or is it totally impossible to use a wallet that come from an other backend to validate blocks ?


texts: How to wait Oraclize result before running code further?

texts:
I'm trying to write a contract, which first asks input from user, then makes Oraclize query and after receiving answer from Oraclize compares user input to Oraclize answer.

My problem is, that my code doesn't wait for the answer from Oraclize and because of that, I get Oraclize result after comparison is already done.

How can I make program to wait for Oraclize result and continue running only after result has arrived?


texts:
In 2017 there was the Metropolis hardfork. In 2018 there will be Constantinople.

Is Constantinople a full PoS fork or will it be hybrid like 1 block of 200 will be PoS mined?
Will there be a Casper fork after Constantinople?

Can somebody please point me to a description of what these forks exactly plan to do and what the current development stage of the parts of Constantinople is?


texts: Error: invalid type (arg="type", value="a") web3.js

texts:
I am trying to get the balance of user for specific token type using web3.js.

Here is my code block:

    var tokenContract = new web3.eth.Contract(erc20abi, tokenAddress)
    tokenContract.methods.balanceOf(accounts[0]).call().then(balance => {
              console.log(balance);
    });

It throws an error as soon as this function is called from web3.

Following is the error at my console:

Uncaught (in promise) Error: invalid type (arg="type", value="a")

at Object.n [as throwError] (web3.min.js:1)
at D (web3.min.js:1)
at web3.min.js:1
at Array.forEach (<anonymous>)
at web3.min.js:1
at D (web3.min.js:1)
at e.<anonymous> (web3.min.js:1)
at Array.forEach (<anonymous>)
at e.encode (web3.min.js:1)
at a.encodeParameters (web3.min.js:1)**

My web3.js version is: 1.2.7

Here are values from the variables used:

accounts[0] = "0x572ACD5370909b2C0aCde66995c1BE8aC25238bE"
tokenAddress = "0xfd60bC45f816b575C2c938F744CFb801505824E7"
erc20abi =  [{
        "constant": true,
        "inputs": [],
        "name": "name",
        "outputs": [{
            "name": "",
            "type": "string"
        }],
        "payable": false,
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "decimals",
        "outputs": [{
            "name": "",
            "type": "uint8"
        }],
        "payable": false,
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [{
            "type": "address"
        }],
        "name": "balanceOf",
        "outputs": [{
            "type": "uint256"
        }],
        "payable": false,
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "symbol",
        "outputs": [{
            "name": "",
            "type": "string"
        }],
        "payable": false,
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [{ "internalType": "address", "type": "address" }],
        "name": "balanceOf",
        "outputs": [{ "internalType": "uint256", "type": "uint256" }],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }
];


texts:
I am trying to get a contract code from javascript. However, when I run this:

web3.eth.getCode("0x9bA082240DBa3F9ef90038b9357649Fa569fd763")

on my browser console, I get an Invalid address error which is unexpected. The above address is a valid contract address and the same function on my geth console returns the correct code. My geth client always syncs up with the blockchain. So my question: why is this problem happening? and how to fix it?


texts:
When you're using a library like SafeMath, and then have using SafeMath for uint256; within a contract, how do uints know to become the a parameter of the library functions? Is that just a convention that applies to all functions whenever you're using a library for a data type?

For instance, you'd do some_uint.sub(4), but the sub method has both a and b parameters:

function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
}


texts: Web3 + Truffle, is this the correct way to approve a spend?

texts:
I have created an ERC20 token using Web3, Openzeppelin and Truffle, and minted some tokens.
const LToken1 = await ERC20.new('Test L Token 1', "TEST1", web3.utils.toWei('1000000'));
I would like to use the ERC20 function approve() to allow a UniswapV2Router to add liquidity of my new token to a Uniswap pair.
await LToken1.approve(router.address, web3.utils.toWei('0.02'), {from: "0xA781A3BAb62cdd3031D90C4C4740dbc719A3921c"});
Is the above line of code the correct way to approve a spend using Web3?


texts: How to use sendTransaction to send ERC20 tokens through Metamask?

texts:
I have a custom ERC20 token and I want to enable metamask support. By this I mean:

1) The user clicks a "Pay using metamask" button

2) The Metamask payment window pops up and with "Pay 100 ABC tokens" (not ETH), with the usual gas price, etc.

How would I do this? I wrote my method halfway, but realized it would only work for ETH.

My ethereum.js file:

const sendTransaction = ({ cost, to, gasPrice }) =>
  new Promise((resolve, reject) => {
    if (window.ethereum) {
      const ethereum = window.ethereum;
      const Web3 = window.Web3;
      const web3 = new Web3(ethereum);
      try {
        ethereum.enable().then(accounts => {
          const from = accounts[0];
          web3.eth.sendTransaction(
            {
              from,
              to,
              gasPrice,
              value: "1000000000000000000"
            },
            (err, res) => {
              err ? reject(err) : resolve();
            }
          );
        });
      } catch (error) {
        reject(error);
      }
    } else if (window.web3) {
      const Web3 = window.Web3;
      const web3 = new Web3(window.web3.currentProvider);
      web3.eth.getAccounts().then(accounts => {
        const from = accounts[0];

        web3.eth.sendTransaction(
          {
            to,
            from,
            value: "1000000000000000000"
          },
          (err, res) => {
            err ? reject(err) : resolve();
          }
        );
      });
    } else {
      console.log(
        "Non-Ethereum browser detected. You should consider trying MetaMask!"
      );
    }
  });

export default {
  sendTransaction
};


texts: web3 - get all contract public variables?

texts: I have an abstract worker contract and few that inherit from it. Those contracts have some public variables, each one different. I want to display them on my website. Is there any way to return all getters from contract, or do I need to create a special function getFields() with multiple return for each one?


texts:
What is the limit to the amount of ERC20 tokens someone can generate?
I tried to generate 1 Trillion tokens but only got 0.000001 Tokens back!

If anyone can make this more clear, I would highly appreciate it.


texts:
I want to return the gas used to the user when he uses a payable function.
I used tx.gasprice but it always returns 1.

How can I get the actual gas used value (not the maximum or user set values, but really the gas used value for the transaction, in my case, a function call)?


texts: Is it safe to keep Ether on an exchanges during the Homestead switchover?

texts: There are several exchanges like Kraken, Gatecoin, etc. Is it safe to keep Ether on one of these exchanges when the switchover from Pioneer to Homestead takes place?


texts:
I'm trying to understand Solidity language in deep. I'm thinking in a traceability test project. But before start the first question appear in my mind. If I want to attach the production flow of one product specific on the blockchain. I have to make more than one contract in solidity? Or with just one contract i can do everything?

I mean imagine that we have a farm a carrier and finally a shop where the product is on sale. I have to generate one contract for each (farm,carrier, shop) and inside the contract insert a value that references to the previous actor? Or the way is to make all the product flow in the same contract??


texts:
I want to be able to trigger runTest() and return false. I'd need to clone the struct at some point but I'm not sure how to do it in solidity. I thought passing it to another function as memory would be a clone but the original gets modified.

pragma solidity ^0.4.19;
pragma experimental ABIEncoderV2;
contract Tester {

    struct Foo {
        bool stayFalse;
    }

    function Tester() public {
    }

    function runTest() public constant returns (bool) {
        Foo memory foo;
        return one(foo);
    }

    function one(Foo memory foo) public constant returns (bool){
        Foo memory foobar;
        foobar = two(foo);
        return foo.stayFalse;
    }

    function two(Foo memory bar) public constant returns(Foo) {
        bar.stayFalse = true;
        return bar;
    }

}


texts:
When trying to compare a string from storage to a string being passed into a function (memory), I am getting the following error when attempting to convert the memory string using keccak256(). What am I supposed to be doing differently?

TypeError: Invalid type for argument in function call. Invalid implicit conversion from string memory to bytes memory requested. This function requires a single bytes argument. Use abi.encodePacked(...) to obtain the pre-0.5.0 behaviour or abi.encode(...) to use ABI encoding.


texts: ERC-20 Airdrop Smart Contract Vs ETH Airdrop Smart contract

texts:
Hi am using a smart contract to airdrop erc-20 tokens:

contract ERC20 {
  function transfer(address _recipient, uint256 _value) public returns (bool success);
}

contract Airdrop {
  function drop(ERC20 token, address[] recipients, uint256[] values) public {
    for (uint256 i = 0; i < recipients.length; i++) {
      token.transfer(recipients[i], values[i]);
    }
  }
}

Though i am unable to airdrop ETH using it, can anyone tell me what i am missing or what loops must be added to the existing code to let it able to airdrop eth.


texts:
this is probably a really really simple question but shamefully it's had me stumped for a while. I am building a simple application which would allow users to purchase Newspaper Articles. Simple enough but the relations is killing me.

I'll outline my goal and where I am so you get an idea of my thinking and perhaps can point me in a more logical direction if needed.

So the way I see it, I have 3 entities.

An Author, An Article and A Reader

An Author can have many Articles

An Article can have one Author

An Article can have many Readers

A Reader can have many Articles

An Author and a Reader have no relation

Mapping a new Article to an Author is not a problem and I have this working

My problem is with mapping many Articles with many Readers

I've thought about having a mapping table like ArticlesRead which would simply have the address of each Reader & the ID of each Article, but how do I go about retrieving the Articles the Reader has purchased.

I think I'm getting a little hung up on how traditional arrays work..

I'm sure this is simple so any advice would be appreciated,

struct Article {
    uint index;
    string content;
    uint price;
}

struct Reader {
    address _address;
}

My code is pretty rubbish for now so I don't think it will help posting it

Thanks


texts: Remix + Metamask not fetching any values

texts:
I have a simple test contract that stores a hash and I deployed it via Remix and Metamask

pragma solidity 0.4.25;

contract Hash {
    bytes32 hash;

    constructor(bytes32 _hash) public {
        hash = _hash;
    }

    function getHash() public view returns (bytes32) {
        return hash;
    }
}

so far, so good. The contract can be found here

I passed "0xE6648B14C7E8303258E7DA8CC80540A6C56EC8D7118A6F88D39E836E31FFC2D0" in the constructor as a hash.

But when I call the getHash function I get the following result:

But when I change the provider to my local parity node I get the following correct result:

Why am I getting the wrong result with metamask?


texts: Error: gas required exceeds allowance (10209310) or always failing transaction

texts:
I'm newbie in ethereum and on my first lession I faced an issue that I can't solve:

Hello.sol:

pragma solidity ^0.6.0;

contract HelloSol {
    uint savedValue;

    function setValue( uint newValue ) public {
        savedValue = newValue;
    }
    function getValue() public view returns( uint ) {
        return savedValue;
    }
}

This simple contract store and return unit value. It perfectly works in Remix.
After I compile this contract, I copy-pasyte WEB3DOPLOY to my private blockchain network, contract was deployed, I create an ABI and contract objects, after that I'm trying to interact with contract, "return" function works fine, but "set" fucntions isn't working at all:

> HelloSol.getValue()
0
> HelloSol.setValue(777, {from: "0xed4e9babb02cc48652375526bdb0d55a86d5c5ce"})
**Error: gas required exceeds allowance (6816018) or always failing transaction**
    at web3.js:3143:20
    at web3.js:6347:15
    at web3.js:5081:36
    at web3.js:4137:16
    at apply (<native code>)
    at web3.js:4223:16
    at <anonymous>:1:1

I spend 12hrs trying to figure out the root cause but with no success. Any suggestions??
Thanks!!


texts: Webj3 erc20 specify nonce for token transfer

texts: How do you specify a nonce when sending erc20 tokens using web3j?


texts:
It is not very clear for me the recursive call of contract's functions. As described in white and yellow papers, a contract program code calls an external contract's function, it has to wait until the called function returns or an exception occurs. Assume that in a function of contract A, it calls a function of contract B with the address of the contract A (at this point, the contract A code has to wait the return from contract B code). However, inside the called function of the contract B, it sends some Weis to the address of the contract A, meaning that the code of contract A will execute. Does it happen that A is waiting for B and B is waiting for A in the same time?

Thanks!


texts:
I forked UniswapV2's factory and router and deployed them in Kovan using remix

I also made sure that I am sending an ETH

I also made sure that I approved the tokens

But I am getting this error when trying to send the transaction

When I proceed, the transaction always fail, here is one of them, it's returning a Fail with error 'UniswapV2Router: EXPIRED', this is the same error I am getting when doing the test in my local in truffle
https://kovan.etherscan.io/tx/0x59624fb39db924eff817f872001718cfaa95c825c052f21f4fd3cb033250d23b
Please take note that transactions are successful when using UniswapV2 Router's contract address in remix


texts: If company that produce ICO want to get N money, but the company did not collect as much of necessary amount of money. Is it means that ICO did not take place and company will not launch?


texts: Updating a field in structure - One to many mapping - Solidity

texts:
I have a structure Student with one to many mapping and pushed values to it.Following is my code:

pragma solidity ^0.4.20;

 struct Student{

  uint id;
  string name;
  uint256 mark;

 }

 mapping(uint => Student[]) StudentDetails;

function addStudent(uint classid,uint id,string name,uint256 mark) public payable{

     StudentDetails[classid].push(Student(id,name,mark));
  }

Now I need to update mark field without updating id and name for each student. How it can be done? Help will be appreciated :)


texts: The method db_putHex does not exsist/is not availabe

texts:
I am starting geth like the below command

geth --testnet --rpc --rpccorsdomain http://localhost:8089

and get the error db_putHex does not exist/is not available on this line:

web3.db.putHex(db, key, value);

What am I doing wrong?


texts: How do I get my Testnet listed on chainid.network

texts: I need assistance with getting my testnet listed on the website chainid.networks. I have already seen the GitHub examples but I would like to know what each field represents. Thank you!


texts: web3 v1 beta. estimateGas throwing Transaction execution error

texts:
I am using web3 verion 1 (beta) connected to a remote Parity node via websocket.

There is a deployed contract TestContract with a test function that emits a Tested event that simply echoes back msg.sender.

contract TestContract {
    event Tested(address sender);

    function test() {
      require(msg.sender != 0x0);
      Tested(msg.sender);
    }
}

The following code

const contract = new web3.eth.Contract(testContactAbi, theAddress)
const gasNeeded = await contract.methods.test().estimateGas({ from: SENDER_ADDRESS })
console.log('gasNeeded', gasNeeded)

throws Transaction execution error

I am sure I have a connection to the node

const listening = await web3.eth.net.isListening()

listening is true

How would I debug this?


texts: React: Re-render states after MetaMask transaction

texts:
The React frontend of my dapp successfully fetches the data from the private blockchain (Ganache) and updates the states accordingly.

However, when I trigger a function via onClick that updates the states, the states render the proper values only when I refresh the page.

What's the most effective way of refreshing the states after a MetaMask transaction?

UPDATE: I was thinking that maybe there could be some way of refreshing the page via Web3js and adding that part into the promise function?

I.E. onClick -> func1.then() -> refresh


texts: How to sign a transaction automatically?

texts:
An api will call the smart contract function. It should sign the transaction on its own instead of human intervention.

I think raw transaction can work here. Are there any other options?

Any help is much appreciated.
Thanks!

--Edit--
The question is updated!


texts: Understanding addresses of contracts (when they deployed twice)

texts:
I just have a quick question about addresses of contracts.
If I want to make a contract to transfere tokens, how do I get the correct addresses of the token I want?
For Exsample:
function transfer() external {
        address a  = address(MyToken_ERC20());
        MyToken_ERC20 token = MyToken_ERC20(a);
        token.transfer(msg.sender, 100);
    }

If I would deploy "MyToken_ERC20" two times there would be two addresses of the token right?
And if yes ... how can I make sure, that I got the right address, only by hardcoding the address into my new contract?


texts: "out of gas" message when calling another solidity contract's method

texts:
I want to call another solidity contract's method using Call/DelegateCall. Although the transaction seems successful, but I did not get the expected result, and it shows "Although one or more Error Occurred [Out of gas] Contract Execution Completed" message.
I am new to solidity code and I use remix to compile and deploy contract on ropsten testnet. I am not sure whether I make some silly mistake. Here are my two contract code:
pragma solidity ^0.4.6;

contract Callee {
    uint[] public values;

    function getValue(uint initial) public view returns(uint) {
        return initial + 150;
    }

    function storeValue(uint value) public {
        values.push(value);
    }

    function getValues() public view returns(uint) {
        return values.length;
    }
}

pragma solidity ^0.4.6;

contract Caller {
    function someUnsafeAction(address addr) public {
        addr.call(bytes4(keccak256("storeValue(uint256)")), 100);
    }
}

I deployed the Callee contract and the Caller contract from remix on ropsten testnet using my meta mask account, then passed the Callee contract address, "0x300997B17aEC75F636Ced66570Af76c05Dd380c9" to the Caller's someUnsafeAction method. The transaction went through, but I did not get the expected result, the value "100" is not saved into the Callee contract (https://ropsten.etherscan.io/address/0x300997b17aec75f636ced66570af76c05dd380c9).
Here is transaction (https://ropsten.etherscan.io/tx/0x625f7cac9aec9613f3e1ab81fbe06a4f57b85517e89521775cdaad2a3a656c5e)
Any help is appreciated. Thanks


texts: Managing ERC20 tokens with a multisignature address

texts:
Say I have the following:

Address A belongs to me and holds 10 ERC20 tokens, but does not hold any ETH
Address B belongs to somebody else and I need to send 10 ERC20 tokens there from address A
Address C belongs to me and holds 1 ETH. Address A did not approve address C to spend any tokens on its behalf.

Is it possible to transfer these 10 ERC20 tokens from address A to address B by somehow using multiple signatures? What I was hoping for is to initiate a transaction from address C (since it holds ETH to pay for gas) or make address C initiate a transaction on behalf of address A. Or maybe there's a smarter way to transfer ERC20 tokens from an address that never held any ETH?

Thanks!


texts:
I was reading on crypto staking, more precisely Defi-Staking on Binance: https://www.binance.com/en/defi-staking
While I am not a native english speaker I could understand that there is no risk in staking, but what's the catch? I mean Binance says I can get up to 9% in one single day, but if it's only about profit then why doesn't everyone simply do it and become 10% richer everyday? I think I am messing something here, please note I am totally new to crypto.


texts: Does Solidity support passing an array of strings to a contract's constructor yet?

texts:
I am going through a tutorial from 2017 that says it was updated in January of 2018.  It says that currently you can not pass an array of strings directly to the constructor of a contract and that you have to use an array of something like byte32.  Is that still the case?

If you can use an array of strings now and you have a link to an example page, then please share it.


texts: How to tell if `geth` connected to EVM One?

texts:
I'm using the EVM One back-end with ewasm/geth according to the following instructions.

Geth seems to be starting up as usual with the following command:

geth --vm.evm=./libevmone.dylib

How can I actually tell if the library has been linked successfully and the new back-end is being used?

FYI - performance seems relatively similar, so my suspicion is that it's not being applied.


texts: Unfortunately my MetaMask wallet did not receive the alt coin I sent from my Coinbase wallet?

texts: I think I messed up I just need some clarification and help if it’s possible to fix. I sent an alt coin called Audio from my Coinbase to my MetaMask wallet, nothing has been received andI have looked up the transaction that says it was successful. What I did not do was swap the alt coin for ETH before transferring, was this a mistake or is it possible to send Alt coins as they are?


texts: What happens if a miner who didn't soft fork mines an "invalid" block?

texts:
Can someone explain, technically, what would happen if a majority of the miners adopted a soft fork (forward-compatible) making some tx invalid and then a miner who didn't fork happened to mine a block containing an invalid tx (but still valid on his fork)?

Basically what I don't understand is that there's a proposal where, apparently, miners can choose which addresses they want to block.

So what if, say, there are 4 groups of miners:

group 1 considers invalid tx to/from address A (17% of miners)
group 2 considers invalid tx to/from address B (23% of miners)
group 3 considers invalid tx to/from address A & B (20% of miners)
group 4 doesn't want to soft fork or doesn't bother (40% of miners)

Isn't group 4 guaranteed to "win", because group 1, 2 and 3 will each be on their own fork, resulting in four forks? Although should have groups 1,2 and 3 all agreed on the same rules for what was invalid, they'd have 60% of the mining power and hence "won"?

Or is the upcoming proposal going to be the same for everyone, and everybody who wants to fork is going to consider the exact same blocks as invalids?

And the second thing I don't understand: there has to be a block at which the new rule kick in and 50%+1 of the miners have to have updated to the soft fork by then for the (forward-compatible) fork to be succesful right? Yet I don't see any block number at which the new rules would kick in the current soft fork proposal code.

Any technical answer is very welcome (*).


texts:
Basically is it possible for constant functions to emit events? Example bellow:

I have Sample Contract which has a getData() function which does not modify any state, emits an event and returns a string value.

contract Sample {

    event ExampleEvent(string data_description);

    function getData() public constant returns (string) {
        ExampleEvent("From Sample contract");
        return "Event sent";
    }
}

Then I try to call it through nodejs with web3.js using .call() (this does not emit event)

SampleContract(abi).at(address).getInfo.call({from:{account});

I only receive the "Event sent" string as a response, but no event has been created.

However if I call this function via a transaction .sendTransaction()(this emits event)

SampleContract(abi).at(address).getInfo.sendTransaction({from:{account});

This returns the transaction hash as expected (since I'm creating a transaction) but it also creates a new event.

I understand that constant functions cannot change a contract state however a new event is not really part of the contract storage/state (events/logs are stored in the transaction logs)?

What is the reason for this not to be working, am I missing something obvious?


texts: How to get the private key from the keystore file

texts:
The book Mastering Ethereum explains the keystore file in geth as follows:
"The private key in the JSON file is not directly encrypted by the password. On the contrary, the password will be expanded through continuous hash operations (and then encrypted). Hash The calculation repeats 262144 rounds. This parameter can be seen in the crypto.kdfparams.n parameter of JSON. Any attempt to brute force the password must go through 262144 rounds of hash calculation, which will greatly reduce the speed of the attack. If the length and complexity are sufficient, the attack of brute force guessing passwords is no longer effective (the complexity of the password itself × 262144 rounds of hashing, the amount of calculation will be very large)."
So I want to know if the private key is not directly encrypted by the password, how can the user obtain the private key from the keystore after entering the password? Does it have to pass 262144 rounds of hash calculation to get the private key? Why take this method, it feels that the efficiency will be very low.


texts: How does one connect to a blockchain? (technical)

texts:
Maybe this was asked sometimes, but I wasn't able to find an answer.

I want to ask how does one connect to a blockchain in general - not the configuration part how to download it, but from the technical perspective, f.e protocols.

For example:

what happens when someone downloads geth, does it use a different protocol to connect to the blockchain?
do the native browsers cannot use required protocols and thus need metamask?
why does the browser cannot use the JSON-RPC protocol and we use web3.js?


texts: How can metamask create account on many networks?

texts:
MetaMask is a browser extension that makes possible to have an ethereum account without run a full ethereum node.

I want to know how can metamsk create the account from my browser on many testnet like rposten, kovan without having an access to the network console.
If is it allowed by an ethereum node, how to give metamsk right to create the account on my private ethereum node.

NB: my node is using geth


texts:
I am trying to compile the following code:

pragma solidity ^0.5.1;

contract MKotET1_1{
   address payable king; uint public claimPrice = 100;

   function calculateCompensation() public returns(uint) {
}

function( ) external payable {
   if (msg.value  < claimPrice) revert();
      uint compensation = calculateCompensation();
      (bool success, bytes memory returnMessage) =
      king.call.value(compensation)("");
      require(success);
      king = msg.sender;
   }
}

I am getting following warning message:

    solc MKotET_stackExchange.sol
    MKotET_stackExchange.sol:11:26: Warning: Unused local variable.
              (bool success, bytes memory returnMessage) = king.call.value(compensation)("");
                             ^------------------------^

Somebody please guide me how to remove this warning message.

Zulfi.


texts: A beginners Geth problem with getGasPrice

texts:
I get "gas required exceeds allowance or always failing transaction" in web3.js when I call web3.eth.getGasPrice(). The error suggest that I am trying to mine a contract. I do not, I only want to get the recent gas price on Ropsten.

When I call the same function while connected to Ganache, all works as expected.

I started Geth on Ubuntu to testnet
I checked eth.syncing, after a while it returned "false". It has tons of ldb-data so I assume it is really synched.
web3.js reports it connects properly

npm -version web3
 6.4.1 (1.0.0-beta.36)

Geth
Version: 1.8.15-stable

I ran out of ideas. I assume that I missed a specific use in Geth.


texts: What is the maximum number of validators in Ethereum?

texts: I'm wondering how many validators can be maxed out in Ethereum 2.0 Proof of Stake algorithm?


texts: Two Questions Regarding the Plasma Side-Chain and Contract stuff

texts:
I have read around some stuff on the idea of side-chains and the Ethereum Plasma project, so from what I understand, the side-chain idea basically works as follows: someone can deposit ether to a Plasma contract for a side-chain, and they will receive the corresponding assets in the side-chain. Then why they want to exit the side-chain, they will need to send the side-chain assets to a certain address in the side-chain, and get corresponding ether back from the Plasma contract. So apart from some complexities in the details like bounties and exit challenges, have I understood the side-chain idea correctly?

Now a couple questions:

1) the Plasma contract only deals with how to securely deposit and redeem ethers, but how does the real conversion from ether to side-chain assets occur? Do we need some off-chain centralized system/oracle to handle it?

For example, if I create a private Ethereum network (let's call it pNet with the official token being pEther) as a side-chain to the main Ethereum network, and want to enable people to convert ether from the mainnet to pEther in the pNet, so I will deploy a Plasma contract on the mainnet to let people deposit their ether, and a nodejs app will need listen to the deposit event via web3, then another contract on the pNet to hold a lot of pEther. Each time the nodejs app receives an event that someone deposited ether to the plasma contract, it will call the contract on the pNet to distribute pEther to the corresponding address.

So the transfer of digital assets between the main chain and side-chain still requires some centralized/semi-centralized system right?

2) As the side-chain's assets and economy system completely depends on the main chain, that means the side-chain should be forbidden from generating new assets independently right? For example, if I implement a PoW consensus in the side-chain, then there must not be any block mining reward for the miners, (apart from transaction gas fees) as block reward from the side-chain will interfere with the main chain's economy system. In that sense, I guess it is best to adopt the PoA consensus for the side-chain implementation if I were to use a private Ethereum network as a side-chain, right?

Thanks.


texts: Whitelisting all addresses for a fallback function

texts:
I'm working on a contract that pays a percentage of interest of a token. The idea is to enable the fallback function only once for an address, and then it can access again to the function when it is whitelisted again.
Here's an extract of my code:

contract PercDistribution {

    mapping (address => uint256) balances;
    mapping (address => bool) public whitelist;
    Token public myToken;
    address public owner;

    function PercDistribution(address _tokenAddress, address _owner) {
        myToken = Token(_tokenAddress);
        owner = _owner;
    }

    function enableWhitelist(address[] _addresses) onlyOwner {
    for (uint i = 0; i < _addresses.length; i++) {
            whitelist[_addresses[i]] = true;
        }
    }

    function disableWhitelist(address[] _addresses) onlyOwner {
    for (uint i = 0; i < _addresses.length; i++) {
            whitelist[_addresses[i]] = false;
        }
    }

    modifier onlyWhitelist() {
        require(whitelist[msg.sender] == true);
        _;
    }

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

    function () payable onlyWhitelist public {
        address investor = msg.sender;
        //do something
        whitelist[investor] = false;
    }

}

Everything works as expected; I whitelist addresses in batch and then when someone call the fallback function his address is blacklisted until I whitelist it again. My question is: is there a way to whitelist every address (and I mean every one that could be created) with a single function, without having to batch thousands of address with the enableWhitelist function?


texts: Issue in deploying contracts through Ethereum Wallet

texts:
I am having issues in deploying contracts in ethereum testnet after updating geth version to the 1.5.6. I have been trying to deploy the basic contract as follows

 pragma solidity ^0.4.2;
 contract Sha_hash_bytes_links
 {
     function return_int()returns(uint x)
        {
            return(0);
        }
  }

But I keep getting the following error.

My testnet account address is 0x03a4406f8A50192986Ab6Ad7057AA0A958823Ed5 which has close to 36 ethers in it so it should not be a problem of not having sufficient funds. I was also able to deploy other contracts before this update.  Could someone kindly direct me ?


texts: manipulate transaction input data via web3

texts:
When sending ETH to another address via metamask, I confirmed that I can also send input data. For example, 0x7465737420746573742074657374

But I also want to know if it's possible to manipulate input data created by web3 like below:

App.contracts.Soccer.deployed().then(function(instance) {
    return instance.purchaseShoes(name, age, { from: accounts[0], value: value});
}).then(function() {
    ...

When creating a transaction using above code, web3 will pack function name, input parameters and so on in the data field of transaction and creates input data in etherscan which are the values I passed to purchaseShoes's parameters.

I know it sounds a bit weird, but like I was able to send input data from metamask, would I be able to modify input data to any content I want before web3 creates the values and send it to etherscan?


texts: What is the program counter at the start of an Ethereum method execution?

texts: When a method in a deployed contract is called (either by an externally controlled account or by another smart contract), what will the program counter be at the beginning of the method call? In other words: Where will code execution start and how does the Ethereum client and the other contracts know where the different methods are located in the EVM?


texts: Convert a string in scientific notation to a number

texts: my smart contract uses an Oracle to retrieve the price. The price is returned as a string in scientific notation, for example, "3e-8". How I can convert this to number (uint)? The token has 18 decimals, so the final value in this example should be 30000000000.


texts:
There are two types of requests in Ethereum - Call & Send

Send requests will send a transaction and hence will take up gas as transaction fee.
Call requests will call the “constant” method and execute its smart contract method in the EVM without sending a transaction.

I have 2 questions here:
 1. How can I connect to a main/testnet blockchain and make the read/call requests on that node?
 2. If the above is possible, how does Ethereum protect itself from such attacks?


texts: Persistence of tokens at crypto exchanges

texts:
There are a lot of crypto exchanges around the world and some of them have an option to add your token to the exchange. But if I get it right, the token should be ERC-20 compatible, therefore Ethereum-based? But there is one thing I can't understand (not advertising anything):

As an example, Ripple XRP Token - can be found in many exchanges, some exchanges have few currencies, like BTC, ETH, XRP, BCC and that's all, but the other have XRP and hundreds of ERC20 Tokens, Bitfinex for example. The question is - how is it possible if XRP is not Ethereum based? And if't its just a special support for XRP implemented, then why tokens made at Waves Platform (Wagerr, Starta etc) can't be traded at Bitfinex alike exchanges as well?

What am I missing?


texts:
I'm compiling a contract in Remix and am getting the error

  ParserError: Expected identifier, got 'Public'

pragma solidity ^0.4.19;

import "browser/ERC20.sol";
import "browser/SafeMath.sol";

contract TestCoin {
string public constant symbol = "TES";
string public constant name = "TestCoin";
uint8 public constant decimals = 18;

uint private constant __totalSupply = 100;
mapping (address => uint) private __balanceOf;
mapping (address => mapping (address => uint256)) internal allowed;

event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);

function public TestCoin() {
    __balanceOf[msg.sender] = __totalSupply;
}

function totalSupply() public constant returns (uint _totalSupply) {
    _totalSupply = __totalSupply;
}

Fairly new with this so any help would be greatly appreciated.


texts:
mapping (address => uint) itemsPerCreator;

if (itemsPerCreator[_creator] == null){}

  Remix give me a error: ParseError: Expected primary expression.

_creator is a addres type variable. Inside the mapping each addres have a uint value.


texts: Monitoring contract event filters with geth --light

texts:
I'm trying to sync 2 ethereum nodes with Main network. It's talking days.

I've an application that filters "Transfer" events on a specific contract.
Something like

abi = ''
address = ''
toggle = False

def get_entries():
  global toggle

  contract = w3.eth.contract(abi=abi, address=address)

  tfilter = contract.on('Transfer', {'fromBlock': 0, 'toBlock': 'latest'})

  return tfilter.get(only_changes = toggle)

  toggle = True

Since it's days to sync in normal mode ( I also tried --fast --cache=2048), if I could run an another node with --light flag, will above even work? does the --light mode support filtering contract events?

In my case I don't need any event from past, I just need to capture contract events from this point forward.


texts: Is there an API to check the real-time hashrate of specific miner pools?

texts: I would like to check the current hashrate of a certain miner, but couldn't find any resources online.


texts: Will SLI/Crossfire bypass VRAM limitations?

texts:
Would running 2 (2GB) AMD R9 270X cards in Crossfire, bypass the DAG limitations on VRAM size?

I made the mistake of thinking my single 2GB R9 270X running alongside my 6GB GTX 1060 would work out. However the DAG has exceed the 2GB limit as of this post and now I can no longer run both.

See output from Claymore's:

ETH: Authorized
Setting DAG epoch #133...
Setting DAG epoch #133 for GPU0
Create GPU buffer for GPU0
Setting DAG epoch #133 for GPU1
GPU0 - not enough GPU memory to place DAG, you cannot mine this coin with this GPU
GPU0 - OpenCL error -61 - cannot allocate big buffer for DAG. Check readme.txt for possible solutions.
Create GPU buffer for GPU1
GPU 0 failed
Setting DAG epoch #133 for GPU0
GPU0, OpenCL error -38 - cannot write buffer for DAG
GPU 0 failed
GPU1 DAG creation time - 8587 ms
Setting DAG epoch #133 for GPU1 done
GPU0 t=35C fan=20%; GPU1 t=58C fan=29%
WATCHDOG: GPU error, you need to restart miner :(
Restarting OK, exit...

I have read
Can you mine with 2GB cards or less? Thinking about the DAG issues
already and I understand combining seperate cards in one mining terminal would not work, however my inquiry is more so about combining them on the physical level with SLI/Crossfire.


texts: Is it possible to refund or cancel a contract based wallet transaction?

texts: Is it possible to refund/cancel transactions? I have sent Ether to a merchant and the funds are away from my wallet, but the merchant said I used a wrong wallet... (I sent from my contract wallet adress and they say, that they are not supporting funds from contract wallets...) What can I do know? I can see, that they received my funds, but they don´t want to give it to me. Is it possible to make a transaction donation, to get my money back?


texts:
I always thought that only the person(s) in possession of the private key to an address would be able to spend or change state for that account. But by using the recover technique rather than the normal way of doing it, I’m not so sure that the statement holds.

Consider the following example:

Construct a valid transaction and sign it normally.
Change some part of the message. This should invalidate the signature
Run the public key recovery on the signature from step 1 and the now modified message. This will produce a random address that I do not know the private key of
Send funds to the random address from step 3. Now, in Bitcoin my funds would be gone and no longer in my control as I do not know the private key of the random address I sent to.
BUT, for Ethereum, if I send the modified message with the invalid signature, a node will get it, derive the same random address and will see that the account has enough funds to pay any instrinsic gas and will process the message and thus change the world state (the nonce of the account will get incremented at the very least)

So i’ve now successfully modified the state of an account I do not know the private key to.

Is this scenario possible? If so, what benefit is there in using the recovery technique vs. the normal way?

Thanks


texts: Store and retrieve audio files on blockchain using hashes and authenticity matching

texts:
I am looking to store and retrieve hashes of authentic audio files on the Ethereum blockchain with the purpose of checking authenticity of these audio files in the future with the hashes stored on the Ethereum blockchain.

But the main concern is that even slightly tempered audio file with regards to bitrarte will provide a different hash and hence will come out as non-authentic.  Can I stored multiple hashes of different versions of the authentic audio files on the Ethereum blockchain.

What is the best way to achieve this on the Ethereum blockchain? can a smart contract be used to achieve this use case.  What hash function should be used on the audio files that would be suitable for storing in an ethereum smart contract, does it matter if its sha1/sha256.


texts: How to encrypt a file with multiple public address?

texts:
Can I encrypt a file with multiple public address such that each of them can decrypt the file using their private keys?
Thus achieving a system to securely store file on IPFS which can be accessed by only a selected number of personals.
How exactly can I achieve this?
How can I achieve this in Solidity and JS.


texts: How to delete a struct from an array without leaving a gap?

texts:
I want to delete a struct from an array.  The order doesn't matter to me so I want to do something like following where you take the last element in the array to replace the element I want to delete so that there are no gaps in the array.
mapping (address => File[]) myFiles;

function deleteFile(uint _index) public {
    require(_index >= 0, "The index cannot be a negative number");

    File[] memory files = myFiles[msg.sender];
    require(_index < files.length, "The index is out of bound");

    if (files.length == 1) {
        files.pop();
    } else {
        File memory file = files[files.length - 1];
        files[_index] = files;
        files.pop();
    }
}

However, pop is not available for struct arrays. I also cannot use files.length -- since length is read-only. How do I achieve this?


texts: Do you have to download all 'Imported new state entries' before syncing with the highest block?

texts:
I'm new to Geth...

I'm performing a fast sync using the following command:

geth --syncmode "fast" --cache 4096

I had been downloading block data until about 1000 blocks from the highestBlock. Then the ability to download blocks slowed significantly/stopped and am now receiving the following:

INFO [05-01|21:31:20] Imported new state entries               count=1467 elapsed=7.016ms   processed=131239 pending=23492 retry=2   duplicate=0 unexpected=63

I notice that the currentBlock: and highestBlock: do not update after some time, but the knownStates and pulledStates do.

> eth.syncing
{
  currentBlock: 5540855,
  highestBlock: 5540944,
  knownStates: 1,
  pulledStates: 0,
  startingBlock: 5540855
}
> eth.syncing
{
  currentBlock: 5540855,
  highestBlock: 5540944,
  knownStates: 14130,
  pulledStates: 6264,
  startingBlock: 5540855
}

Is this normal behavior for fast syncing? Do more blocks get downloaded and the highestBlock get updated again or do I have to stop and restart the geth console?


texts: Converting msg.value in other solidity units

texts:
In my app, I need to check if the value received in a payable function is equal or greater than a fixed number (priceToSell) expressed in finney. What is the best way to check that? Is that?

require (msg.value/(1 finney) >= priceToSell);

Thank you


texts: Make a HTML counter that relays stats from an address on Etherscan

texts:
I'm a new dev and I have a pretty noob question so please go easy on me :)

I'm trying to make a counter on my website that shows some stats about my Dice smart contract. I want it to include how many bets it has, largest bet, profit etc. Similar to what vdice has on their website: https://vdice.io

Any ideas on how to do this would be greatly appreciated. Thank you!


texts: How to simulate multiple consecutive transactions and get the resulting state?

texts:
I'm trying to simulate a transaction on the public blockchain that invokes a contract's method with certain parameters. Then I want to make a follow-up transaction with some other method call.

I figured that I can use call() function in the JavaScript console to invoke a method without actually publishing a real transaction, e.g:

var abi = [...];
var contractAddress = "0x...";
var contract = web3.eth.contract(abi).at(contractAddress);
contract.updateSomething.call(...);    // change some values

The problem now is: How can I make another call that uses the updated state of the contract?

If I just use another call() it returns the old value, not the updated one.

...
contract.updateSomething.call(...);    // change some values
contract.readSomething.call();         // returns old value


texts:
I really tried to look a lot of information about Geth syncing methods. I do understand differences between every syncing method but still i could not get answer to this question. I know that fast sync switches to full sync after certain point.
Does mining pool require full sync from beginning or does it just require that node is running full sync even though chaindata has been build with fast sync?
And no i am not planning on doing solomining.


texts: ERC20 token transfer is not working in Ethereum private Blockchain (contract to contrcat call)

texts:
When I am trying to call ERC20 token transfer function from another contract (contract to contract call) in ethereum private blockchain network is not working, but if I try to call directly from js it's working.
Below I have shown the contract and js call.
ERC20.sol
function transfer(address sender, address receiver, uint256 numTokens) public returns (bool)
{
    require(numTokens <= balances[admin]);
    balances[admin] = balances[admin].sub(numTokens);
    balances[receiver] = balances[receiver].add(numTokens);
    emit Transfer(admin, receiver, numTokens);
    return true;
}

ABcontract.sol
function tokentransfer(address sender, address receiver) public returns (bool) {
    ERC20Basic instance = ERC20Basic(erc20address);
    instance.transfer(sender,account,1000);
    return true;
}

app.js
tokentransfer:function(){
    ABcontract.deployed().then(function(instance){
      instance.tokentransfer(sender,receiver,{from:sender,gas:4600000});
    })
},

Sender have 1000 tokens by using ERC20 createtoken function.
Truffle v4.1.15 (core: 4.1.15)
Solidity v0.4.25 (solc-js)
node v10.19.0
Network : Private blockchain (Note:It's working in testrpc)

Help will be appreciated.


texts:
I want to send ethereum, but by writing code directly, not from the wallet or interface, like "sendrawtransaction" in bitcoin.
How can I do that I need the codes or algorithm


texts:
I am try to compute the baby step giant step algorithm to find the discrete logarithm.
But because of the warning I can't compile the code.
It appears at the uint256[] storage A and uint256[] storage B

Here is the code:

function squareRoot(uint256 x) public returns (uint256 y) {
    uint256 z = (x + 1) / 2;
    y = x;
    while (z < y) {
        y = z;
        z = (x / z + z) / 2;
    }
}

function ceiling(uint256 a) constant returns (uint256) {
    return (a / 1) * 1;
}

function proofOfWorkOptimized() onlyOwner public {
    uint256 base = 19;
    uint256 exponent;
    uint256 modulo = 221;
    uint256 valueAtIndexi;
    uint256 valueAtIndexj;

    uint256 rootCeiling = ceiling(squareRoot(modulo));

    uint256[] storage A;
    uint256[] storage B;

    for (uint256 i = 1; i <= rootCeiling; i++){
        uint256 result = base**i % modulo;
        A.push(result);
    }
    for (uint256 j = 0; j < rootCeiling; j++){
        result = base**(rootCeiling*j) % modulo;
        B.push(result);
    }
    for (i = 1; i <= A.length-1; i++){
        for (j = 1; j <= B.length-1; j++){
            if (i == j){
                valueAtIndexi = A[i];
                valueAtIndexj = B[j];
                break;
            }
        }
    }
    exponent = ((valueAtIndexj + 1)*rootCeiling - valueAtIndexi) % modulo;

How can I fix it?


texts: Add existing wallet to geth with address and password

texts:
A few months ago I mined some Ethereum. I do not have the .json file anymore. But I do have the address and the password. Currently I'm running Geth (for the past 12 hours) but I'm not able to put in any commands. For some reason it keeps syncing.

How can I write commands in Geth?
How can I add an existing wallet with address and password?


texts: Linked Trezor to an empty keystore file, how do I change it?

texts:
I generated a wallet using MyEtherWallet, first on the test network Rinkeby, then one on the real network. I copied my keystore json files for both. When connecting to my trezor wallet, I opened the empty test accounts' keystore file by accident. When I try to open MyEtherWallet with trezor, it automatically opens the empty account, so I can't transfer my eth that is in a different account with a different keystore file.

But it appears that trezor can only store one keystore file? There is no option to delete the wrong keystore file and enter the right one? I assume I can format Trezor and start over, but I already have some bitcoin in there, so I want to know if there is a simpler way than sending btc out, formatting trezor and resending everything.


texts:
Is there a way to set the block size and the block number in Remix IDE?
If not, could you suggest another platform where I can change these parameters?
Thanks


texts: Is there any other blockchain project that implements smart contract

texts:
Quite new to blockchain so my question maybe somewhat stupid. I have a blockchain project, where smart contract is required but it also has special requirement such as Proof-of-Importance. I have spent some time coding smart contracts in Ethereum. It's good but according to the project requirement, I have to understand all the Ethereum source code. So I am wondering is there any light-weighted blockchain project that implements smart contract?

Many Thanks.