• Stars
    star
    129
  • Rank 277,721 (Top 6 %)
  • Language
    Solidity
  • Created about 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Smart contracts and smart contract utilities for use with Immutable X.

Immutable X Contracts

Installation:

npm install @imtbl/imx-contracts

or

yarn add @imtbl/imx-contracts

Immutable Contract Addresses

Environment/Network Core (StarkEx Bridge) Contract User Registration Contract
Sandbox (Goerli) 0x7917edb51ecd6cdb3f9854c3cc593f33de10c623 0x1c97ada273c9a52253f463042f29117090cd7d83
Production (Mainnet) 0x5fdcca53617f4d2b9134b29090c87d01058e27e9 0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c

Setup

You will need an Ethereum wallet private key to deploy contracts. This can be your own private key or you can use the scripts/generateRandomKey.ts script to generate a new random Ethereum private key and address for use with this repo with the following command:

yarn generate-random-key

Also required are API keys for Alchemy and Etherscan to deploy contracts from this repo.

  1. Make a copy of the .env.example file and rename the file to .env.
  2. Add private keys and API keys to the .env file.

Note: All the environment variables in .env need a value or hardhat will throw an error.

L2 Minting

Immutable X is the only NFT scaling protocol that supports minting assets on L2, and having those assets be trustlessly withdrawable to Ethereum L1. To enable this, before you can mint on L2, you need to deploy an IMX-compatible ERC721 contract as the potential L1 home for these assets. Luckily, making an ERC721 contract IMX-compatible is easy!

No Code Usage (Test Environment Only)

In the test environment, deploying an ERC721 contract which is compatible with Immutable X is extremely easy. First, update the .env file, setting:

  • CONTRACT_OWNER_ADDRESS
  • CONTRACT_NAME
  • CONTRACT_SYMBOL
  • ETHERSCAN_API_KEY

Then, just run yarn hardhat run deploy/asset.ts --network sandbox.

Basic Usage

If you're starting from scratch, simply deploy a new instance of Asset.sol and you'll have an L2-mintable ERC721 contract. Set the _imx parameter in the contract constructor to either the Sandbox or Production addresses as above.

If you already have an ERC721 contract written, simply add Mintable.sol as an ancestor, implement the _mintFor function with your internal mint function, and set up the constructor as above:

import "@imtbl/imx-contracts/contracts/Mintable.sol";

contract YourContract is Mintable {

    constructor(address _imx) Mintable(_imx) {}

    function _mintFor(
        address to,
        uint256 id,
        bytes calldata blueprint
    ) internal override {
        // TODO: mint the token using your existing implementation
    }

}

Advanced Usage

To enable L2 minting, your contract must implement the IMintable.sol interface with a function which mints the corresponding L1 NFT. This function is mintFor(address to, uint256 quantity, bytes mintingBlob). Note that this is a different function signature to _mintFor in the previous example. The "blueprint" is the immutable metadata set by the minting application at the time of asset creation. This blueprint can store the IPFS hash of the asset, or some of the asset's properties, or anything a minting application deems valuable. You can use a custom implementation of the mintFor function to do whatever you like with the blueprint.

Your contract also needs to have an owner() function which returns an address. You must be able to sign a message with this address, which is used to link this contract your off-chain application (so you can authorise L2 mints). A simple way to do this is using the OpenZeppelin Ownable contract (npm install @openzeppelin/contracts).

import "@imtbl/imx-contracts/contracts/Mintable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract YourContract is IMintable, Ownable {

    function mintFor(
        address to,
        uint256 quantity,
        bytes calldata mintingBlob
    ) external override {
        // TODO: make sure only Immutable X can call this function
        // TODO: mint the token!
    }

}

Registration.sol & IMX.sol is for reference purposes if you choose to offer these functions in your own smart contracts and is not required if you only want to deploy an ERC721.

Manually verifying registration contract

First, deploy to sandbox as described in the L2 Minting section. Change to mainnet if required.

Verification with Etherscan should happen automatically within a few minutes of contract deployment, but if it fails you can run it manually, e.g.

yarn hardhat verify --network <network> <address> <args used in deployment>

Generating Typescript Types

Run yarn compile. The output can be found in the artifacts/typechain folder.

More Repositories

1

imx-starknet

Immutable X on StarkNet
Python
70
star
2

imx-core-sdk

The Immutable Core SDK provides convenient access to the Immutable API's and Ethereum contract methods for applications written on the Immutable X platform.
TypeScript
61
star
3

gods-unchained-api

Public developer API documentation for Gods Unchained.
58
star
4

imx-reactjs-integration-example

React app to demonstrate basic Immutable X integration flows
TypeScript
45
star
5

imx-examples

Examples for Immutable X developers.
TypeScript
45
star
6

contracts

Smart contracts for developers in the Immutable ecosystem.
Solidity
34
star
7

gu-composited-card

A simple, framework agnostic web component to facilitate the display of Gods Unchained card element(s).
TypeScript
17
star
8

zkevm-boilerplate

Boilerplate Hardhat project for EVM smart contract development in Solidity
TypeScript
16
star
9

ts-immutable-sdk

Immutable Typescript SDK
TypeScript
10
star
10

unity-immutable-sdk

Unity SDK for Immutable's products.
HTML
10
star
11

imx-core-sdk-golang

The Immutable Core SDK Golang provides convenient access to the Immutable APIs and Ethereum contract methods for applications integrating with ImmutableX platform.
Go
9
star
12

imx-unity-sdk

C#
7
star
13

imx-docs

API reference, Tutorials and How-to Guides for Immutable X offering zero gas fees, instant trades, and carbon neutral NFTs for marketplaces, games, and applications without compromise. Build your NFT business in hours with our APIs.
HTML
6
star
14

imx-core-sdk-csharp

The Immutable Core SDK C# provides convenient access to the Immutable APIs and Ethereum contract methods for applications integrating with Immutable
C#
6
star
15

generate-stark-key

This tool generates the deterministic stark key for a given private key.
JavaScript
5
star
16

imxscripts

TypeScript
5
star
17

unreal-immutable-sdk

Immutable Unreal SDK
C++
4
star
18

imx-core-sdk-kotlin-jvm

Kotlin
4
star
19

imx-core-sdk-swift

The ImmutableX Core SDK Swift provides convenient access to the Immutable API's for applications written on the ImmutableX platform.
Swift
4
star
20

sample-project-metadata

Sample NFT metadata project for public forking.
4
star
21

zkevm-bridge-contracts

Smart contracts for the Immutable zkEVM native bridge
Solidity
3
star
22

immutable-seaport

Immutable Seaport extends Seaport and implements a SIP7 compatible zone contract for royalty enforcement
TypeScript
2
star
23

StarkNetCourseContent

Python
2
star
24

sample-unity-game

C#
2
star
25

wallet-contracts

TypeScript
2
star
26

basic-preset-minting

TypeScript
2
star
27

databasediff

Simple Go program to compare row counts of tables across two databases
Go
1
star
28

imx-wallet-sdk-ios

Ruby
1
star