-
Notifications
You must be signed in to change notification settings - Fork 3
docs: permissioned mts tokens #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
012896e
7c7c3f6
c192f37
19c66c1
aec3883
62f3c2d
6b4f5b0
b6a0c01
a7881f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| title: Permissioned MTS Tokens | ||
| description: Leverage Injective's permissions module in MultiVM Token Standard (MTS) tokens | ||
| --- | ||
|
|
||
| ## Injective's Permissions Module | ||
|
|
||
| The [`permissions` module](https://docs.injective.network/developers-native/injective/permissions) | ||
| is native to Injective, and allows custom management (e.g. roles) for Denoms. | ||
| This capability is extended to MultiVM Token Standard (MTS) tokens, | ||
| where you can implement those custom management rules within your EVM smart contract code. | ||
|
|
||
| ## Why Uses Permissions on MTS Tokens? | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| If you are tokenizing real world assets (RWAs) using MTS on Injective, | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| and that underlying asset inherently requires permissions, | ||
| that is a great use case for tapping into Injective's `permissions` module. | ||
|
|
||
| The EVM smart contract of your MTS token simply needs to implement | ||
| an additional Solidity interface to leverage the power of the `permissions` module. | ||
|
|
||
| ## Implementation | ||
|
|
||
| In your smart contract, import `IPermissionsHook` from `PermissionsHook.sol` and extend it. | ||
|
|
||
| ```solidity | ||
| interface IPermissionsHook | ||
| ``` | ||
|
|
||
| This will involve implementing the `isTransferRestricted` function, | ||
| with the following signature: | ||
|
|
||
| ```solidity | ||
| function isTransferRestricted( | ||
| address from, | ||
| address to, | ||
| Cosmos.Coin calldata amount | ||
| ) | ||
| ``` | ||
|
|
||
| You may find the full file on Github: | ||
| [`PermissionsHook.sol`](https://github.com/InjectiveLabs/solidity-contracts/blob/master/src/PermissionsHook.sol) | ||
|
|
||
| ## Example | ||
|
|
||
| Create a smart contract that extends `PermissionsHook`: | ||
|
|
||
| ```solidity | ||
| import { Cosmos } from "../src/CosmosTypes.sol"; | ||
| import { PermissionsHook } from "../src/PermissionsHook.sol"; | ||
| contract RestrictedAddressTransferHook is PermissionsHook { | ||
| /* | ||
| ... | ||
| */ | ||
| } | ||
| ``` | ||
|
|
||
| Add a custom implementation of the `isTransferRestricted` function. | ||
| For example, this function will allow all transfers, | ||
| exepct for ones involving a specific address: | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```solidity | ||
| function isTransferRestricted( | ||
| address from, | ||
| address to, | ||
| Cosmos.Coin calldata amount | ||
| ) external pure override returns (bool) { | ||
| address restrictedAddress = '0x...'; | ||
| if (from == restrictedAddress || to == restrictedAddress) { | ||
| // this particular address is not allowed to transfer | ||
| return true; | ||
| } | ||
|
|
||
| // All other transfers are allowed | ||
| return false; | ||
| } | ||
| ``` | ||
|
Comment on lines
+62
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix Solidity syntax error in code example. Line 68 contains invalid Solidity syntax. Address literals in Solidity must not use quotes (single or double). The current example uses 🔎 Proposed fix function isTransferRestricted(
address from,
address to,
Cosmos.Coin calldata amount
) external pure override returns (bool) {
- address restrictedAddress = "0x...";
+ address restrictedAddress = 0x0000000000000000000000000000000000000000; // Replace with actual address
if (from == restrictedAddress || to == restrictedAddress) {
// this particular address is not allowed to transfer
return true;
}
// All other transfers are allowed
return false;
}Alternatively, for a more realistic example, consider using a state variable or constructor parameter as shown in the previous review. 🤖 Prompt for AI Agents |
||
|
|
||
| You may find a more detailed example of this on Github: | ||
| [`PermissionsHookExamples.sol`](https://github.com/InjectiveLabs/solidity-contracts/blob/master/examples/PermissionsHookExamples.sol) | ||
Uh oh!
There was an error while loading. Please reload this page.