An experimental project for representing any JSON data structure as a Starknet smart contract. It demonstrates the feasibility of hosting complex objects, such as MIDI compositions, in smart contracts
Install modules defined in package.json
npm install
Create a temporary environment
nix-shell
To represent a JSON object as a Starknet smart contract:
- Create a new folder and place the JSON file in it.
- Run the following command:
npx hardhat generateContract <path-to-json-file> <name-of-generated-file>
This will generate a new cairo file with the specified name in contracts folder.
npx hardhat generateContract example/input/midi.json midi-generated
(I used the Tone.js library to convert the object retrieved from the smart contract into a midi file.)
Once your contract is deployed, you can call the smart contract's retrieve_object
function to get a representation of your original JSON object.
To convert this object back to a JSON style, you can use the onchainObjectToJSON function.
If you have any comments, suggestions, or encounter any problems, please let me know. You can submit your feedback by creating an issue on this repository, or you can contact me on Twitter at @raphael_dkhn. Thank you for your support!