Skip to content

Commit

Permalink
chore: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Jul 25, 2024
1 parent b813000 commit 4c535a2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 46 deletions.
86 changes: 41 additions & 45 deletions .gitbook/core-modules/token-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,99 +19,93 @@ Creates a denom of `factory/{creator address}/{subdenom}` given the denom creato
Keep in mind that that the `admin` of the token can change the supply (mint or burn new tokens). Its recommended that the `admin` is unset using the `MsgChangeAdmin`, as explained below.

```ts
import {
MsgCreateDenom,
} from "@injectivelabs/sdk-ts";
import { BigNumberInBase } from "@injectivelabs/utils";
import { Network } from "@injectivelabs/networks";
import { MsgCreateDenom } from '@injectivelabs/sdk-ts'
import { BigNumberInBase } from '@injectivelabs/utils'
import { Network } from '@injectivelabs/networks'

const injectiveAddress = "inj1...";
const privateKey = "0x...";
const subdenom = "inj-test";
const injectiveAddress = 'inj1...'
const privateKey = '0x...'
const subdenom = 'inj-test'

const msg = MsgCreateDenom.fromJSON({
subdenom,
symbol: 'InjTest',
name: 'Inj Testing',
sender: injectiveAddress,
});
})

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

console.log(txHash);
console.log(txHash)
```

#### MsgMint

Minting of a specific denom is only allowed for the current admin. Note, the current admin is defaulted to the creator of the denom.

```ts
import {
MsgMint,
} from "@injectivelabs/sdk-ts";
import { BigNumberInBase } from "@injectivelabs/utils";
import { Network } from "@injectivelabs/networks";
import { MsgMint } from '@injectivelabs/sdk-ts'
import { BigNumberInBase } from '@injectivelabs/utils'
import { Network } from '@injectivelabs/networks'

const injectiveAddress = "inj1...";
const privateKey = "0x...";
const subdenom = "inj-test";
const injectiveAddress = 'inj1...'
const privateKey = '0x...'
const subdenom = 'inj-test'
const amountToMint = 1_000_000_000

const msg = MsgMint.fromJSON({
sender: injectiveAddress,
amount: {
denom: `factory/${injectiveAddress}/${subdenom}`,
amount: amountToMint
}
});
amount: amountToMint,
},
})

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

console.log(txHash);
console.log(txHash)
```

#### MsgBurn

Burning of a specific denom is only allowed for the current admin. Note, the current admin is defaulted to the creator of the denom.

```ts
import {
MsgBurn,
} from "@injectivelabs/sdk-ts";
import { BigNumberInBase } from "@injectivelabs/utils";
import { Network } from "@injectivelabs/networks";
import { MsgBurn } from '@injectivelabs/sdk-ts'
import { BigNumberInBase } from '@injectivelabs/utils'
import { Network } from '@injectivelabs/networks'

const injectiveAddress = "inj1...";
const privateKey = "0x...";
const subdenom = "inj-test";
const injectiveAddress = 'inj1...'
const privateKey = '0x...'
const subdenom = 'inj-test'
const amountToBurn = 1_000_000_000

const msg = MsgBurn.fromJSON({
sender: injectiveAddress,
amount: {
denom: `factory/${injectiveAddress}/${subdenom}`,
amount: amountToBurn
}
});
amount: amountToBurn,
},
})

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

console.log(txHash);
console.log(txHash)
```

#### MsgSetDenomMetadata
Expand Down Expand Up @@ -159,7 +153,8 @@ const msg = MsgSetDenomMetadata.fromJSON({
name: '', /** the name of your token */
symbol: '', /** the symbol of your token */
uri: '' /** the logo of your token, should be hosted on IPFS and should be a small webp image */
denomUnits: denomUnitsIfTokenHas6Decimals /** choose if you want to have 6 or 0 decimals for the token */
denomUnits: denomUnitsIfTokenHas6Decimals /** choose if you want to have 6 or 0 decimals for the token */,
decimals: 6 /** choose if you want to have 6 or 0 decimals for the token */
}
});

Expand Down Expand Up @@ -190,7 +185,8 @@ const denom = `factory/${injectiveAddress}/${subdenom}`
const msg = MsgChangeAdmin.fromJSON({
denom,
sender: injectiveAddress,
newAdmin: 'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49' /** SET TO ZERO ADDRESS */,
newAdmin:
'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49' /** SET TO ZERO ADDRESS */,
})

const txHash = await new MsgBroadcasterWithPk({
Expand Down
3 changes: 2 additions & 1 deletion .gitbook/core-modules/tokenfactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ const msg = MsgSetDenomMetadata.fromJSON({
name: '', /** the name of your token */,
symbol: '' /** the symbol of your token */,
uri: '' /** the logo of your token, should be hosted on IPFS and should be a small webp image */
denomUnits: denomUnitsIfTokenHas6Decimals /** choose if you want to have 6 or 0 decimals for the token */
denomUnits: denomUnitsIfTokenHas6Decimals /** choose if you want to have 6 or 0 decimals for the token */,
decimals: 6 /** choose if you want to have 6 or 0 decimals for the token */
}
});

Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,18 @@
link-module-alias "^1.2.0"
shx "^0.3.2"

"@injectivelabs/test-utils@^1.14.13-beta.0":
version "1.14.13"
resolved "https://registry.yarnpkg.com/@injectivelabs/test-utils/-/test-utils-1.14.13.tgz#b63636e5c780e86b2dda948ee0b16199d96a42c4"
integrity sha512-wa5TQcWLvORRm36mw4Hee+XF7lBlArVK3DM1ebC0uBvVcUgrmm3g/nh1pV/NzLN16WtrLLsvnTsE5uiNEcgYdw==
dependencies:
axios "^1.6.4"
bignumber.js "^9.0.1"
link-module-alias "^1.2.0"
shx "^0.3.2"
snakecase-keys "^5.1.2"
store2 "^2.12.0"

"@injectivelabs/ts-types@^1.14.12", "@injectivelabs/ts-types@^1.14.12-beta.0":
version "1.14.12"
resolved "https://registry.yarnpkg.com/@injectivelabs/ts-types/-/ts-types-1.14.12.tgz#6a3b9882665d0e6899cdf1b3cc290ca1fd2cfa53"
Expand Down

0 comments on commit 4c535a2

Please sign in to comment.