docs: readme update
This commit is contained in:
12
README.md
12
README.md
@@ -119,6 +119,18 @@ All exports are stored under `rsdk` global variable.
|
||||
```
|
||||
|
||||
### Using the RedStone Gateway
|
||||
|
||||
#### SDK version >= `0.5.0`
|
||||
From version `0.5.0`, the RedStone Gateway is the default gateway used by the SDK.
|
||||
By default, the `{notCorrupted: true}` mode is used (as describe below).
|
||||
If you want to use the Arweave gateway in version >= `0.5.0`:
|
||||
```ts
|
||||
const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
|
||||
.useArweaveGateway()
|
||||
.build();
|
||||
```
|
||||
|
||||
#### SDK version < `0.5.0`
|
||||
In order to use the [Redstone Gateway](https://github.com/redstone-finance/redstone-sw-gateway) for loading the contract interactions,
|
||||
configure the smartweave instance in the following way:
|
||||
```ts
|
||||
|
||||
@@ -18,21 +18,18 @@ async function main() {
|
||||
});
|
||||
|
||||
try {
|
||||
const smartweave = SmartWeaveNodeFactory
|
||||
.memCachedBased(arweave)
|
||||
.useRedStoneGateway()
|
||||
.build();
|
||||
const smartweave = SmartWeaveNodeFactory.memCached(arweave);
|
||||
|
||||
const jsContractSrc = fs.readFileSync(path.join(__dirname, 'data/js/token-pst.js'), 'utf8');
|
||||
const wasmContractSrc = fs.readFileSync(path.join(__dirname, 'data/rust/rust-pst_bg.wasm'));
|
||||
const initialState = fs.readFileSync(path.join(__dirname, 'data/js/token-pst.json'), 'utf8');
|
||||
|
||||
// case 1 - full deploy, js contract
|
||||
/* const contractTxId = await smartweave.createContract.deploy({
|
||||
const contractTxId = await smartweave.createContract.deploy({
|
||||
wallet,
|
||||
initState: initialState,
|
||||
src: jsContractSrc,
|
||||
}, true);*/
|
||||
}, true);
|
||||
|
||||
// case 2 - deploy from source, js contract
|
||||
/*const contractTxId = await smartweave.createContract.deployFromSourceTx({
|
||||
@@ -57,16 +54,27 @@ async function main() {
|
||||
srcTxId: "5wXT-A0iugP9pWEyw-iTbB0plZ_AbmvlNKyBfGS3AUY",
|
||||
}, true);*/
|
||||
|
||||
const contract = smartweave.contract("CRMRwP-poSTYI7f9fI-vF0CKaTTJTIl74KQYbnJ4hnE").connect(wallet);
|
||||
const contract = smartweave.contract(contractTxId).connect(wallet);
|
||||
|
||||
const result = await contract.writeInteraction<any>({
|
||||
await contract.bundleInteraction<any>({
|
||||
function: "storeBalance",
|
||||
target: "M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI",
|
||||
});
|
||||
|
||||
//const {state, validity} = await contract.readState();
|
||||
await contract.bundleInteraction<any>({
|
||||
function: "storeBalance",
|
||||
target: "M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI",
|
||||
});
|
||||
|
||||
//logger.info("Result", state);
|
||||
await contract.bundleInteraction<any>({
|
||||
function: "storeBalance",
|
||||
target: "M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI",
|
||||
});
|
||||
|
||||
const {state, validity} = await contract.readState();
|
||||
|
||||
logger.info("Result", state);
|
||||
logger.info("Validity", validity);
|
||||
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
|
||||
Reference in New Issue
Block a user