New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@imtbl/core-sdk

Package Overview
Dependencies
Maintainers
12
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@imtbl/core-sdk - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

dist/src/contracts/contracts/Registration.d.ts

3

dist/src/contracts/contracts/index.d.ts
export type { Core } from "./Core";
export type { ERC20 } from "./ERC20";
export type { ERC721 } from "./ERC721";
export type { Registration } from "./Registration";
export { Core__factory } from "./Core__factory";
export { ERC20__factory } from "./ERC20__factory";
export { ERC721__factory } from "./ERC721__factory";
export { Registration__factory } from "./Registration__factory";

@@ -14,5 +14,3 @@ import type * as openzeppelin from "./@openzeppelin";

export { Core__factory } from "./factories/contracts/Core__factory";
export type { ERC20 } from "./contracts/ERC20";
export { ERC20__factory } from "./factories/contracts/ERC20__factory";
export type { ERC721 } from "./contracts/ERC721";
export { ERC721__factory } from "./factories/contracts/ERC721__factory";
export type { Registration } from "./contracts/Registration";
export { Registration__factory } from "./factories/contracts/Registration__factory";

@@ -1,6 +0,2 @@

export declare enum TokenType {
ETH = "ETH",
ERC20 = "ERC20",
ERC721 = "ERC721"
}
import { TokenType } from './token';
export interface ETHDeposit {

@@ -7,0 +3,0 @@ type: TokenType.ETH;

@@ -12,2 +12,3 @@ import { ec } from 'elliptic';

starkContractAddress: string;
registrationContractAddress: string;
}

@@ -19,1 +20,4 @@ export declare type UnsignedMintRequest = Omit<MintRequest, 'auth_signature'>;

export * from './deposit';
export * from './withdrawal';
export * from './token';
export * from './signable-withdrawal';
import { Signer } from '@ethersproject/abstract-signer';
import { TransfersApi, CreateTransferResponseV1, TransfersApiGetTransferRequest } from '../api';
import { GetSignableBurnRequest } from './types';
export declare function burnWorkflow(signer: Signer, request: GetSignableBurnRequest, transfersApi: TransfersApi): Promise<CreateTransferResponseV1>;
import { StarkWallet } from '../types';
export declare function burnWorkflow(signer: Signer, starkWallet: StarkWallet, request: GetSignableBurnRequest, transfersApi: TransfersApi): Promise<CreateTransferResponseV1>;
export declare function getBurnWorkflow(request: TransfersApiGetTransferRequest, transfersApi: TransfersApi): Promise<import("axios").AxiosResponse<import("../api").Transfer, any>>;
import { Signer } from '@ethersproject/abstract-signer';
import { TransactionResponse } from '@ethersproject/providers';
import { DepositsApi, EncodingApi, TokensApi, UsersApi } from '../../api';
import { Core } from '../../contracts';
import { Config, ERC20Deposit } from '../../types';
export declare function depositERC20Workflow(signer: Signer, deposit: ERC20Deposit, depositsApi: DepositsApi, usersApi: UsersApi, tokensApi: TokensApi, encodingApi: EncodingApi, contract: Core, config: Config): Promise<string>;
export declare function depositERC20Workflow(signer: Signer, deposit: ERC20Deposit, depositsApi: DepositsApi, usersApi: UsersApi, tokensApi: TokensApi, encodingApi: EncodingApi, config: Config): Promise<TransactionResponse>;
import { Signer } from '@ethersproject/abstract-signer';
import { TransactionResponse } from '@ethersproject/providers';
import { DepositsApi, EncodingApi, UsersApi } from '../../api';
import { Core } from '../../contracts';
import { Config, ERC721Deposit } from '../../types';
export declare function depositERC721Workflow(signer: Signer, deposit: ERC721Deposit, depositsApi: DepositsApi, usersApi: UsersApi, encodingApi: EncodingApi, contract: Core, config: Config): Promise<string>;
export declare function depositERC721Workflow(signer: Signer, deposit: ERC721Deposit, depositsApi: DepositsApi, usersApi: UsersApi, encodingApi: EncodingApi, config: Config): Promise<TransactionResponse>;
import { Signer } from '@ethersproject/abstract-signer';
import { TransactionResponse } from '@ethersproject/providers';
import { DepositsApi, EncodingApi, UsersApi } from '../../api';
import { Core } from '../../contracts';
import { ETHDeposit } from '../../types';
export declare function depositEthWorkflow(signer: Signer, deposit: ETHDeposit, depositsApi: DepositsApi, usersApi: UsersApi, encodingApi: EncodingApi, contract: Core): Promise<string>;
import { Config, ETHDeposit } from '../../types';
export declare function depositEthWorkflow(signer: Signer, deposit: ETHDeposit, depositsApi: DepositsApi, usersApi: UsersApi, encodingApi: EncodingApi, config: Config): Promise<TransactionResponse>;
import { Signer } from '@ethersproject/abstract-signer';
import { GetSignableRegistrationResponse, RegisterUserResponse, UsersApi } from '../api';
import { Core } from '../contracts';
export declare function registerOffchainWorkflow(signer: Signer, usersApi: UsersApi): Promise<RegisterUserResponse>;
export declare function isRegisteredOnChainWorkflow(signer: Signer, contract: Core): Promise<boolean>;
import { Registration } from '../contracts';
import { StarkWallet } from '../types';
export declare function registerOffchainWorkflow(signer: Signer, starkWallet: StarkWallet, usersApi: UsersApi): Promise<RegisterUserResponse>;
export declare function isRegisteredOnChainWorkflow(starkPublicKey: string, contract: Registration): Promise<boolean>;
export declare function getSignableRegistrationOnchain(etherKey: string, starkPublicKey: string, usersApi: UsersApi): Promise<GetSignableRegistrationResponse>;
import { Signer } from '@ethersproject/abstract-signer';
import { TransfersApi, GetSignableTransferRequestV1, CreateTransferResponseV1, GetSignableTransferRequest, CreateTransferResponse } from '../api';
export declare function transfersWorkflow(signer: Signer, request: GetSignableTransferRequestV1, transfersApi: TransfersApi): Promise<CreateTransferResponseV1>;
export declare function batchTransfersWorkflow(signer: Signer, request: GetSignableTransferRequest, transfersApi: TransfersApi): Promise<CreateTransferResponse>;
import { StarkWallet } from '../types';
export declare function transfersWorkflow(signer: Signer, starkWallet: StarkWallet, request: GetSignableTransferRequestV1, transfersApi: TransfersApi): Promise<CreateTransferResponseV1>;
export declare function batchTransfersWorkflow(signer: Signer, starkWallet: StarkWallet, request: GetSignableTransferRequest, transfersApi: TransfersApi): Promise<CreateTransferResponse>;

@@ -1,24 +0,35 @@

import { TransfersApiGetTransferRequest } from '../api';
import { TransfersApiGetTransferRequest, GetSignableCancelOrderRequest } from '../api';
import { Signer } from '@ethersproject/abstract-signer';
import { UnsignedMintRequest, UnsignedTransferRequest, UnsignedBatchNftTransferRequest, ERC20Deposit, ERC721Deposit, ETHDeposit, TokenDeposit, UnsignedBurnRequest, Config } from '../types';
import { UnsignedMintRequest, UnsignedTransferRequest, UnsignedBatchNftTransferRequest, ERC20Deposit, ERC721Deposit, ETHDeposit, TokenDeposit, UnsignedBurnRequest, TokenPrepareWithdrawal, Config, ERC721Withdrawal, ERC20Withdrawal, TokenWithdrawal, StarkWallet } from '../types';
export declare class Workflows {
protected config: Config;
private readonly usersApi;
private readonly depositsApi;
private readonly encodingApi;
private readonly mintsApi;
private readonly ordersApi;
private readonly tokensApi;
private readonly transfersApi;
private readonly depositsApi;
private readonly tokensApi;
private readonly encodingApi;
private readonly usersApi;
private readonly withdrawalsApi;
constructor(config: Config);
registerOffchain(signer: Signer): Promise<import("../api").RegisterUserResponse>;
isRegisteredOnchain(signer: Signer): Promise<boolean>;
registerOffchain(signer: Signer, starkWallet: StarkWallet): Promise<import("../api").RegisterUserResponse>;
isRegisteredOnchain(signer: Signer, starkWallet: StarkWallet): Promise<boolean>;
mint(signer: Signer, request: UnsignedMintRequest): Promise<import("../api").MintTokensResponse>;
transfer(signer: Signer, request: UnsignedTransferRequest): Promise<import("../api").CreateTransferResponseV1>;
batchNftTransfer(signer: Signer, request: UnsignedBatchNftTransferRequest): Promise<import("../api").CreateTransferResponse>;
burn(signer: Signer, request: UnsignedBurnRequest): Promise<import("../api").CreateTransferResponseV1>;
deposit(signer: Signer, deposit: TokenDeposit): Promise<string>;
depositEth(signer: Signer, deposit: ETHDeposit): Promise<string>;
transfer(signer: Signer, starkWallet: StarkWallet, request: UnsignedTransferRequest): Promise<import("../api").CreateTransferResponseV1>;
batchNftTransfer(signer: Signer, starkWallet: StarkWallet, request: UnsignedBatchNftTransferRequest): Promise<import("../api").CreateTransferResponse>;
burn(signer: Signer, starkWallet: StarkWallet, request: UnsignedBurnRequest): Promise<import("../api").CreateTransferResponseV1>;
getBurn(request: TransfersApiGetTransferRequest): Promise<import("axios").AxiosResponse<import("../api").Transfer, any>>;
depositERC20(signer: Signer, deposit: ERC20Deposit): Promise<string>;
depositERC721(signer: Signer, deposit: ERC721Deposit): Promise<string>;
deposit(signer: Signer, deposit: TokenDeposit): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
depositEth(signer: Signer, deposit: ETHDeposit): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
depositERC20(signer: Signer, deposit: ERC20Deposit): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
depositERC721(signer: Signer, deposit: ERC721Deposit): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
prepareWithdrawal(signer: Signer, starkWallet: StarkWallet, token: TokenPrepareWithdrawal, quantity: string): Promise<import("../api").CreateWithdrawalResponse>;
completeEthWithdrawal(signer: Signer, starkPublicKey: string): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
completeERC20Withdrawal(signer: Signer, starkPublicKey: string, token: ERC20Withdrawal): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
completeERC721Withdrawal(signer: Signer, starkPublicKey: string, token: ERC721Withdrawal): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
completeWithdrawal(signer: Signer, starkPublicKey: string, token: TokenWithdrawal): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
cancelOrder(signer: Signer, starkWallet: StarkWallet, request: GetSignableCancelOrderRequest): Promise<{
order_id: number | undefined;
status: string | undefined;
}>;
}

@@ -1,21 +0,176 @@

MIT License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Copyright (c) 2022 Immutable
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
1. Definitions.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
{
"name": "@imtbl/core-sdk",
"version": "0.0.2",
"version": "0.1.0",
"description": "Immutable Core SDK",

@@ -12,3 +12,3 @@ "main": "dist/index.cjs.js",

"author": "Immutable",
"license": "MIT",
"license": "Apache-2.0",
"engines": {

@@ -19,4 +19,2 @@ "node": ">=14"

"generate-contract-bindings": "hardhat compile",
"test-contract-bindings": "node_modules/ts-node/dist/bin.js --transpile-only src/core.contract.ts",
"test-api-bindings": "node_modules/ts-node/dist/bin.js --transpile-only src/api-test.ts",
"build": "NODE_ENV=production rollup --config rollup.config.js",

@@ -23,0 +21,0 @@ "prebuild": "rm -rf dist",

@@ -0,1 +1,13 @@

<div align="center">
<br>
<br>
<a href="https://docs.x.immutable.com/docs">
<img src="images/imx-logo.png">
</a>
<br>
<br>
</div>
---
# Immutable Core SDK

@@ -7,5 +19,6 @@

- See the [developer guides](https://docs.x.immutable.com/docs) for information on building on Immutable X.
- See the [API reference documentation](https://docs.x.immutable.com/reference) for more information on our API's.
See the [developer guides](https://docs.x.immutable.com/docs) for information on building on Immutable X.
See the [API reference documentation](https://docs.x.immutable.com/reference) for more information on our API's.
## Installation

@@ -23,15 +36,239 @@

...
### Configuration
## API autogenerated code
A configuration object is required to be passed into Core SDK requests. This can be obtained by using the `getConfig` function available within the Core SDK. You are required to select the Ethereum network. The Immutable X platform currently supports `ropsten` for testing and `mainnet` for production.
...
```ts
import { AlchemyProvider } from '@ethersproject/providers';
import { getConfig } from '@imtbl/core-sdk';
## Smart contract autogeneration
const ethNetwork = 'ropsten'; // or mainnet;
### Libraries
// Use the helper function to get the config
const config = getConfig(ethNetwork);
- https://hardhat.org/guides/compile-contracts.html
- https://www.npmjs.com/package/@typechain/hardhat
// Setup a provider and signer
const privateKey = YOUR_PRIVATE_KEY;
const provider = new AlchemyProvider(ethNetwork, YOUR_ALCHEMY_API_KEY);
const signer = new Wallet(privateKey).connect(provider);
```
#### Stark Wallet
Some methods require a stark wallet as a parameter. The Core SDK expects you will generate your own stark wallet.
```ts
import { Wallet } from '@ethersproject/wallet';
import { generateStarkWallet } from '@imtbl/core-sdk';
// generate your own stark wallet
const generateWallets = async (provider: AlchemyProvider) => {
// L1 credentials
const wallet = Wallet.createRandom().connect(provider);
// L2 credentials
// Obtain stark key pair associated with this user
const starkWallet = await generateStarkWallet(wallet); // this is sdk helper function
return {
wallet,
starkWallet
};
};
```
### Standard API Requests
The Core SDK includes classes that interact with the Immutable X APIs.
```ts
// Standard API request example usage
import { getConfig, AssetsApi } from '@imtbl/core-sdk';
const getYourAsset = async (tokenAddress: string, tokenId: string) => {
const config = getConfig('ropsten');
const assetsApi = new AssetsApi(config.api);
const response = await assetsApi.getAsset({
tokenAddress,
tokenId,
});
return response;
};
```
View the [OpenAPI spec](openapi.json) for a full list of API requests available in the Core SDK.
### Authorised project owner requests
Some methods require authorisation by the project owner, which consists of a Unix epoch timestamp signed with your ETH key and included in the request header.
On project and collection methods that require authorisation, this signed timestamp string can typically be passed as the `iMXSignature` and `iMXTimestamp` parameters.
```ts
// Example method to generate authorisation headers
const getProjectOwnerAuthorisationHeaders = async (signer: Signer) => {
const timestamp = Math.floor(Date.now() / 1000).toString();
const signature = await signRaw(timestamp, signer);
return {
timestamp,
signature,
};
};
// Using generated authorisation headers
const createProject = async (
name: string,
company_name: string,
contact_email: string,
) => {
const api = new ProjectsApi(this.config.api);
const { timestamp, signature } = getProjectOwnerAuthorisationHeaders(signer);
return await api.createProject({
createProjectRequest: {
name,
company_name,
contact_email,
},
iMXSignature: signature,
iMXTimestamp: timestamp,
});
};
```
The following methods require project owner authorisation:
**Projects**
- createProject
- getProject
- getProjects
**Collections**
- createCollection
- updateCollection
**Metadata**
- addMetadataSchemaToCollection
- updateMetadataSchemaByName
### Contract Requests
Immutable X is built as a ZK-rollup in partnership with StarkWare. We chose the ZK-rollups because it is the only solution capable of scale without compromise. This means whenever you mint or trade an NFT on Immutable X, you pay zero gas, and the validity of all transactions are directly enforced by Ethereum’s security using zero-knowledge proofs -- the first “layer 2” for NFTs on Ethereum.
The Core SDK provides interfaces for all smart contracts required to interact with the Immutable X platform.
[See all smart contract available in the Core SDK](#smart-contract-autogeneration)
```ts
import { Core__factory } from '@imtbl/core-sdk';
// Get instance of core contract
const contract = Core__factory.connect(config.starkContractAddress, signer);
// Obtain necessary parameters...
// Populate and send transaction
const populatedTransaction = await contract.populateTransaction.depositNft(
starkPublicKey,
assetType,
vaultId,
tokenId,
);
const transactionResponse = await signer.sendTransaction(populatedTransaction);
```
### Workflows
A workflow is a combination of API and contract calls required for more complicated functionality.
```ts
// User registration workflow example
import { AlchemyProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { getConfig, Workflows } from '@imtbl/core-sdk';
const alchemyApiKey = YOUR_ALCHEMY_API_KEY;
const ethNetwork = 'ropsten';
// Setup provider and signer
const provider = new AlchemyProvider(ethNetwork, alchemyApiKey);
const signer = new Wallet(privateKey).connect(provider);
// Configure Core SDK Workflow class
const config = getConfig(ethNetwork);
const workflows = new Workflows(config);
const registerUser = async () => {
const response = await workflows.registerOffchain(signer);
console.log(response);
};
```
The workflow can be found in the [workflows directory](src/workflows/).
### Available Workflows
The current workflow methods exposed from the `Workflow` class.
| Workflow | Description |
| -------------------------- | ---------------------------------------------------------------------------- |
| `registerOffchain` | Register L2 wallet. |
| `isRegisteredOnchain` | Check wallet registered on L2. |
| `mint` | Mint tokens on L2. |
| `transfer` | Transfer tokens to another wallet. |
| `batchNftTransfer` | Batch transfer tokens. |
| `burn` | Burn tokens. |
| `getBurn` | Verify burn/transfer defails. |
| `deposit` | Helper method around the other deposit methods. Deposit based on token type. |
| `depositEth` | Deposit ETH to L2 wallet. |
| `depositERC20` | Depost ERC20 token to L2 wallet. |
| `depositERC721` | Depost ERC721 NFT to L2 wallet. |
| `prepareWithdrawal` | Prepare token for withdrawl. |
| `completeEthWithdrawal` | Withdraw ETH to L1. |
| `completeERC20Withdrawal` | Withdrawn ERC20 to L1. |
| `completeERC721Withdrawal` | Withdraw ERC721 to L1. |
| `completeWithdrawal` | Helper method around withdraw methods. Withdraw based on token type. |
## Autogenerated Code
Parts of the Core SDK are automagically generated.
### API Autogenerated Code
We use OpenAPI (formally known as Swagger) to auto-generate the API clients that connect to the public APIs.
The OpenAPI spec is retrieved from https://api.x.immutable.com/openapi and also saved in the repo.
### Smart contract autogeneration
The Immutable solidity contracts can be found under `contracts` folder. Contract bindings in typescript is generated using [hardhat](https://hardhat.org/guides/compile-contracts.html).
#### Core
The Core contract is Immutable's main interface with the Ethereum blockchain, based on [StarkEx](https://docs.starkware.co/starkex-v4).
[View contract](contracts/Core.sol)
#### Registration
The Registration contract is a proxy smart contract for the Core contract that combines transactions related to onchain registration, deposits and withdrawals. When a user who is not registered onchain attempts to perform a deposit or a withdrawal, the Registration combines requests to the Core contract in order to register the user first. - users who are not registered onchain are not able to perform a deposit or withdrawal.
Fore example, instead of making subsequent transaction requests to the Core contract, i.e. `registerUser` and `depositNft`, a single transaction request can be made to the proxy Registration contract - `registerAndWithdrawNft`.
[View contract](contracts/Registration.sol)
#### IERC20
Standard interface for interacting with ERC20 contracts, taken from [OpenZeppelin](https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#IERC20).
#### IERC721
Standard interface for interacting with ERC721 contracts, taken from [OpenZeppelin](https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#IERC721).
## Changelog Management

@@ -96,1 +333,23 @@

- Push to remote by using yes
## Getting Help
Immutable X is open to all to build on, with no approvals required. If you want to talk to us to learn more, or apply for developer grants, click below:
[Contact us](https://www.immutable.com/contact)
### Project Support
To get help from other developers, discuss ideas, and stay up-to-date on what's happening, become a part of our community on Discord.
[Join us on Discord](https://discord.gg/TkVumkJ9D6)
You can also join the conversation, connect with other projects, and ask questions in our Immutable X Discourse forum.
[Visit the forum](https://forum.immutable.com/)
#### Still need help?
You can also apply for marketing support for your project. Or, if you need help with an issue related to what you're building with Immutable X, click below to submit an issue. Select _I have a question_ or _issue related to building on Immutable X_ as your issue type.
[Contact support](https://support.immutable.com/hc/en-us/requests/new)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc