Skip to content

Commit 44835a6

Browse files
Deprecate contract clients; export Typescript ABIs for interacting with deployed preset contracts (#213)
* add deprecation notice * add typescript abis * export abis * add ImmutableERC1155 * update readme
1 parent 9295f9e commit 44835a6

14 files changed

+3227
-25
lines changed

.gas-snapshot

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
AllowlistERC721TransferApprovals:testBlockTransferForNoneOALAddr() (gas: 107740)
2+
AllowlistERC721TransferApprovals:testBlockTransferForNoneOALAddr() (gas: 108284)
3+
AllowlistERC721TransferApprovals:testBlockTransferForNoneOALWallet() (gas: 1188716)
4+
AllowlistERC721TransferApprovals:testBlockTransferForNoneOALWallet() (gas: 1189260)
5+
AllowlistERC721TransferApprovals:testBlockTransferFromNoneOALAddress() (gas: 108100)
6+
AllowlistERC721TransferApprovals:testBlockTransferFromNoneOALAddress() (gas: 108602)
7+
AllowlistERC721TransferApprovals:testDeployment() (gas: 10009)
8+
AllowlistERC721TransferApprovals:testDeployment() (gas: 9965)
9+
AllowlistERC721TransferApprovals:testDisguisedEOAApprovalTransfer() (gas: 278297)
10+
AllowlistERC721TransferApprovals:testDisguisedEOAApprovalTransfer() (gas: 278946)
11+
AllowlistERC721TransferApprovals:testOnReceiveTransferFrom() (gas: 258431)
12+
AllowlistERC721TransferApprovals:testOnReceiveTransferFrom() (gas: 258937)
13+
AllowlistERC721TransferApprovals:testShouldApproveAddrInOAL() (gas: 217133)
14+
AllowlistERC721TransferApprovals:testShouldApproveAddrInOAL() (gas: 218414)
15+
AllowlistERC721TransferApprovals:testShouldApproveEOA() (gas: 171898)
16+
AllowlistERC721TransferApprovals:testShouldApproveEOA() (gas: 173179)
17+
AllowlistERC721TransferApprovals:testShouldApproveWalletInOAL() (gas: 1325303)
18+
AllowlistERC721TransferApprovals:testShouldApproveWalletInOAL() (gas: 1326606)
19+
AllowlistERC721TransferApprovals:testShouldNotAllowApproveFromNoneOALContract() (gas: 107378)
20+
AllowlistERC721TransferApprovals:testShouldNotAllowApproveFromNoneOALContract() (gas: 107679)
21+
AllowlistERC721TransferApprovals:testShouldNotApproveNoneOALSCW() (gas: 1232905)
22+
AllowlistERC721TransferApprovals:testShouldNotApproveNoneOALSCW() (gas: 1233322)
23+
AllowlistERC721TransferApprovals:testTransferBetweenEOAs() (gas: 129660)
24+
AllowlistERC721TransferApprovals:testTransferBetweenEOAs() (gas: 130368)
25+
AllowlistERC721TransferApprovals:testTransferBetweenSCWInOAL() (gas: 2263192)
26+
AllowlistERC721TransferApprovals:testTransferBetweenSCWInOAL() (gas: 2263925)
27+
AllowlistERC721TransferApprovals:testTransferToAddrInOAL() (gas: 166790)
28+
AllowlistERC721TransferApprovals:testTransferToAddrInOAL() (gas: 167523)
29+
AllowlistERC721TransferApprovals:testTransferToWalletInOAL() (gas: 1273627)
30+
AllowlistERC721TransferApprovals:testTransferToWalletInOAL() (gas: 1274360)
31+
ChainlinkControlTests:testConfigureRequests() (gas: 29757)
32+
ChainlinkControlTests:testConfigureRequestsBadAuth() (gas: 40354)
33+
ChainlinkControlTests:testInit() (gas: 1504756)
34+
ChainlinkControlTests:testRoleAdmin() (gas: 92292)
35+
ChainlinkControlTests:testRoleAdminBadAuth() (gas: 44062)
36+
ChainlinkCoverageFakeTests:testFixMockCoordinatorCoverage() (gas: 467341)
37+
ChainlinkCoverageFakeTests:testInit() (gas: 1504919)
38+
ChainlinkCoverageFakeTests:testV2BaseChecksCoverage() (gas: 462646)
39+
ChainlinkInitTests:testInit() (gas: 1504788)
40+
ChainlinkIntegrationTests:testBadFulfilment() (gas: 29985)
41+
ChainlinkIntegrationTests:testEndToEnd() (gas: 586008)
42+
ChainlinkIntegrationTests:testHackFulfilment() (gas: 455339)
43+
ChainlinkIntegrationTests:testInit() (gas: 1504757)
44+
ChainlinkIntegrationTests:testRequestRandom() (gas: 57273)
45+
ChainlinkIntegrationTests:testRequestTooEarly() (gas: 25782)
46+
ChainlinkIntegrationTests:testTwoRequests() (gas: 85823)
47+
ChainlinkOperationalTests:testBadFulfilment() (gas: 29985)
48+
ChainlinkOperationalTests:testHackFulfilment() (gas: 455306)
49+
ChainlinkOperationalTests:testInit() (gas: 1504757)
50+
ChainlinkOperationalTests:testRequestRandom() (gas: 57192)
51+
ChainlinkOperationalTests:testRequestTooEarly() (gas: 25782)
52+
ChainlinkOperationalTests:testTwoRequests() (gas: 85823)
53+
ControlRandomSeedProviderTest:testAddOffchainRandomConsumer() (gas: 45704)
54+
ControlRandomSeedProviderTest:testAddOffchainRandomConsumerBadAuth() (gas: 53368)
55+
ControlRandomSeedProviderTest:testGetRandomSeedInitRandao() (gas: 48442)
56+
ControlRandomSeedProviderTest:testGetRandomSeedInitTraditional() (gas: 48473)
57+
ControlRandomSeedProviderTest:testGetRandomSeedNoOffchainSource() (gas: 16333)
58+
ControlRandomSeedProviderTest:testGetRandomSeedNotGenRandao() (gas: 51080)
59+
ControlRandomSeedProviderTest:testGetRandomSeedNotGenTraditional() (gas: 51134)
60+
ControlRandomSeedProviderTest:testInit() (gas: 2108843)
61+
ControlRandomSeedProviderTest:testNoDowngrade() (gas: 3244256)
62+
ControlRandomSeedProviderTest:testNoUpgrade() (gas: 18457)
63+
ControlRandomSeedProviderTest:testReinit() (gas: 22783)
64+
ControlRandomSeedProviderTest:testRemoveOffchainRandomConsumer() (gas: 35268)
65+
ControlRandomSeedProviderTest:testRemoveOffchainRandomConsumerBadAuth() (gas: 76371)
66+
ControlRandomSeedProviderTest:testRoleAdmin() (gas: 97806)
67+
ControlRandomSeedProviderTest:testRoleAdminBadAuth() (gas: 49175)
68+
ControlRandomSeedProviderTest:testSetOffchainRandomSource() (gas: 26989)
69+
ControlRandomSeedProviderTest:testSetOffchainRandomSourceBadAuth() (gas: 45324)
70+
ControlRandomSeedProviderTest:testSetRanDaoAvailable() (gas: 27553)
71+
ControlRandomSeedProviderTest:testSetRanDaoAvailableBadAuth() (gas: 49941)
72+
ControlRandomSeedProviderTest:testUpgrade() (gas: 1649333)
73+
ControlRandomSeedProviderTest:testUpgradeBadAuth() (gas: 1641725)
74+
ControlRandomSeedProviderTest:testV2NoDowngrade() (gas: 1623397)
75+
ImmutableERC1155Costs:test_Mint100To1() (gas: 62009)
76+
ImmutableERC1155Costs:test_Mint10To5() (gas: 61922)
77+
ImmutableERC1155Costs:test_Mint1To5() (gas: 61944)
78+
ImmutableERC1155Costs:test_Mint5To5() (gas: 61899)
79+
ImmutableERC1155Test:test_AdminRoleCanSetBaseURI() (gas: 27117)
80+
ImmutableERC1155Test:test_AdminRoleCanSetContractURI() (gas: 21743)
81+
ImmutableERC1155Test:test_ApprovedOperatorBatchTransferFrom() (gas: 215975)
82+
ImmutableERC1155Test:test_ApprovedOperatorTransferFrom() (gas: 154849)
83+
ImmutableERC1155Test:test_ApprovedSCWOperatorBatchTransferFromToApprovedReceiver() (gas: 263256)
84+
ImmutableERC1155Test:test_ApprovedSCWOperatorTransferFrom() (gas: 194435)
85+
ImmutableERC1155Test:test_ApprovedSCWOperatorTransferFromToApprovedReceiver() (gas: 197709)
86+
ImmutableERC1155Test:test_ApprovedSCWOperatorTransferFromToUnApprovedReceiver() (gas: 195278)
87+
ImmutableERC1155Test:test_BatchBurn() (gas: 133999)
88+
ImmutableERC1155Test:test_Burn() (gas: 54997)
89+
ImmutableERC1155Test:test_DeploymentAllowlistShouldGiveAdminToOwner() (gas: 16303)
90+
ImmutableERC1155Test:test_DeploymentShouldSetAdminRoleToOwner() (gas: 10872)
91+
ImmutableERC1155Test:test_DeploymentShouldSetAllowlistToProxy() (gas: 9855)
92+
ImmutableERC1155Test:test_DeploymentShouldSetBaseURI() (gas: 9693)
93+
ImmutableERC1155Test:test_DeploymentShouldSetContractURI() (gas: 9663)
94+
ImmutableERC1155Test:test_MinterRoleCanBatchMint() (gas: 161400)
95+
ImmutableERC1155Test:test_MinterRoleCanMint() (gas: 63382)
96+
ImmutableERC1155Test:test_PermitRevertsWhenDeadlineExceeded() (gas: 25751)
97+
ImmutableERC1155Test:test_PermitRevertsWhenInvalidNonce() (gas: 56265)
98+
ImmutableERC1155Test:test_PermitRevertsWhenInvalidSigner() (gas: 56222)
99+
ImmutableERC1155Test:test_PermitSuccess() (gas: 82929)
100+
ImmutableERC1155Test:test_RevertIfNonAdminAttemptsToSetBaseURI() (gas: 43856)
101+
ImmutableERC1155Test:test_RevertIfNonAdminAttemptsToSetContractURI() (gas: 43843)
102+
ImmutableERC1155Test:test_UnapprovedSCWOperatorTransferFrom() (gas: 89255)
103+
ImmutableERC1155Test:test_giveMinterRole() (gas: 24714)
104+
ImmutableERC20FixedSupplyNoBurnTest:testChangeOwner() (gas: 19980)
105+
ImmutableERC20FixedSupplyNoBurnTest:testInit() (gas: 38921)
106+
ImmutableERC20FixedSupplyNoBurnTest:testRenounceOwnerBlocked() (gas: 11134)
107+
ImmutableERC20Test:testBurn() (gas: 49360)
108+
ImmutableERC20Test:testCanOnlyMintUpToMaxSupply() (gas: 67222)
109+
ImmutableERC20Test:testChangeOwner() (gas: 20209)
110+
ImmutableERC20Test:testInit() (gas: 38556)
111+
ImmutableERC20Test:testMint() (gas: 62348)
112+
ImmutableERC20Test:testOnlyMinterCanMint() (gas: 44635)
113+
ImmutableERC20Test:testRenounceOwnerBlocked() (gas: 11332)
114+
OperationalRandomSeedProviderTest:testGetRandomSeedInitRandao() (gas: 48462)
115+
OperationalRandomSeedProviderTest:testGetRandomSeedInitTraditional() (gas: 48526)
116+
OperationalRandomSeedProviderTest:testGetRandomSeedNoOffchainSource() (gas: 16323)
117+
OperationalRandomSeedProviderTest:testGetRandomSeedNotGenRandao() (gas: 51147)
118+
OperationalRandomSeedProviderTest:testGetRandomSeedNotGenTraditional() (gas: 51212)
119+
OperationalRandomSeedProviderTest:testInit() (gas: 2108881)
120+
OperationalRandomSeedProviderTest:testOffchainNextBlock() (gas: 138600)
121+
OperationalRandomSeedProviderTest:testOffchainNotReady() (gas: 112897)
122+
OperationalRandomSeedProviderTest:testOffchainTwoInOneBlock() (gas: 110631)
123+
OperationalRandomSeedProviderTest:testRanDaoDelayedFulfilment() (gas: 134110)
124+
OperationalRandomSeedProviderTest:testRanDaoNextBlock() (gas: 81550)
125+
OperationalRandomSeedProviderTest:testRanDaoTwoInOneBlock() (gas: 51746)
126+
OperationalRandomSeedProviderTest:testReinit() (gas: 22728)
127+
OperationalRandomSeedProviderTest:testTradDelayedFulfilment() (gas: 134448)
128+
OperationalRandomSeedProviderTest:testTradNextBlock() (gas: 80391)
129+
OperationalRandomSeedProviderTest:testTradTwoInOneBlock() (gas: 51786)
130+
OperatorAllowlistTest:testDeployment() (gas: 39610)
131+
OperatorAllowlistTest:testFailedUpgradeNoPerms() (gas: 1554749)
132+
OperatorAllowlistTest:testShouldAddAndRemoveAnAddressOfAMarketPlaceAndRemoveItFromAllowlist() (gas: 41761)
133+
OperatorAllowlistTest:testShouldAddAndRemoveSmartContractWalletBytecodeFromAllowlist() (gas: 1155323)
134+
OperatorAllowlistTest:testShouldLimitAllowlistAddAndRemoveFunctionality() (gas: 163547)
135+
OperatorAllowlistTest:testShouldNotAllowlistSCWWithSameBytecodeButDifferentImplementationAddress() (gas: 2112028)
136+
OperatorAllowlistTest:testShouldSupportIOperatorAllowlistInterface() (gas: 10631)
137+
OperatorAllowlistTest:testUpgradeToV2() (gas: 1582052)
138+
PaymentSplitterTest:testAddErc20() (gas: 1188176)
139+
PaymentSplitterTest:testCalculateReleasableAmount() (gas: 203086)
140+
PaymentSplitterTest:testDeployRoles() (gas: 22859)
141+
PaymentSplitterTest:testGrantReleaseFundsRole() (gas: 93633)
142+
PaymentSplitterTest:testInvalidPermissions() (gas: 174248)
143+
PaymentSplitterTest:testPayeeAdded() (gas: 20067)
144+
PaymentSplitterTest:testReceiveNativeTokenEvent() (gas: 18262)
145+
PaymentSplitterTest:testReleaseERC20sOverridePayees() (gas: 439241)
146+
PaymentSplitterTest:testReleaseERC20sSimple() (gas: 291122)
147+
PaymentSplitterTest:testReleaseNativeFundsOverridePayees() (gas: 275290)
148+
PaymentSplitterTest:testReleaseNativeTokenFundsSimple() (gas: 147191)
149+
PaymentSplitterTest:testSharesAdded() (gas: 24243)
150+
PaymentSplitterTest:testTokensAdded() (gas: 22613)
151+
RegistrationV4Test:testCompleteWithdrawalAll_WhenUserIsRegistered() (gas: 111955)
152+
RegistrationV4Test:testCompleteWithdrawalAll_WhenUserIsRegisteredAndHasEthKeyBalanceOnly() (gas: 93416)
153+
RegistrationV4Test:testCompleteWithdrawalAll_WhenUserIsRegisteredAndHasStarkKeyBalanceOnly() (gas: 91345)
154+
RegistrationV4Test:testCompleteWithdrawalV4_WhenUserIsNotRegistered() (gas: 87145)
155+
RegistrationV4Test:testGetVersion() (gas: 10650)
156+
RegistrationV4Test:testRegisterAndCompleteWithdrawalAll_WhenUserIsNotRegistered() (gas: 114413)
157+
RegistrationV4Test:testRegisterAndCompleteWithdrawalAll_WhenUserIsRegistered() (gas: 115075)
158+
RegistrationV4Test:testRegisterAndWithdrawalNFT_WhenUserIsNotRegistered() (gas: 1733099)
159+
RegistrationV4Test:testRegisterAndWithdrawalNFT_WhenUserIsRegistered() (gas: 1733990)
160+
RegistrationV4Test:testRegisterWithdrawalAndMintNFT_WhenUserIsNotRegistered() (gas: 1723044)
161+
RegistrationV4Test:testRegister_WhenUserIsNotRegistered() (gas: 44713)
162+
RegistrationV4Test:testShouldFailWithdrawalAll_WhenUserDoesNotHaveFundsToWithdraw() (gas: 52900)
163+
RegistrationV4Test:testShouldFailWithdrawalAll_WhenUserIsNotRegistered() (gas: 93525)
164+
SingleGameRandomValuesTest:testFirstValue() (gas: 121607)
165+
SingleGameRandomValuesTest:testFirstValues() (gas: 116110)
166+
SingleGameRandomValuesTest:testInit() (gas: 13182)
167+
SingleGameRandomValuesTest:testMultiFetch() (gas: 118704)
168+
SingleGameRandomValuesTest:testMultipleGames() (gas: 567246)
169+
SingleGameRandomValuesTest:testNoValues() (gas: 8848)
170+
SingleGameRandomValuesTest:testSecondValue() (gas: 188944)
171+
SingleGameRandomValuesTest:testSecondValues() (gas: 159172)
172+
SupraControlTests:testInit() (gas: 1383940)
173+
SupraControlTests:testRoleAdmin() (gas: 92386)
174+
SupraControlTests:testRoleAdminBadAuth() (gas: 44170)
175+
SupraControlTests:testSetSubscription() (gas: 21583)
176+
SupraControlTests:testSetSubscriptionBadAuth() (gas: 40305)
177+
SupraCoverageFakeTests:testFixMockCoordinatorCoverage() (gas: 411486)
178+
SupraCoverageFakeTests:testInit() (gas: 1383863)
179+
SupraInitTests:testInit() (gas: 1383951)
180+
SupraIntegrationTests:testBadFulfilment() (gas: 27869)
181+
SupraIntegrationTests:testEndToEnd() (gas: 583888)
182+
SupraIntegrationTests:testHackFulfilment() (gas: 423998)
183+
SupraIntegrationTests:testInit() (gas: 1383955)
184+
SupraIntegrationTests:testRequestRandom() (gas: 55131)
185+
SupraIntegrationTests:testRequestTooEarly() (gas: 23855)
186+
SupraIntegrationTests:testTwoRequests() (gas: 83473)
187+
SupraOperationalTests:testBadFulfilment() (gas: 27869)
188+
SupraOperationalTests:testHackFulfilment() (gas: 423931)
189+
SupraOperationalTests:testInit() (gas: 1383955)
190+
SupraOperationalTests:testRequestRandom() (gas: 55072)
191+
SupraOperationalTests:testRequestTooEarly() (gas: 23877)
192+
SupraOperationalTests:testTwoRequests() (gas: 83495)
193+
SwitchingRandomSeedProviderTest:testGetRandomSeedInitRandao() (gas: 48462)
194+
SwitchingRandomSeedProviderTest:testGetRandomSeedInitTraditional() (gas: 48526)
195+
SwitchingRandomSeedProviderTest:testGetRandomSeedNoOffchainSource() (gas: 16323)
196+
SwitchingRandomSeedProviderTest:testGetRandomSeedNotGenRandao() (gas: 51147)
197+
SwitchingRandomSeedProviderTest:testGetRandomSeedNotGenTraditional() (gas: 51168)
198+
SwitchingRandomSeedProviderTest:testInit() (gas: 2108881)
199+
SwitchingRandomSeedProviderTest:testReinit() (gas: 22728)
200+
SwitchingRandomSeedProviderTest:testSwitchOffchainOffchain() (gas: 174831)
201+
SwitchingRandomSeedProviderTest:testSwitchOffchainOnchain() (gas: 197469)
202+
SwitchingRandomSeedProviderTest:testSwitchRanDaoOffchain() (gas: 198644)
203+
SwitchingRandomSeedProviderTest:testSwitchTraditionalOffchain() (gas: 198836)
204+
UninitializedRandomSeedProviderTest:testGetRandomSeedInitRandao() (gas: 48398)
205+
UninitializedRandomSeedProviderTest:testGetRandomSeedInitTraditional() (gas: 48451)
206+
UninitializedRandomSeedProviderTest:testGetRandomSeedNoOffchainSource() (gas: 16256)
207+
UninitializedRandomSeedProviderTest:testGetRandomSeedNotGenRandao() (gas: 51025)
208+
UninitializedRandomSeedProviderTest:testGetRandomSeedNotGenTraditional() (gas: 51079)
209+
UninitializedRandomSeedProviderTest:testInit() (gas: 2108733)
210+
UninitializedRandomSeedProviderTest:testReinit() (gas: 22706)
211+
UninitializedRandomValuesTest:testInit() (gas: 13136)

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/clients @immutable/assets
2+
/abi @immutable/assets
23

34
/contracts/allowlist @immutable/assets
45
/contracts/token @immutable/assets

README.md

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Immutable Contracts is a library of smart contracts targeted at developers who w
66

77
- Token presets, e.g. ERC721
88

9-
- [ImmutableERC721](./contracts/token/erc721/preset/ImmutableERC721.sol)
10-
- [ImmutableERC721MintByID](./contracts/token/erc721/preset/ImmutableERC721MintByID.sol)
11-
- [ImmutableERC1155](./contracts/token/erc1155/preset/ImmutableERC1155.sol)
12-
- [ImmutableERC20MinterBurnerPermit](./contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol)
13-
- [ImmutableERC20FixedSupplyNoBurn](./contracts/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.sol)
9+
- [ImmutableERC721](./contracts/token/erc721/preset/ImmutableERC721.sol)
10+
- [ImmutableERC721MintByID](./contracts/token/erc721/preset/ImmutableERC721MintByID.sol)
11+
- [ImmutableERC1155](./contracts/token/erc1155/preset/ImmutableERC1155.sol)
12+
- [ImmutableERC20MinterBurnerPermit](./contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol)
13+
- [ImmutableERC20FixedSupplyNoBurn](./contracts/token/erc20/preset/ImmutableERC20FixedSupplyNoBurn.sol)
1414

1515
- Bridging contracts
1616

@@ -65,24 +65,55 @@ contract MyERC721 is ImmutableERC721 {
6565
}
6666
```
6767

68-
#### SDK client
68+
#### Typescript ABIs
6969

70-
`contracts` comes with a Typescript SDK client that can be used to interface with Immutable preset contracts:
70+
`contracts` comes with importable Typescript ABIs that can be used to generate a contract client in conjunction with libraries such as `viem` or `wagmi`, so that you can
71+
interact with deployed preset contracts.
7172

72-
- ImmutableERC721
73-
- ImmutableERC721MintByID
73+
The following Typescript ABIs are available:
7474

75-
To import and use the ImmutableERC721 contract client:
75+
- `ImmutableERC721Abi`
76+
- `ImmutableERC721MintByIdAbi`
77+
- `ImmutableERC1155Abi`
7678

77-
```typescript
78-
import { ERC721Client } from "@imtbl/contracts";
79-
80-
const contractAddress = YOUR_CONTRACT_ADDRESS;
79+
An example of how to create and use a contract client in order to interact with a deployed `ImmutableERC721`:
8180

82-
const client = new ERC721Client(contractAddress);
83-
84-
const mintTransaction = await client.populateMint(receiver, 1);
85-
const tx = await signer.sendTransaction(mintTransaction);
81+
```typescript
82+
import { getContract, http, createWalletClient, defineChain } from "viem";
83+
import { privateKeyToAccount } from "viem/accounts";
84+
import { ImmutableERC721MintByIdAbi } from "@imtbl/contracts";
85+
86+
const PRIVATE_KEY = "YOUR_PRIVATE_KEY"; // should be read from environment variable
87+
const CONTRACT_ADDRESS = "YOUR_CONTRACT_ADDRESS"; // should be of type `0x${string}`
88+
const RECIPIENT = "ACCOUNT_ADDRESS"; // should be of type `0x${string}`
89+
const TOKEN_ID = BigInt(1);
90+
91+
const immutableTestnet = defineChain({
92+
id: 13473,
93+
name: "imtbl-zkevm-testnet",
94+
nativeCurrency: { name: "IMX", symbol: "IMX", decimals: 18 },
95+
rpcUrls: {
96+
default: {
97+
http: ["https://rpc.testnet.immutable.com"],
98+
},
99+
},
100+
});
101+
102+
const walletClient = createWalletClient({
103+
chain: immutableTestnet,
104+
transport: http(),
105+
account: privateKeyToAccount(`0x${PRIVATE_KEY}`),
106+
});
107+
108+
// Bound contract instance
109+
const contract = getContract({
110+
address: CONTRACT_ADDRESS,
111+
abi: ImmutableERC721MintByIdAbi,
112+
client: walletClient,
113+
});
114+
115+
const txHash = await contract.write.mint([recipient, tokenId]);
116+
console.log(`txHash: ${txHash}`);
86117
```
87118

88119
## Build and Test

abi/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Typescript ABIs
2+
3+
The `contracts` repo exports Typescript ABIs for customers to generate their own contract clients using modern libraries such as `abitype`, `viem` and `wagmi`, for interacting with deployed preset contracts.
4+
5+
## Adding a new Typescript ABI
6+
7+
Typescript ABIs are generated using `@wagmi/cli` and `foundry` build files:
8+
9+
- `@wagmi/cli` configuration can be found in file `wagmi.config.ts`
10+
- `foundry` build files are available in this repo once built at folder `foundry-out`
11+
12+
To add a new Typescript ABI:
13+
14+
- Ensure the JSON ABI is available in folder `foundry-out`
15+
- Update the configuration in `wagmi.config.ts` to add the ABI to the `contracts` array
16+
- Run command `yarn wagmi generate` from the root of the folder
17+
- Ensure the new Typescript ABI is available in `abi/generated.ts`
18+
- Update `abi/index.ts` to rename and export Typescript ABI
19+
20+
The next published version will contain the new Typescript ABI.

0 commit comments

Comments
 (0)