Skip to content

Javascript SDK for interacting with a Soroban Governor based DAO.

License

Notifications You must be signed in to change notification settings

script3/soroban-governor-js-sdk

Repository files navigation

soroban-governor-js-sdk JS

JS library for interacting with Soroban smart contracts soroban-governor and soroban-votes via Soroban RPC.

Use it

Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods:

import { VotesClient } from "soroban-governor-js-sdk";

let stellarRpc = new rpc.Server("rpcUrl");
let account = await stellarRpc.getAccount("public key");
let votes = new VotesClient("Contract Address");

let { op, parser } = votes.depositFor({
  from: config.admin.publicKey(),
  amount: 100000n,
});

// Create transaction from operation
let tx = new TransactionBuilder(account, {
  fee: "10000",
  networkPassphrase: "passphrase",
})
  .setTimeout(TimeoutInfinite)
  .addOperation(xdr.Operation.fromXDR(op.toXDR("base64"), "base64"))
  .build();

// Simulate
let sim_resp = await stellarRpc.simulateTransaction(tx);

// Parse Response
let result = ContractResult.fromSimulationResponse(sim_resp, parser);

// Error handling
if (result.result.isErr()) {
  let error = result.result.unwrapErr();
  if (error.type == ContractErrorType.InvokeHostFunctionEntryArchived) {
    // create a restore ledger entry tx_builder
  } else {
    throw result.result.unwrapErr();
  }
}

// ...Handle transaction signing and submitting

About

Javascript SDK for interacting with a Soroban Governor based DAO.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •