Skip to content

Commit

Permalink
added syntax highlighting to javascript README
Browse files Browse the repository at this point in the history
  • Loading branch information
11reed committed Jul 27, 2021
1 parent 179c800 commit dbbe57b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ 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() => {
console.log('deploying...');
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}`);
Expand All @@ -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]);
```

Expand All @@ -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

0 comments on commit dbbe57b

Please sign in to comment.