|
| 1 | +--- |
| 2 | +title: Injective Cheat Sheet |
| 3 | +--- |
| 4 | + |
| 5 | +# Injective Cheat Sheet |
| 6 | + |
| 7 | +This page contains helpful helpful tips, best practices, and other general information that either does not fit into a general category, or is worth repeating here. |
| 8 | + |
| 9 | +## Contributing to the Burn Auction Pool |
| 10 | + |
| 11 | +Every week, 60% of the accumulated trading fees transform into a pool of assets that's up for auction. |
| 12 | + |
| 13 | +Members of the Injective community can participate in these auctions. Here's how it happens: |
| 14 | + |
| 15 | +- Members place their bids on the asset basket using INJ. |
| 16 | +- Once the auction concludes, the highest bid wins the assets. |
| 17 | +- This winning bid is not re-circulated. Instead, it's burned, ensuring the value of INJ is maintained. |
| 18 | + |
| 19 | +Beyond the fees, there's another way the auction pool can grow: direct contributions from community members. If you wish to boost the auction pool, you can directly send funds to the Auction subaccount. |
| 20 | + |
| 21 | +:::info |
| 22 | + |
| 23 | +When ready to contribute, send funds to the following subaccount via [MsgExternalTransfer](../modules/injective/exchange/messages#msgexternaltransfer): |
| 24 | + |
| 25 | +`0x1111111111111111111111111111111111111111111111111111111111111111` |
| 26 | + |
| 27 | +Be aware that any funds you send will be reflected in the next auction, not the current one. |
| 28 | + |
| 29 | +::: |
| 30 | + |
| 31 | +For additional help: |
| 32 | + |
| 33 | +- Follow this guide in the [Injective Python SDK example](https://github.com/InjectiveLabs/sdk-python/blob/master/examples/chain_client/30_ExternalTransfer.py) to get a comprehensive understanding. |
| 34 | + |
| 35 | +- Alternatively, refer to the following simplified code snippet: |
| 36 | + |
| 37 | +```python MsgExternalTransfer example |
| 38 | +import asyncio |
| 39 | +import logging |
| 40 | + |
| 41 | +from pyinjective.composer import Composer as ProtoMsgComposer |
| 42 | +from pyinjective.async_client import AsyncClient |
| 43 | +from pyinjective.transaction import Transaction |
| 44 | +from pyinjective.constant import Network |
| 45 | +from pyinjective.wallet import PrivateKey |
| 46 | + |
| 47 | +async def main() -> None: |
| 48 | + # select network: local, testnet, mainnet |
| 49 | + network = Network.mainnet() |
| 50 | + composer = ProtoMsgComposer(network=network.string()) |
| 51 | + |
| 52 | + # initialize grpc client |
| 53 | + # client = AsyncClient(network, insecure=False) |
| 54 | + client = AsyncClient(network, insecure=True) |
| 55 | + |
| 56 | + await client.sync_timeout_height() |
| 57 | + |
| 58 | + # load account |
| 59 | + priv_key = PrivateKey.from_hex("Your PK") |
| 60 | + pub_key = priv_key.to_public_key() |
| 61 | + |
| 62 | + address = pub_key.to_address() |
| 63 | + account = await client.get_account(address.to_acc_bech32()) |
| 64 | + print(f" pubkey {address.to_acc_bech32()}") |
| 65 | + subaccount_id = address.get_subaccount_id(index=1) |
| 66 | + dest_subaccount_id = "0x1111111111111111111111111111111111111111111111111111111111111111" |
| 67 | + |
| 68 | + # prepare tx msg |
| 69 | + msg = composer.MsgExternalTransfer( |
| 70 | + sender=address.to_acc_bech32(), |
| 71 | + source_subaccount_id=subaccount_id, |
| 72 | + destination_subaccount_id=dest_subaccount_id, |
| 73 | + amount=0.123123123, |
| 74 | + denom="INJ" |
| 75 | + ) |
| 76 | + |
| 77 | + tx = ( |
| 78 | + Transaction() |
| 79 | + .with_messages(msg) |
| 80 | + .with_sequence(client.get_sequence()) |
| 81 | + .with_account_num(client.get_number()) |
| 82 | + .with_chain_id(network.chain_id) |
| 83 | + ) |
| 84 | + |
| 85 | + # build tx |
| 86 | + gas_price = 500000000 |
| 87 | + gas_limit = 90000 + 20000 # add 20k for gas, fee computation |
| 88 | + gas_fee = '{:.18f}'.format((gas_price * gas_limit) / pow(10, 18)).rstrip('0') |
| 89 | + fee = [composer.Coin( |
| 90 | + amount=gas_price * gas_limit, |
| 91 | + denom=network.fee_denom, |
| 92 | + )] |
| 93 | + tx = tx.with_gas(gas_limit).with_fee(fee).with_memo('').with_timeout_height(client.timeout_height) |
| 94 | + sign_doc = tx.get_sign_doc(pub_key) |
| 95 | + sig = priv_key.sign(sign_doc.SerializeToString()) |
| 96 | + tx_raw_bytes = tx.get_tx_data(sig, pub_key) |
| 97 | + |
| 98 | + # broadcast tx: send_tx_async_mode, send_tx_sync_mode, send_tx_block_mode |
| 99 | + res = await client.send_tx_sync_mode(tx_raw_bytes) |
| 100 | + print(res) |
| 101 | + print("gas wanted: {}".format(gas_limit)) |
| 102 | + print("gas fee: {} INJ".format(gas_fee)) |
| 103 | + |
| 104 | +if __name__ == "__main__": |
| 105 | + asyncio.get_event_loop().run_until_complete(main()) |
| 106 | +``` |
| 107 | + |
| 108 | +### Burner Address |
| 109 | + |
| 110 | +If you would like to burn tokens directly, send funds to the following address: |
| 111 | + |
| 112 | +``` |
| 113 | +inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49 |
| 114 | +``` |
| 115 | + |
| 116 | +This is effectively the Injective `0x0...` address converted into `bech32`. |
| 117 | + |
| 118 | +## Creating Transactions |
| 119 | + |
| 120 | +### Via APIs |
| 121 | + |
| 122 | +See the [Injective API Docs](https://api.injective.exchange/#chain-api) for examples of generating, signing, and broadcasting transactions using the [Python](https://github.com/InjectiveLabs/sdk-python), [Go](https://github.com/InjectiveLabs/sdk-go/), and [TypeScript](https://github.com/InjectiveLabs/injective-ts) SDKs. |
| 123 | + |
| 124 | +### Via Ledger |
| 125 | + |
| 126 | +For Ledger support, transactions should be created and signed with the TypeScript SDK. See [here](https://docs.ts.injective.network/transactions) for transactions in TypeScript and [here](https://docs.ts.injective.network/transactions/ethereum/ethereum-ledger) for signing with Ledger. |
| 127 | + |
| 128 | +### Via `injectived` |
| 129 | + |
| 130 | +Transactions can also be generated, signed, and broadcasted through the `injectived` CLI. See [Using `injectived`](../tools/injectived/02_using.md) for an overview of the process, or the full [commands](../tools/injectived/commands#tx) for documentation on possible transactions types. |
0 commit comments