Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clockwork-xyz/sdk

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clockwork-xyz/sdk

Clockwork Typescript SDK

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Clockwork SDK

Clockwork Typescript SDK

License

Getting Started

For a quickstart guide and in depth tutorials, see the Clockwork Docs. To jump straight to examples, go here. For the latest Rust API documentation, see Clockwork Rust SDK.

Note

  • Clockwork SDK is in active development, so all APIs are subject to change.
  • This code is unaudited. Use at your own risk.

Usage

First, initialize a ClockworkProvider

const wallet = new NodeWallet(new Keypair());
const connection = new Connection(clusterApiUrl("devnet"));
const provider = new ClockworkProvider(wallet, connection);

Get Thread Address

let [pubkey, bump] = provider.getThreadPDA(
      wallet.publicKey,
      "ThreadProgramTest"
);

Initialize a Thread

let tx = await provider.threadCreate(
      wallet.publicKey,         // authority
      "ThreadProgramTest",      // id
      [],                       // instructions to execute
      { now: {} },              // thread trigger
      0.1 * LAMPORTS_PER_SOL    // amount to send to the thread
);

Get Thread Data Deserialized

let threadAccount = await provider.getThreadAccount(threadPubkey);

Pause/Resume/Reset/Delete/ Thread

let tx = await provider.threadPause(wallet.publicKey, threadPubkey);
let tx = await provider.threadResume(wallet.publicKey, threadPubkey);
let tx = await provider.threadReset(wallet.publicKey, threadPubkey);
let tx = await provider.threadDelete(wallet.publicKey, threadPubkey);

Update a Thread

let tx = await provider.threadUpdate(wallet.publicKey, threadPubkey, {
      name: "TestUpdateThread",
      rateLimit: new BN(32),
      trigger: { now: {} },
});

Withdraw from Thread

let tx = await provider.threadWithdraw(
      wallet.publicKey,
      threadPubkey,
      0.01 * LAMPORTS_PER_SOL
);

Get Crate Info

let tx = await provider.getCrateInfo();

Get Worker Address

let [pubkey, bump] = provider.getWorkerPDA("8");

Get Worker Account

let workerAccount = await provider.getWorkerAccount(workerPubkey);

Keywords

FAQs

Package last updated on 01 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc