From dbbe57b54de98246c780785292ae341f9631884d Mon Sep 17 00:00:00 2001 From: 11reed Date: Tue, 27 Jul 2021 13:53:35 -0400 Subject: [PATCH] added syntax highlighting to javascript README --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 00a8608..36b3f62 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This library uses a smart contract located at solana-json.so to store text based # Testnet Example This code exaple will set up a connection to the Solana testnet, create a user and request airdrop funding. It will then deploy the contract to testnet and push and pull example JSON data to the contract. -``` +```javascript const solanaJSON = require('./solana-json.js'); (async() => { @@ -16,12 +16,15 @@ const solanaJSON = require('./solana-json.js'); const connection = solanaJSON.setupConnection('https://testnet.solana.com'); const payerAccount = await solanaJSON.createUser(); await solanaJSON.fundUser(connection,payerAccount); + const smartContract = { pathToProgram: './solana-json.so', dataLayout: solanaJSON.setDataStructure(1000), } + const app = await solanaJSON.loadProgram(connection,smartContract,payerAccount); console.log('app',app); + const confirmationTicket = await solanaJSON.pushJSON(connection,app,'{"abc":123}'); const testJSON = solanaJSON.pullJSON(connection,app.appAccount.publicKey); console.log(`Test: ${JSON.parse(testJSON).abc}`); @@ -33,7 +36,7 @@ const solanaJSON = require('./solana-json.js'); To deploy the contract on mainnet you'll need an account with some SOL tokens to pay for the transactions. You can load a user account using a private key buffer array. Check the code in solana-json.rs to make sure this is what you are looking for. There are currently no checks on the data provider key so anyone can upload and modify the data stored in the contract. Editing this file will require rebuilding using "cargo build-bpf" -``` +```javascript const payerAccount = solanaJSON.loadUser([1,185,72,49,215,81,171,50,85,54,122,53,24,248,3,221,42,85,82,43,128,80,215,127,68,99,172,141,116,237,232,85,185,31,141,73,173,222,173,174,4,212,0,104,157,80,63,147,21,81,140,201,113,76,156,161,154,92,70,67,163,52,219,72]); ``` @@ -56,4 +59,4 @@ If anyone would like to add code to the project please do so via a pull request. - Easy way to adjust data size - Add secure data option on smartcontract - Test random data such as unicode in json -- Audit smartcontract +- Audit smartcontract \ No newline at end of file