-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from InjectiveLabs/docs/update-examples
docs/update examples
- Loading branch information
Showing
26 changed files
with
1,728 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Fee Grant | ||
|
||
The `feegrant` module allows accounts (granters) to grant fee allowances to other accounts (grantees). This allows the grantee to use the granter's funds to pay for transaction fees. | ||
|
||
## Messages | ||
|
||
### MsgGrantAllowance | ||
|
||
A fee allowance grant is created using the `MsgGrantAllowance` message. If there is already a grant for the (granter, grantee) pair, then the new grant will overwrite the previous one. | ||
|
||
```ts | ||
import { MsgGrantAllowance, MsgBroadcasterWithPk } from '@injectivelabs/sdk-ts' | ||
import { Network } from '@injectivelabs/networks' | ||
|
||
|
||
const privateKeyOfGranter = '0x...' | ||
|
||
const date = new Date('2023-10-02T00:00:00Z') | ||
const expiration = date.getTime() / 1000 | ||
const granter = 'inj...' | ||
const grantee = 'inj...' | ||
const allowance = { | ||
spendLimit: [ | ||
{ | ||
denom: 'inj', | ||
amount: '10000', | ||
}, | ||
], | ||
expiration | ||
} | ||
|
||
const msg = MsgGrantAllowance.fromJSON({ | ||
granter, | ||
grantee, | ||
allowance, | ||
}) | ||
|
||
const txHash = await new MsgBroadcasterWithPk({ | ||
privateKey: privateKeyOfGranter, | ||
network: Network.Testnet, | ||
}).broadcast({ | ||
msgs: msg, | ||
}) | ||
|
||
console.log(txHash) | ||
|
||
``` | ||
|
||
### MsgRevokeAllowance | ||
A grant can be removed using the MsgRevokeAllowance message. The grantee will no longer be able to use the granter's funds to pay for transaction fees. | ||
|
||
```ts | ||
import { MsgRevokeAllowance, MsgBroadcasterWithPk } from '@injectivelabs/sdk-ts' | ||
import { Network } from '@injectivelabs/networks' | ||
|
||
const privateKey= "0x..." | ||
const granteeAddress = 'inj...' | ||
const granterAddress = 'inj...' | ||
|
||
const params = { | ||
grantee: granteeAddress, | ||
granter: granterAddress, | ||
} | ||
|
||
const msg = MsgRevokeAllowance.fromJSON(params); | ||
|
||
const txHash = await new MsgBroadcasterWithPk({ | ||
privateKey, | ||
network: Network.Testnet, | ||
}).broadcast({ | ||
msgs: msg, | ||
}) | ||
|
||
console.log(txHash) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.