1

I am wondering if it is possible to call a function of a smart contract every time a block is mined, perhaps as part of the coinbase transaction? The result of the call would be to send a percentage of the block reward to a storage contract.

2 Answers 2

0

If you're a miner, you can include whatever (valid) transactions you want in the blocks you mine. So yes, you could include a transaction that transfers ether to a contract.

2
  • But if the destination addresses of the receiving parties was constantly changing based on some business logic for example, it would be easier to include this logic at the application layer (smart contract). How would you include this in the protocol - to necessitate a contract call?
    – lulbaiking
    Jan 22, 2018 at 3:24
  • I think I'm confused about what you're trying to do. Miners can include any valid transaction they want, because they're the ones putting together the block. They can decide right before assembling the block what transaction they want to include, or they can always include a transaction that sends ether to a contract (that then distributes it). Does that help?
    – user19510
    Jan 22, 2018 at 4:07
0

We can do it by using abigen tool to generate go binding to the smart contract and call contract's method on consensus level against a backend with current chain's state. Similar to Ethereum's SimulatedBackend but with real chain's state.

By the way, we can do in more simple way. You need only to AddBlance() to give mining reward to the smart contact similar to AddBalance() for PoW miners' coinbase. The thing we need to do more is making a method/dapp allow user to claim reward from contract's balance.

Hope this help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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