Injective | TS & dApps Docs
DocumentationInjective TS
  • Overview
  • Getting Started
    • Technical Concepts
    • Application Concepts
      • Calculations
        • Min Price Tick Size
        • Min Quantity Tick Size
      • Networks
      • CosmJs Support
    • Assets
      • Creating Tokens
      • Denom Client (deprecated)
      • Injective Lists
    • Running examples
  • Wallets
    • Getting Started
    • Accounts
    • Wallet Connections
    • Wallet Strategy
    • Offchain (Arbitrary) Data
  • Querying
    • Getting Started
    • Chain
      • Auction
      • Auth
      • Bank
      • Distribution
      • Exchange
      • Governance
      • IBC
      • Mint
      • Insurance Funds
      • Oracle
      • Peggy
      • Permissions
      • Staking
      • Tendermint
      • Wasm
      • WasmX
      • Token Factory
    • Indexer
      • Account
      • Auction
      • Derivatives
      • Explorer
      • Insurance Funds
      • Markets
      • Leaderboard
      • Mito
      • Oracle
      • Portfolio
      • Spot
      • Web3Gw Transactions
      • Streaming
        • Account
        • Auction
        • Derivatives
        • Oracle
        • Portfolio
        • Spot
        • Explorer
    • Ethereum (GraphQL)
  • Transactions
    • Getting Started
    • Cosmos
      • Ledger through Keplr Wallet
    • Ethereum
      • Ethereum Ledger
    • MsgBroadcaster
    • Private Key
    • Web3 Gateway
  • Core Modules (& examples)
    • Getting Started
    • Auction
    • AuthZ
    • Bank
    • Distribution
    • Exchange
    • Feegrant
    • Governance
    • IBC
    • Insurance
    • Peggy
    • Permissions
    • Staking
    • Tokenfactory
    • Wasm
  • Smart Contracts
    • Cosmwasm
      • Injective Name Service
      • Neptune Service
      • CW20 to Bank & Market Order in One Transaction
  • Bridges
    • Getting Started
    • Ethereum
    • IBC
    • Wormhole
  • Building Dapps
    • Getting Started
    • Configuring Nuxt
    • Configuring React
    • dApps Examples
      • Smart Contract
      • DEX
      • Bridge
      • Simple HTML example with Webpack
Powered by GitBook
On this page
  • Messages
  • MsgClaimVoucher
  • MsgCreateNamespace
  • MsgDeleteNamespace
  • MsgRevokeNamespaceRoles
  • MsgUpdateNamespace
  • MsgUpdateNamespaceRoles
  1. Core Modules (& examples)

Permissions

The Permissions Module facilitates the management of namespaces, roles, and permissions within the Injective ecosystem. This documentation outlines the key message types and their usage for interacting with permissions-related data.

Messages

Let's explore (and provide examples) the Messages that the Permissions module exports and we can use to interact with the Injective chain.

MsgClaimVoucher

This message is used to claim a voucher tied to a specific address within a namespace.

import {
  MsgClaimVoucher,
  MsgBroadcasterWithPk,
} from "@injectivelabs/sdk-ts";
import { Network } from "@injectivelabs/networks";

const injectiveAddress = "inj1...";
const privateKey = "0x...";
const denom = "inj";

const msg = MsgClaimVoucher.fromJSON({
  injectiveAddress,
  denom,
});

const txHash = await new MsgBroadcasterWithPk({
  privateKey,
  network: Network.Testnet
}).broadcast({
  msgs: msg
});

console.log(txHash);

MsgCreateNamespace

This message is used to creates a new namespace with permissions and roles.

import {
  MsgCreateNamespace,
  MsgBroadcasterWithPk,
} from "@injectivelabs/sdk-ts";
import { Network } from "@injectivelabs/networks";

const injectiveAddress = "inj1...";
const secondAddress = "inj2.....";
const privateKey = "0x...";
const denom = "inj";
const wasmHook = "inj3....";
const mintsPausedValue = false;
const sendsPausedValue = false;
const burnsPausedValue = false;
const role1 = "Everyone";
const permissions1 = 1;

const msg = MsgCreateNamespace.fromJSON({
  injectiveAddress,
  namespace: {
    denom,
    wasmHook,
    mintsPausedValue,
    sendsPausedValue,
    burnsPausedValue,
    rolePermissions: {
      role: role1,
      permissions: permissions1,
    },
    addressRoles: {
      address: injectiveAddress,
      roles: [role1],
    },
  },
})


const txHash = await new MsgBroadcasterWithPk({
  privateKey,
  network: Network.Testnet
}).broadcast({
  msgs: msg
});

console.log(txHash);

MsgDeleteNamespace

This message is used to delete an existing namespace.

import {
  MsgDeleteNamespace,
  MsgBroadcasterWithPk,
} from "@injectivelabs/sdk-ts";
import { Network } from "@injectivelabs/networks";

const injectiveAddress = "inj1...";
const privateKey = "0x...";
const denom = "inj";

const msg = MsgDeleteNamespace.fromJSON({
  injectiveAddress,
  denom
});

const txHash = await new MsgBroadcasterWithPk({
  privateKey,
  network: Network.Testnet
}).broadcast({
  msgs: msg
});

console.log(txHash);

MsgRevokeNamespaceRoles

This message is used to revoke roles from specified addresses in a namespace.

import {
  MsgRevokeNamespaceRoles,
  MsgBroadcasterWithPk,
} from "@injectivelabs/sdk-ts";
import { Network } from "@injectivelabs/networks";

const injectiveAddress = "inj1...";
const privateKey = "0x...";
const denom = "inj";
const roles = ["role1","role2"];

const msg = MsgRevokeNamespaceRoles.fromJSON({
  injectiveAddress,
  denom,
  addressRolesToRevoke: {
    injectiveAddress,
    roles: roles,
  },
});

const txHash = await new MsgBroadcasterWithPk({
  privateKey,
  network: Network.Testnet
}).broadcast({
  msgs: msg
});

console.log(txHash);

MsgUpdateNamespace

This message is used to update namespace properties like mints, sends, and burns.

import {
  MsgUpdateNamespace,
  MsgBroadcasterWithPk,
} from "@injectivelabs/sdk-ts";
import { Network } from "@injectivelabs/networks";

const injectiveAddress = "inj1..."
const privateKey = "0x...";
const denom = "inj";
const wasmHookValue = "inj2...";
const mintsPausedValue = false;
const sendsPausedValue = false;
const burnsPausedValue = true;

const msg = await new MsgUpdateNamespace.fromJSON({
  injectiveAddress,
  denom,
  wasmHook: {
    newValue: wasmHookValue
  },
  mintsPaused: {
    newValue: mintsPausedValue;
  },
  sendsPaused: {
    newValue: sendsPausedValue;
  },
  burnsPaused: {
    newValue: burnsPausedValue;
  },
});

const txHash = await new MsgBroadcasterWithPk({
  privateKey,
  network: Network.Testnet
}).broadcast({
  msgs: msg
});

console.log(txHash);

MsgUpdateNamespaceRoles

This message is used to modify the roles and permissions for addresses in a namespace.

import {
  MsgUpdateNamespaceRoles,
  MsgBroadcasterWithPk,
} from "@injectivelabs/sdk-ts";
import { Network } from "@injectivelabs/networks";

const injectiveAddress = "inj1...";
const privateKey = "0x...";
const denom = "inj";
const role = "role1";
const permissions = 4;

const msg = MsgUpdateNamespaceRoles.fromJSON({
  injectiveAddress,
  denom,
  rolePermissions: {
    role,
    permissions: permissions
  },
  addressRoles: {
    injectiveAddress,
    roles: [role],
  },
});

const txHash = await new MsgBroadcasterWithPk({
  privateKey,
  network: Network.Testnet
}).broadcast({
  msgs: msg
});

console.log(txHash);
PreviousPeggyNextStaking

Last updated 8 months ago