Azoyalabs / avalanche_hackathon

https://avalanche-hackathon-web.vercel.app
0 stars 1 forks source link

Define Behaviour for minting author token #4

Closed Wally869 closed 8 months ago

Wally869 commented 8 months ago

Minting is done using a transferAndCall on the CCIP-BnM token which calls the Receiver which in turns calls the Summit contract to mint a token.

This flow is fine for a Reader User, but transferAndCall should require tokens to be transferred. The issue is for a Writer User creating a new article: this is a free action and transferAndCall may not be appropriate if no funds are sent

To Do

Wally869 commented 8 months ago

CCIP-BnM contract seems to accept 0 value transferAndCall (see passing tests in b0695aa2ee157e382651c9d651298b3afc6181d1)

Will need to verify by calling the contract on testnet to be sure

Wally869 commented 8 months ago

Also what about crosschain calls?

Wally869 commented 8 months ago

CCIP-BnM contract seems to accept 0 value transferAndCall (see passing tests in b0695aa)

Will need to verify by calling the contract on testnet to be sure

I confirmed that 0-value transferAndCall are correctly working in a same-chain context https://testnet.snowtrace.io/tx/0xa21f3e71ed14e44aa4a164414768eec4f1a0c556f34fad56c20d769cc11beca9?chainId=43113

Wally869 commented 8 months ago

Docs also show that cross-chain messaging can be independent from sending a token. Difference is: I think it'll be calling CCIPReceive instead of onTokenTransfer?

So both functions should do same thing, need to check which function is called in which context tbh

Wally869 commented 8 months ago

Crosschain calls between testnets are a success: https://ccip.chain.link/msg/0x0f247d9e6505516dfc7d6f7a49b680384cec6d385ebe6b8006dc378b9d64749e

Crosschain token transfers call the "_ccipReceive" function, while same chain transferAndCall call the "onTokensTransfer" method.

Parameters for send in crosschain are a bit troublesome, plus require fees estimate, maybe create a small sender contract to simplify the task. Closing for now, would be in another issue