@rareprotocol/rare-cli 0.2.2 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -1
- package/dist/client.d.ts +2224 -0
- package/dist/client.js +3439 -0
- package/dist/index.js +1554 -572
- package/package.json +18 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RARE Protocol CLI
|
|
2
2
|
|
|
3
|
-
Command-line tool for the [RARE Protocol](https://superrare.com) on Ethereum. Deploy NFT contracts, mint tokens, run auctions, and search the network — all from your terminal.
|
|
3
|
+
Command-line tool for the [RARE Protocol](https://superrare.com) on Ethereum. Deploy NFT contracts, mint tokens, run auctions, create offers and listings, and search the network — all from your terminal.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -149,6 +149,56 @@ rare auction cancel --contract 0x... --token-id 1
|
|
|
149
149
|
rare auction status --contract 0x... --token-id 1
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
+
### Offers
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Create an offer on a token
|
|
156
|
+
rare offer create --contract 0x... --token-id 1 --amount 0.5
|
|
157
|
+
|
|
158
|
+
# Create an offer with ERC20 currency
|
|
159
|
+
rare offer create --contract 0x... --token-id 1 --amount 100 --currency usdc
|
|
160
|
+
|
|
161
|
+
# Accept an offer on a token you own
|
|
162
|
+
rare offer accept --contract 0x... --token-id 1 --amount 0.5
|
|
163
|
+
|
|
164
|
+
# Cancel your offer
|
|
165
|
+
rare offer cancel --contract 0x... --token-id 1
|
|
166
|
+
|
|
167
|
+
# Check offer status (read-only)
|
|
168
|
+
rare offer status --contract 0x... --token-id 1
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Listings
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# List a token for sale at a fixed price
|
|
175
|
+
rare listing create --contract 0x... --token-id 1 --price 1.0
|
|
176
|
+
|
|
177
|
+
# List with ERC20 currency or a targeted buyer
|
|
178
|
+
rare listing create --contract 0x... --token-id 1 --price 100 --currency rare --target 0x...buyer
|
|
179
|
+
|
|
180
|
+
# Buy a listed token
|
|
181
|
+
rare listing buy --contract 0x... --token-id 1 --amount 1.0
|
|
182
|
+
|
|
183
|
+
# Cancel a listing
|
|
184
|
+
rare listing cancel --contract 0x... --token-id 1
|
|
185
|
+
|
|
186
|
+
# Check listing status (read-only)
|
|
187
|
+
rare listing status --contract 0x... --token-id 1
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Currencies
|
|
191
|
+
|
|
192
|
+
All marketplace commands (`auction`, `offer`, `listing`) accept `--currency` to specify a payment token. Named currencies (`eth`, `usdc`, `rare`) are resolved per-chain automatically. You can also pass any ERC20 address directly.
|
|
193
|
+
|
|
194
|
+
ERC20 allowances are auto-approved when needed for bids, offers, and purchases.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# List supported currencies and their addresses
|
|
198
|
+
rare currencies
|
|
199
|
+
rare currencies --chain mainnet
|
|
200
|
+
```
|
|
201
|
+
|
|
152
202
|
### Search
|
|
153
203
|
|
|
154
204
|
```bash
|
|
@@ -191,6 +241,82 @@ rare status --contract 0x...
|
|
|
191
241
|
rare status --contract 0x... --token-id 1
|
|
192
242
|
```
|
|
193
243
|
|
|
244
|
+
## SDK Client Usage
|
|
245
|
+
|
|
246
|
+
Use the client export when integrating RARE flows directly in your app code.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
npm install @rareprotocol/rare-cli viem
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Create a client
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
import { createPublicClient, createWalletClient, http } from 'viem';
|
|
256
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
257
|
+
import { sepolia } from 'viem/chains';
|
|
258
|
+
import { createRareClient } from '@rareprotocol/rare-cli/client';
|
|
259
|
+
|
|
260
|
+
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
|
261
|
+
const publicClient = createPublicClient({
|
|
262
|
+
chain: sepolia,
|
|
263
|
+
transport: http(process.env.RPC_URL),
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const walletClient = createWalletClient({
|
|
267
|
+
account,
|
|
268
|
+
chain: sepolia,
|
|
269
|
+
transport: http(process.env.RPC_URL),
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const rare = createRareClient({ publicClient, walletClient });
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Search
|
|
276
|
+
|
|
277
|
+
`search.nfts` auto-applies the client chain unless you pass `chainIds`.
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
const nfts = await rare.search.nfts({ query: 'portrait', take: 10 });
|
|
281
|
+
const collections = await rare.search.collections({ ownerAddresses: [account.address] });
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Upload media and mint
|
|
285
|
+
|
|
286
|
+
`media.upload` accepts a `Uint8Array` (Node `Buffer` works directly).
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
import { readFile } from 'node:fs/promises';
|
|
290
|
+
|
|
291
|
+
const imageBytes = await readFile('./art.png');
|
|
292
|
+
const image = await rare.media.upload(imageBytes, 'art.png');
|
|
293
|
+
|
|
294
|
+
const tokenUri = await rare.media.pinMetadata({
|
|
295
|
+
name: 'My NFT',
|
|
296
|
+
description: 'Minted with the SDK client',
|
|
297
|
+
image,
|
|
298
|
+
tags: ['art'],
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const minted = await rare.mint.mintTo({
|
|
302
|
+
contract: '0xYourContractAddress',
|
|
303
|
+
tokenUri,
|
|
304
|
+
to: '0xRecipientAddress',
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
console.log(minted.tokenId);
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Import an ERC-721 collection
|
|
311
|
+
|
|
312
|
+
`import.erc721` derives `chainId` from the client. If `owner` is omitted, it defaults to the configured account.
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
await rare.import.erc721({
|
|
316
|
+
contract: '0xYourContractAddress',
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
194
320
|
## Configuration
|
|
195
321
|
|
|
196
322
|
Config is stored at `~/.rare/config.json`. Each chain has its own private key and RPC URL.
|