2

If I make an ethereum smart contract - call it simplecoin, can I set it up such that I can allow users of the coin to mine the transactions? Rather than a generic ethereum miner that would charge gas?

Is this possible?

1

Yes it is possible. However, it depends how you define "mining".

Normally mining means the action of a consensus protocol, like Proof of Work, or Proof of Stake, etc. So it will affect how coins are created. You will need to be very careful to allow the execution of

coins[msg.sender] += 5;

which means the creation must be in the guidance of the consensus protocol.

Here is an example. You define an new coin (ERC20) with following feature:

Every 100 block, you give 5% interests to token holder.

func getInterest(){
    if( (coins[msg.sender].lastClainBlk + 100 ) < block.number ){
        coins[msg.sender].balance += coins[msg.sender].balance *RATE;
        coins[msg.sender].lastClainBlk = block.number
    }
}

Token holder can explicitly call this function to claim the interest. Or done implicitly during transfer.

0

Yes, this is possible.

Just create a function in your contract that takes an array of transactions and a nonce:

assert(transactionsValid(transactions));
var new_head = hash(transactions, nonce, blockhead);
assert(new_head < threshold);
coins[msg.sender] += 5;
blockhead = new_head;

Most likely you'd ommit transactions and just keep nonce and head.

0

No: I'm assuming your smart contract requires modifying the blockchain (you mention "coin", so presumably you track balances on-chain).

You can have an Ethereum smart contract that validates transactions using a mining process. However, it can only be in addition to, not instead of the regular Ethereum mining process. If a contract modifies the blockchain, it will consume gas which must be paid for using ether. A corollary is that your minimum (on-chain) confirmation time is Ethereum's block time. More generally, you cannot write an Ethereum smart-contract to get around the rules of Ethereum.

-1

As far as I know, this is not a possibility. At this point, all transactions are processed by running nodes (miners).

What you suggest, would be 'leaving the network' to get your contracts (mining) done by external resources to save the gas cost. Which is not possible and violates some of the core principles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.