Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dkackman committed Aug 4, 2022
1 parent 2a4d5de commit 3865c0c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,15 @@ Some of these configure the connection and REPL options, while other enable inte
These global objects are available within the REPL environment
bls BLS signature functions
chia Chia node rpc services. This object is only availble after a successful .connect
All functions on these chia services are async & awaitable: crawler, daemon, farmer, full_node, harvester, wallet
All functions on these chia services are async & awaitable: crawler, daemon, farmer, full_node, harvester, wallet, simulator
clvm_tools clvm_tools-js functions (run, brun, opc, opd, read_ir)
clvm clvm-js (Program, SExp, op_codes etc.)
clvm clvm-js (Program, SExp etc.)
utils Chia-utils (bech32m and other helpers)
connection Properties of the current connection
options Configurable REPL options
contentHasher A helper to generate NFT compatible hashes for files or remote resources
metadataFactory A helper to generate NFT and Collection metadata
minter The NFT minter. Only availble when connected to the chia daemon
repl.builtinModules
Show other available builtin node modules

Expand All @@ -92,6 +95,8 @@ compile(chiaLisp, prefix, ...compileArgs)
Compiles a chialisp program into its address, clvm, puzzle, and puzzle_hash
test(chiaLisp, compileArgs = [], programArgs = []))
Runs a chialisp program and displays its output
uploadNft(dataFile, metadataContent, ipfsToken, licenseFile)
Uploads nft files to nft.storage. The minter uses this internally.
```

## Examples
Expand All @@ -101,6 +106,31 @@ Once connected to the `daemon` each of the service endpoints becomes availalbe a

Knowing [the chia rpc api](https://dkackman.github.io/chia-api/) will help immensely. All endpoints and data payloads should work. Since it is a full nodejs REPL environment, core modules like `fs` and `http` are available.

### Mint a simple NFT

```javascript
🌿 let dataFileInfo = {
name: 'test-nft-by-you',
type: 'image/jpg',
filepath: 'E:\\nft\\flower.jpg'
};
🌿 let mintingInfo = {
wallet_id: 2,
target_address: 'txch10kn82kl6hqv47qzeh4ugmqjr5mmdcnrlymfx8wl9nrhhkyxnzfkspna7l9',
};
🌿 let collectionMetaData = metadataFactory.createCollectionMetadata('test-nft-collection-by-you');
🌿 let nftMetadata = metadataFactory.createNftMetadata('test-nft-by-you', collectionMetaData);
🌿 await minter.createNftFromFile(dataFileInfo, mintingInfo, nftMetadata);
{
spend_bundle: {
aggregated_signature: '0x99e39df189f009a4679067d212a6845b7bfec05452d9696de79907a861239de3cbd247a27c39b2ca2492740f9f4aab58028ebf035f40597d16ddeee5194f8dfaa8c8ec8e90b6c91fce60944f0e55997b443be63ed8e9dcb9d685a9b473e1b441',
coin_solutions: [ [Object], [Object], [Object] ]
},
success: true,
wallet_id: 2
}
```

### Run a CLVM Program

```javascript
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions packages/chia-repl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

[![CodeQL](https://github.com/dkackman/chia-repl/actions/workflows/codeql.yml/badge.svg)](https://github.com/dkackman/chia-repl/actions/workflows/codeql.yml)
[![Node.js CI](https://github.com/dkackman/chia-repl/actions/workflows/node.js.yml/badge.svg)](https://github.com/dkackman/chia-repl/actions/workflows/node.js.yml)
[![NPM](https://nodei.co/npm/chia-repl.png?mini=true)](https://npmjs.org/package/chia-repl)
<a href="https://www.npmjs.com/package/chia-repl"><img src="https://img.shields.io/npm/v/chia-repl.svg?sanitize=true" alt="Version"></a>
<a href="https://www.npmjs.com/package/chia-repl"><img src="https://img.shields.io/npm/l/chia-repl.svg?sanitize=true" alt="Version"></a>
<a href="https://www.npmjs.com/package/chia-repl"><img src="https://img.shields.io/npm/dm/chia-repl.svg?sanitize=true" alt="Monthly Downloads"></a>
<a href="https://www.npmjs.com/package/chia-repl"><img src="https://img.shields.io/npm/dt/chia-repl.svg?sanitize=true" alt="Total Downloads"></a>

A REPL tool for Chia that incorporates various chia and crypto utilities in a single, interactive node environent.

Expand All @@ -11,6 +14,8 @@ A REPL tool for Chia that incorporates various chia and crypto utilities in a si
- [clvm-js](https://github.com/Chia-Mine/clvm-js)
- [chia-utils](https://github.com/CMEONE/chia-utils)
- [@rigidity/bls-signatures](https://github.com/Rigidity/bls-signatures)
- [chia-daemon](https://github.com/dkackman/chia-repl/tree/main/packages/chia-daemon)
- [chia-nft-minter](https://github.com/dkackman/chia-repl/tree/main/packages/chia-nft-minter)

## Packaged

Expand Down Expand Up @@ -73,12 +78,15 @@ Some of these configure the connection and REPL options, while other enable inte
These global objects are available within the REPL environment
bls BLS signature functions
chia Chia node rpc services. This object is only availble after a successful .connect
All functions on these chia services are async & awaitable: crawler, daemon, farmer, full_node, harvester, wallet
All functions on these chia services are async & awaitable: crawler, daemon, farmer, full_node, harvester, wallet, simulator
clvm_tools clvm_tools-js functions (run, brun, opc, opd, read_ir)
clvm clvm-js (Program, SExp, op_codes etc.)
clvm clvm-js (Program, SExp etc.)
utils Chia-utils (bech32m and other helpers)
connection Properties of the current connection
options Configurable REPL options
contentHasher A helper to generate NFT compatible hashes for files or remote resources
metadataFactory A helper to generate NFT and Collection metadata
minter The NFT minter. Only availble when connected to the chia daemon
repl.builtinModules
Show other available builtin node modules

Expand All @@ -87,6 +95,8 @@ compile(chiaLisp, prefix, ...compileArgs)
Compiles a chialisp program into its address, clvm, puzzle, and puzzle_hash
test(chiaLisp, compileArgs = [], programArgs = []))
Runs a chialisp program and displays its output
uploadNft(dataFile, metadataContent, ipfsToken, licenseFile)
Uploads nft files to nft.storage. The minter uses this internally.
```

## Examples
Expand Down
2 changes: 1 addition & 1 deletion packages/chia-repl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chia-repl",
"version": "0.12.5",
"version": "0.12.6",
"description": "A REPL tool for Chia that incorporates various chia and crypto utilities in a single, interactive node environent.",
"main": "index.js",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions packages/chia-repl/repl_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,18 @@ export default function createRepl(cursor) {
console.log(`${chalk.green('utils')}\t\tChia-utils (bech32m and other helpers)`);
console.log(`${chalk.green('connection')}\tProperties of the current connection`);
console.log(`${chalk.green('options')}\t\tConfigurable REPL options`);
console.log(`${chalk.green('contentHasher')}\tA helper to generate NFT compatible hashes for files or remote resources`);
console.log(`${chalk.green('metadataFactory')}\tA helper to generate NFT and Collection metadata`);
console.log(`${chalk.green('minter')}\t\tThe NFT minter. Only availble when connected to the chia daemon`);
console.log(`${chalk.green('repl.builtinModules')}\n\t\tShow other available builtin node modules`);

console.log('\nThese global functions are invocable within the REPL environment');
console.log(`${chalk.green('compile')}${chalk.gray('(chiaLisp, prefix, ...compileArgs)')}`);
console.log('\t\tCompiles a chialisp program into its address, clvm, puzzle, and puzzle_hash');
console.log(`${chalk.green('test')}${chalk.gray('(chiaLisp, compileArgs = [], programArgs = []))')}`);
console.log('\t\tRuns a chialisp program and displays its output');
console.log(`${chalk.green('uploadNft')}${chalk.gray('(dataFile, metadataContent, ipfsToken, licenseFile)')}`);
console.log('\t\tUploads nft files to nft.storage. The minter uses this internally.');

chiaRepl.repl.displayPrompt();
}
Expand Down

0 comments on commit 3865c0c

Please sign in to comment.