npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@agreewe/quickwork-sdk

v1.0.1

Published

Quickwork SDK to allow TS applications to interact with the Quickwork Smart Contract

Downloads

6

Readme

Introduction

This package acts as an interaction layer for the Solidity program found in contracts/quickwork.sol. Quickwork allows for tasks to be proposed by a group, and accomplished by an individual or another group. Once the tasks are deemed completed by the proposers, the various parties can sign on each individual deliverable and release the task bounty attached to each.

Installation instructions

First, install this package via the command below.

npm i @agreewe/solana-blockchain-contracts

Initializing Quickwork Contract

Types and enums:

export enum ApprovalType {
  ALL = 0, // Requires all in the SignerList to sign on each deliverable to be considered completed
  MAJORITY = 1 // Requires > 50% majority in SignerList to sign on each deliverable to be considered completed (e.g. 1/2, 6/11)
}

export interface Deliverable {
  task: string; // Task description
  approvalType: ApprovalType; // Type of approval as seen above
  completed: boolean, // Set to false unless it is already completed from the start
  taskBounty: number // USDC amount - Take note of decimals: 2000000 = USDC $2

}

export interface DeploymentArgs {
  deliverableList: Deliverable[];
  signerList: string[];
  receiverAddress: string;
  agreementEndDate: number; // unix timestamp
  withdrawalAddress: string;
}

If you have not initialized a contract before, refer to the code below.

Only wallet address in the SignerList are able to sign on task to deem it as completed.

Withdrawal address will be the only wallet which can initiate withdrawAll function (only after current date is past the end date of the agreement)

import { deployQuickWorkContract, DeploymentArgs } from 'quickwork-sdk';
import { ethers } from 'ethers';

const deploymentWallet = new ethers.Wallet(PRIVATE_KEY, new ethers.providers.JsonRpcProvider(GOERLI_RPC_URL)); 

const params: DeploymentArgs = {
    deliverableList: [{
        task: "Task 1",
        approvalType: 0,
        completed: false,
        taskBounty: 2000000 //in USDC
    }, {
        task: "Task 2",
        approvalType: 1,
        completed: false,
        taskBounty: 3000000 //in USDC
    }],
    signerList: [signer1.address, signer2.address, signer3.address],
    receiverAddress: signer1.address,
    agreementEndDate: 1669934745,
    withdrawalAddress: deploymentWallet.address, // Does NOT have to be the deployment wallet address. 
}

const deploy = async () => {
    const contract = await deployQuickWorkContract(wallet1, params);
    return contract.address;
}
const contractAddr = deploy();

Take note that the contract has to be funded with >= USDC than the total USDC required for pay outs.

Initiating Quickwork Instance

    const quickworkInstance = new QuickWorkContract(deploymentWallet, contractAddress)

Getting Deliverable Details

    const firstTask = quickworkInstance.getDeliverable(deliverableNo)

Signing Deliverable

    await quickworkInstance.signDeliverable(deliverableNo)

Check If a Deliverable has been Signed by a Specific Party

    await quickworkInstance.isDeliverableApprovedBySigner(deliverableNo, address)

Distribute Task Bounty for Specific Task

This can only be done if the task has been signed by sufficient number of signers and been marked as completed. Task will be automatically marked as completed if the requirements of number of signers are met.

        await quickworkInstance.releaseDeliverableSpecificFund(deliverableNo)

Withdraw All

The withdraw all function withdraws all ETH and USDC in the contract to the withdrawalAddr wallet. This can only be done if the current time is past the end date of the agreement. This function can only be called by the withdrawalAddr specified when deploying the Quickwork Smart Contract.

    await quickworkInstance.withdrawAll()

There are other functions such as getAgreementEndDate(), isUserAllowedToSign(), isDeliverablePaid(), getTotalSigners(), getReceiverAddress(), getSignerCountOnDeliverable() and more. These functions can be found in src/index.ts