Skip to content

Commit 55f96a7

Browse files
authored
[CP-461] chore: fix STR docs and add LICENSE. Refresh README index for the docs. (#15)
1 parent 447e212 commit 55f96a7

File tree

4 files changed

+236
-89
lines changed

4 files changed

+236
-89
lines changed

LICENSE

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction,
10+
and distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity authorized by
13+
the copyright owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all
16+
other entities that control, are controlled by, or are under common
17+
control with that entity. For the purposes of this definition,
18+
"control" means (i) the power, direct or indirect, to cause the
19+
direction or management of such entity, whether by contract or
20+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
21+
outstanding shares, or (iii) beneficial ownership of such entity.
22+
23+
"You" (or "Your") shall mean an individual or Legal Entity
24+
exercising permissions granted by this License.
25+
26+
"Source" form shall mean the preferred form for making modifications,
27+
including but not limited to software source code, documentation
28+
source, and configuration files.
29+
30+
"Object" form shall mean any form resulting from mechanical
31+
transformation or translation of a Source form, including but
32+
not limited to compiled object code, generated documentation,
33+
and conversions to other media types.
34+
35+
"Work" shall mean the work of authorship, whether in Source or
36+
Object form, made available under the License, as indicated by a
37+
copyright notice that is included in or attached to the work
38+
(an example is provided in the Appendix below).
39+
40+
"Derivative Works" shall mean any work, whether in Source or Object
41+
form, that is based on (or derived from) the Work and for which the
42+
editorial revisions, annotations, elaborations, or other modifications
43+
represent, as a whole, an original work of authorship. For the purposes
44+
of this License, Derivative Works shall not include works that remain
45+
separable from, or merely link (or bind by name) to the interfaces of,
46+
the Work and Derivative Works thereof.
47+
48+
"Contribution" shall mean any work of authorship, including
49+
the original version of the Work and any modifications or additions
50+
to that Work or Derivative Works thereof, that is intentionally
51+
submitted to Licensor for inclusion in the Work by the copyright owner
52+
or by an individual or Legal Entity authorized to submit on behalf of
53+
the copyright owner. For the purposes of this definition, "submitted"
54+
means any form of electronic, verbal, or written communication sent
55+
to the Licensor or its representatives, including but not limited to
56+
communication on electronic mailing lists, source code control systems,
57+
and issue tracking systems that are managed by, or on behalf of, the
58+
Licensor for the purpose of discussing and improving the Work, but
59+
excluding communication that is conspicuously marked or otherwise
60+
designated in writing by the copyright owner as "Not a Contribution."
61+
62+
"Contributor" shall mean Licensor and any individual or Legal Entity
63+
on behalf of whom a Contribution has been received by Licensor and
64+
subsequently incorporated within the Work.
65+
66+
2. Grant of Copyright License. Subject to the terms and conditions of
67+
this License, each Contributor hereby grants to You a perpetual,
68+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69+
copyright license to reproduce, prepare Derivative Works of,
70+
publicly display, publicly perform, sublicense, and distribute the
71+
Work and such Derivative Works in Source or Object form.
72+
73+
3. Grant of Patent License. Subject to the terms and conditions of
74+
this License, each Contributor hereby grants to You a perpetual,
75+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76+
(except as stated in this section) patent license to make, have made,
77+
use, offer to sell, sell, import, and otherwise transfer the Work,
78+
where such license applies only to those patent claims licensable
79+
by such Contributor that are necessarily infringed by their
80+
Contribution(s) alone or by combination of their Contribution(s)
81+
with the Work to which such Contribution(s) was submitted. If You
82+
institute patent litigation against any entity (including a
83+
cross-claim or counterclaim in a lawsuit) alleging that the Work
84+
or a Contribution incorporated within the Work constitutes direct
85+
or contributory patent infringement, then any patent licenses
86+
granted to You under this License for that Work shall terminate
87+
as of the date such litigation is filed.
88+
89+
4. Redistribution. You may reproduce and distribute copies of the
90+
Work or Derivative Works thereof in any medium, with or without
91+
modifications, and in Source or Object form, provided that You
92+
meet the following conditions:
93+
94+
(a) You must give any other recipients of the Work or
95+
Derivative Works a copy of this License; and
96+
97+
(b) You must cause any modified files to carry prominent notices
98+
stating that You changed the files; and
99+
100+
(c) You must retain, in the Source form of any Derivative Works
101+
that You distribute, all copyright, patent, trademark, and
102+
attribution notices from the Source form of the Work,
103+
excluding those notices that do not pertain to any part of
104+
the Derivative Works; and
105+
106+
(d) If the Work includes a "NOTICE" text file as part of its
107+
distribution, then any Derivative Works that You distribute must
108+
include a readable copy of the attribution notices contained
109+
within such NOTICE file, excluding those notices that do not
110+
pertain to any part of the Derivative Works, in at least one
111+
of the following places: within a NOTICE text file distributed
112+
as part of the Derivative Works; within the Source form or
113+
documentation, if provided along with the Derivative Works; or,
114+
within a display generated by the Derivative Works, if and
115+
wherever such third-party notices normally appear. The contents
116+

README.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
## Upload and interact with MintBurnBankERC20 using Foundry
2-
Install Foundry first, then:
1+
## Solidity Contracts
32

4-
```sh
5-
# create address in local keystore
6-
cast wallet import ccc --mnemonic "XXXXXXX"
3+
This repository contains a collection of Solidity contracts that can be used to interact with the Injective blockchain.
74

8-
# compile and deploy SC
9-
forge create src/MintBurnBankERC20.sol:MintBurnBankERC20 -r evmixt --account ccc --broadcast --constructor-args 0xCCCC7F724FD589F95D50BeDD60E6BA1D4b145ccc "MintBurnBankERC20" "MintBurnBankERC20" 18
10-
# copy the deployed SC address
5+
Examples for how to use these contracts can be found in the [demos](demos) directory. The repo itself is a Foundry project, so you can use the `forge` command to compile and deploy the contracts. Also, can be included in your own Foundry project as a dependency.
116

12-
# mint
13-
cast send -r evmixt --account ccc 0x6139E59DceB290b5c80127dF87242429D42143d2 "mint(address,uint256)" 0xCCCC7F724FD589F95D50BeDD60E6BA1D4b145ccc 666
7+
### ERC20 Multi-Token Standard (Bank Precompile)
148

15-
# query through EVM JSON-RPC
16-
cast call -r evmixt 0x6139E59DceB290b5c80127dF87242429D42143d2 "balanceOf(address)" 0xCCCC7F724FD589F95D50BeDD60E6BA1D4b145ccc
9+
Injective implements its multi-token standard for ERC-20 tokens using the Bank precompile, which connects EVM-based smart contracts to the native `x/bank` module. This eliminates double-accounting and enables seamless interoperability between the EVM and native chain state. The standard includes ready-to-use contracts like `BankERC20`, `FixedSupplyBankERC20`, and `MintBurnBankERC20`.
1710

18-
# query through cosmos x/bank
19-
injectived q bank balance inj1enx87uj06kyljh2shmwkpe46r493ghxv3360aq evm/0x6139E59DceB290b5c80127dF87242429D42143d2 --node https://k8s.testnet.evmix.tm.injective.network
11+
For more details, see the [ERC20 Multi-Token Standard documentation](docs/erc20_multi_token_standard.md) and try out the [ERC20 demo](demos/erc20/README.md).
2012

21-
# transfer
22-
cast send -r evmixt --account ccc 0x6139E59DceB290b5c80127dF87242429D42143d2 "transfer(address,uint256)" 0xC6Fe5D33615a1C52c08018c47E8Bc53646A0E101 555
23-
```
13+
14+
### Exchange Precompile
15+
16+
The Exchange Precompile provides a system smart contract interface for interacting with Injective's exchange module directly from Solidity. It enables smart contracts to perform actions like deposits/withdrawals, order management, balance queries, and authorization handling. The precompile can be accessed directly by contracts managing their own funds, or through a proxy pattern for contracts acting on behalf of users.
17+
18+
For more details, see the [Exchange Precompile documentation](docs/exchange_precompile.md) and try out the [Exchange demo](demos/exchange/README.md).
19+
20+
21+
### Staking Precompile
22+
23+
The Staking Precompile provides a system smart contract interface for interacting with Injective's staking module directly from Solidity. It enables smart contracts to perform staking operations like delegating tokens to validators, undelegating, redelegating between validators, querying delegation data, and withdrawing staking rewards.
24+
25+
For more details, see the [Staking Precompile documentation](docs/staking_precompile.md) and try out the [Staking demo](demos/staking/README.md).
26+
27+
28+
## License
29+
30+
This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.

docs/erc20_multi_token_standard.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# ERC20 and Multi-Token Standard on Injective
2+
3+
Injective implements its multi-token standard for ERC-20 tokens using
4+
the Bank precompile, which connects EVM-based smart contracts to the native
5+
`x/bank` module. This model eliminates double-accounting and enables seamless
6+
interoperability between the EVM and the native chain state.
7+
8+
We also provide an `erc20` module that allows you to deploy ERC-20 tokens wrapping
9+
any native assets issued via `tokenfactory` module or IBC.
10+
11+
## Overview
12+
13+
The Bank precompile allows Solidity smart contracts to interact directly with
14+
the native `x/bank` module of the Injective chain. By using this precompile,
15+
developers can implement ERC-20 tokens that are backed entirely by native chain
16+
balances, rather than managing a separate balance within the EVM.
17+
18+
Each ERC-20 token using the Bank precompile is represented on-chain with a
19+
special denom of the form:
20+
21+
```
22+
erc20:<contract-address>
23+
```
24+
25+
For example, a token deployed at `0x123...abc` will have a denom of `erc20:0x123...abc`.
26+
27+
## Key Properties
28+
29+
- Single source of truth: Tokens exist only on-chain via the `x/bank` module.
30+
The smart contract simply provides a view and interface for the native balances.
31+
32+
- No bridging required: Unlike traditional bridge-based representations, this
33+
model avoids dual-token setups. There is no need for wrapping/unwrapping or
34+
deposit/withdraw actions.
35+
36+
- Instant consistency: Any native bank transfer is immediately reflected in the
37+
ERC-20 view, and any `transfer()` call in Solidity reflects directly in the chain
38+
state.
39+
40+
## Benefits
41+
42+
🔒 **Secure** – No wrapped tokens or bridging logic; balances are held directly in
43+
the Injective chain.
44+
45+
🚀 **Fast and simple** – No sync delays or manual operations to keep two systems in
46+
balance.
47+
48+
🧠 **Developer-friendly** – Use familiar ERC-20 interfaces while leveraging native
49+
chain accounting.
50+
51+
## Available Contracts
52+
53+
Several reusable contracts are available.
54+
55+
| Contract | Description |
56+
| ------------------------- | ------------------------------------------------------------------------- |
57+
| [Bank.sol](../src/Bank.sol) | Interface for the Bank precompile |
58+
| [BankERC20.sol](../src/BankERC20.sol) | Abstract ERC-20 implementation backed by the Bank precompile |
59+
| [FixedSupplyBankERC20.sol](../src/FixedSupplyBankERC20.sol) | ERC-20 with a fixed supply, fully decentralized (no minting or burning) |
60+
| [MintBurnBankERC20.sol](../src/MintBurnBankERC20.sol) | ERC-20 with an owner that can mint and burn tokens |
61+
62+
All implementations extend OpenZeppelin’s standard ERC20 interfaces, enabling
63+
easy integration and extension.
64+
65+
## Customise Your Own ERC-20
66+
67+
Developers are free to implement their own ERC-20 tokens using the Bank
68+
precompile interface. Start by inheriting from `BankERC20.sol`, or fork and modify
69+
existing implementations to suit your requirements.
70+
71+
## Minting ERC-20 Tokens requires a fee
72+
73+
Minting ERC-20 tokens creates a `x/bank` native denom, and for the first mint a fee is required.
74+
75+
The default fee is 1 INJ, however the value is configurable and may change in the future, you can check the current fee value by querying the `erc20` module:
76+
77+
```json
78+
// injectived q erc20 params --chain-id injective-1 --output=json
79+
80+
{"params":{"denom_creation_fee":{"denom":"inj","amount":"1000000000000000000"}}}
81+
```
82+
83+
**Key tips about the fee:**
84+
85+
* It's required only for the first mint of a new denom.
86+
* Usually you can include it when deploying the ERC-20 contract, in our `MintBurnBankERC20.sol` example the constructor is payable.
87+
* It can be sent to contract address after deployment, in a separate transaction.
88+
* It can be included in the `mint()` function call, as `msg.value`, but it works when the method is payable.
89+
* Finally, make sure that when a *transparent upgradeable proxy* is used, the fee is sent to the proxy address, not the implementation address.
90+
91+
## Example
92+
93+
For a full example of how to deploy and interact with our `MintBurnBankERC20.sol`
94+
contract, which is banked entirely by `x/bank` denoms, please refer to the
95+
[ERC20 demo](../demos/erc20/README.md)
96+

erc20_single_token_representation.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)