1.1.3 • Published 2 months ago

@shakesco/automation v1.1.3

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
2 months ago

@shakesco/automation

This repository makes it easy for businesss to interact with their autopayment contract and enable automation!

Before intergrating please read this short explanation on how the system works. It will help you understand how you may want to setup your autopayments.

To install:

npm i @shakesco/automation

After installing:

const shakesco = require("@shakesco/automation");
const { TestAutomation, delegateAccount, Automation, automationBusiness } = shakesco;
const { JsonRpcProvider, Wallet, parseUnits } = shakesco;

Use the TestAutomation for testing before going live.

When using TestAutomation:

  const provider = new JsonRpcProvider(process.env.MATICRPC_URL);

  const wallet = new Wallet(process.env.MUMBAIORSEPOLIAPRIVKEY, provider);

  const shakescocontract = new TestAutomation(wallet, automationBusiness);

  const checkRequest = await shakescocontract.isRequested(delegateAccount);
  console.log(checkRequest);

⚠️ The privatekey and provider for testing MUST BE IN MUMBAI OR SEPOLIA. Visit Alchemy

When ready to move live:

📓NOTE: Visit Shakesco to get fee rates and api key.

Send request to user. Ask user for their email or delegate address or username they registered with us.

  const address = /* Initialize your automation address. Can be found in your dashboard https://shakesco.netlify.app/ */

  const shakescocontract = new Automation(address, process.env.SHAKESCOAPIKEY, "Ethereum");

  const period = "604800" //1 week

  const amount = parseUnits("20", 18); //amount to request regularly 

  const delegateAddress = /*Ask user/business for their delegate account(Address or email or identity(.SNS))*/

  const requestUser = await shakescocontract.requestUser(delegateAddress, period, amount, false, [], []);//request user

  const requestBusiness = await shakescocontract.requestBusiness(delegateAddress,period,amount);//or request business

  console.log(requestUser);//Requested user successfully
  console.log(requestBusiness);//Requested business successfully

📓NOTE: Period should be in seconds. Amount should be in usd. Eg: "20" is in usd. Boolean values are returned as STRINGS

When you want to request split payment:

  const address = /* Initialize your automation address. Can be found in your dashboard https://shakesco.netlify.app/ */

  const shakescocontract = new Automation(address, process.env.SHAKESCOAPIKEY);

  const period = "604800" //1 week

  const totalAmount = parseUnits("30", 18); //amount to request regularly 

  const mainAddress = /** Users delegate account, email or identity(.SNS)*/

  const friends = ["", ""]; //request friend details. Delegate account, email or identity(.SNS)

  const friendsAmount = [parseUnits("10", 18), parseUnits("10", 18)];

  const mainamount = parseUnits("10", 18);
  
  const requestUser = await shakescocontract.requestUser(mainAddress, period, mainamount, true, friends, friendsAmount);//request user

  console.log(requestUser); //Requested user successfully (Returns for main only)

  //so check the rest.
  for (let i = 0; i < friends.length; i++) {
    const isrequested = await shakescocontract.isRequested(friends[i]);
    console.log(isrequested); // true/false
  }

To check if user has made payment or not:

  const address = /*Initialize your automation address*/
  
  let delegateAddress = /*Request user for their info: Email or address or identity(.SNS)*/ 

  const shakescocontract = new Automation(address, process.env.SHAKESCOAPIKEY);

  const requestUser = await shakescocontract.hasPaid(delegateAddress);
  console.log(requestUser);//"true"

⚠️WARNING: Check the above step where you are offering your service. Otherwise you will offer service for free without knowing. For split auto-payment, service is only given to 'group leader'. So always query them alone, the rest will just return false.

We also don't offer daily automation. If your business requires daily automation please reach out to us!

ENJOY YOUR FINANCIAL FREEDOM😁!!!

1.1.3

2 months ago

1.1.2

2 months ago

1.1.1

3 months ago

1.1.0

3 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago