Giveth / impact-graph

MIT License
49 stars 18 forks source link

Automate minting $nice tokens for eligible donations #832

Open mohammadranjbarz opened 1 year ago

mohammadranjbarz commented 1 year ago

Now givback-calculation get donations data, and @divine-comedian fetchs data from that and distribute/mint $nice tokens for donors, but we would move it to impact-graph

If a donation to the giveth project is made in certain stablecoins - once it is confirmed we mint automatically the tokens

I need to know how to call smart contract function for this purpose (@divine-comedian would setup an address that we can give the minter permission to) then pass the private key to the impact-graph and allow it to call mint for the $nice token

divine-comedian commented 1 year ago

This is where on the UI we can give permission to a specified ETH address to have minting privileges for $nice

https://xdai.aragon.blossom.software/#/nrgiv/permissions/app/0x80446f514aaec7cfb7eb791830a672c5ef047943

I will ask amin the process for securely generating a new account we can use for minting from the impact-graph

aminlatifi commented 1 year ago

Generally, we have two ways Hold the key in our application and do the transactions! less research and hard to maintenance!! Relying on a third-party service which I am not sure will work for us, but it's worth giving it a shot

These third-party services may help https://www.openzeppelin.com/defender https://docs.gelato.network/introduction/what-is-gelato

aminlatifi commented 1 year ago

Defender Relay service seems to be right up to our alley https://docs.openzeppelin.com/defender/relay

aminlatifi commented 1 year ago

Defender Relay service seems to be right up to our alley https://docs.openzeppelin.com/defender/relay

Also supports all networks we use

aminlatifi commented 1 year ago

Openzeppelin Defender Relay has a webhook trigger that enables us to send transaction and monitor it. It has versatile features like replacing/rejecting blocked transactions and tracking the state of a sent transaction. Gelato hasn't implemented the webhook feature yet

divine-comedian commented 10 months ago

Coming back around to this feature. I tested out OP Defender and managed to setup a relayer instance in the dapp and make a local call to the relayer which then minted a token to a specified address using an aragon DAO token-manager. You can check it out here: https://github.com/divine-comedian/defender-autotask-examples/blob/master/typescript/src/index.ts#L11

I think we can implement this without too much headache. @jainkrati maybe this is a good issue for training some devs who are interested in BE work.

For context:

Currently in the dapp when a user donates to the giveth project on giveth in stablecoins (USDC, DAI, USDT etc..) we give them $nice tokens - these $nice tokens are used to buy swag from our shop and are an extra thank you for donating stable tokens. $nice tokens are minted at a rate of 1:1 per stable donated to Giveth.

However this is done manually every 2 weeks according to GIVbacks rounds and collecting the list of eligible receipients, making the votes to send the tokens etc.. all of it is done manually! So the idea here is that we could do it automatically using a service like OP Defender which can recevier HTTPS requests and make authenticated calls and trigger smart contract interactions from an EOA relayer address that Open Zeppelin facilitates our control over.

In order to make this happen we would need to:

  1. setup relayer addresss in Open Zeppelin (or use the one I made)
  2. import API keys to BE repo
  3. redefine list of eligible stables (hardcoded or from AdminJS)
  4. Give permissions on Aragon DAO for relayer to mint $nice tokens

then on donation of eligible stable tokens:

  1. check stable matches one of the eligible tokens
  2. confirm tx was successful
  3. get data for hashing mint data (donor address, amount donated)
  4. hash data by calling mint function with arguments (receiver, amount)
  5. send callData to relayer (defining target as token-manager on Aragon DAO) via authenticated https request

from there the relayer forwards the callData to aragon DAO and mints the $nice tokens to the donor on gnosis chain

we would also need to keep an eye on the relayer's balance since I think we do have to top it up manually with gas

jainkrati commented 7 months ago

Well @RamRamez is all set with his BE skills and can take this up for progressing along the learning curve!!