0

I want to create a set of coins implementing fungible-v2 and a set of internal features. My approach has been to create an interface mytoken and to implement both mytoken and fungible-v2 in mytoken1. I have also created a table for account balance and so on.

The problem is that if I want to create a new token mytoken2 with tiny differences from mytoken1 (maybe just the name), I have to copy all the contract (which is really huge in terms of line codes).

Another alternative would be to create another module with the common behaviour but in that case I believe I could find some issues with capability handling, module governance, etc. in calls between modules (and I will need to create the all functions to fulfill the public interfaces).

In Solidity there is the abstract and extend reserved words allowing to inherit common behavior.

Which would be the best approach in PACT?

datoga
  • 103
  • 8

1 Answers1

0

To avoid code duplication you can wrap the functions from a module token as base for your module token1, token2, ...

Stuart Popejoy wrote an extended example on how wrapping can be used: https://medium.com/kadena-io/pact-tips-wrapper-contracts-7034be982c56

georgep
  • 731
  • 1
  • 12