Quick-start Guide to accessing the most powerful workforce in the world.

David Britt
Effect Network
Published in
5 min readDec 14, 2021

We will start this story by telling a simple tale of how you can make your very own dApp using Effect Network. This post guides you along as you make your own dApp for the Effect Network Hackathon, where you can win over $55K in prizes! So come along and let’s learn 📖

TL;DR

  • Create a project directory and download the Effect Network Twitter Template to it. Which can be found here: Tweet Sentiment Template.
  • Install Effect-JS: npm i @effectai/effect-js
  • Copy and paste this in a file called index.js in your project directory and run it with node index.js.
  • 🎉🎉🎉
Quick Start script

All of this is built using Web3 technologies. So, there are no API keys needed! It is optional to have an EOS account or a MetaMask wallet. But for this guide, we’ll assume you’ll be using a burner wallet that is generated by the SDK. We will also assume that you already understand how Effect Network works. But if you don’t, please take a look at our website to learn more! https://effect.network

In this post, we’ll be taking a look at what our Chief Engineer showed in his presentation during the Kick-Off week of the Hackathon asimple Twitter sentiment analysis dApp.

So let’s set it up you are conducting some kind of survey about tweets. Of course, you can use machine learning algorithms to do this kind of analysis. However, your use case falls a bit outside the scope of using such methodologies. You want to be able to use real humans to annotate this dataset for you.

Sneak peek of how the survey template is going to look like.

Enter stage left, Effect Network SDK. With the shiny new SDK, you can create the survey easily, upload it, and like magic up to 10K people will be workingto work on it within a matter of minutes! As the workforce gets on its way with your tasks, you’ll be able to download the results as they come in.

Requirements

To use the SDK, we’ll need to get set up with a couple of requirements. Most notably NodeJS. Download and install NodeJS for your operating system at the following link here.

Setup and Initialize

Make a new directory for this project and install the SDK, in your terminal run:

mkdir effect_tweet_sentiment
cd effect_tweet_sentiment
npm init -y
npm i @effectai/effect-js
touch index.js

Now that we have everything set up and ready to go, we can start building. So let’s import effectsdk into index.js and initiate the client using the jungle configuration.

# index.jsconst fs = require('fs')
const effectsdk = require('@effectai/effect-js')
const client = new effectsdk.EffectClient('jungle')

Create and connect account

First, we’ll need to create an Effect Network account using the createAccount()method. If you have a BSC private key, you can pass it here as well. That way, you will be able to access your account again when you want to create new campaigns, or create batches for this account. Afterwards, we’ll open up a wallet using createWallet()using account. Finally, we pass the wallet to the connectAccount() method. Which will verify the credentials with the Effect Network Account smart contract and will allow you to make authorized calls to edit the campaigns you own.

# index.js...
const account = effectsdk.createAccount()
const wallet = effectsdk.createWallet(account)
const effectAccount = await client.connectAccount(wallet)
console.log(effectAccount)

Pay attention to the output of the connectAccount() call, we’ll need the values of effectAccountin a bit to get funds at the faucet.

Campaign

The campaign is the bucket that holds all the microtasks, each campaign has one template and one set of instructions.

What we are presenting to the workforce on the Effect Network is a microtask. A micro task is a digital task that can within a couple of seconds to a couple of minutes. To present them to the workers, we’ll need to create a template using HTML, within which we’ll be loading data that will render into something like the tweet sentiment analysis microtask displayed up above.

We’ll use a template that has already been created and is available at Effect Force Templates. Download the following file and save as template_tweet.html in your project folder: template_tweet.html

Or copy and paste the template:

The template that will be rendered when presented to the worker.

Using makeCampaign() we can upload and publish the campaign onto the blockchain right away.

# index.js
...
const efx_quantity = '2'
const template_tweet = fs.readFileSync('template_tweet.html', 'utf8')
const campaign_template = {
title: 'Tweet Sentiment Analysis',
description: 'Survey to measure emotional impact of Tweets',
instruction: 'Fill in the survey and press submit',
template: template_tweet,
category: 'Social',
example_task: {
'tweet_id': '20'
},
version: 1,
reward: 2
}
const campaign = await client.force.makeCampaign(campaign_template, efx_quantity)...

Testnet

Take a look at testnet.effect.network, and use the privateKey that you got from calling the connectAccount() method to log in to Effect Force. There you will be able to see the campaigns you created.

Now is also the perfect time to join our Discord and go to the faucet channel to get Testnet tokens so that in the next step you can create batches.

Now that you’ve uploaded the campaign, and gotten your Testnet EFX, you can start uploading tasks to Effect Network. Every time you create a batch the needed amount of EFX is reserved, and paid out to the workers when they have completed a task.

Create an object with the property tasks, and an array with placeholder values that will be substituted every time it is loaded into the template. In this case, the template has a placeholder called: tweet_id, so we need to specify the value for each data point. Afterwards, use the getMyLastCampaign() method to get the last campaign you created and to upload the batch to that campaign using createBatch().

# index.js
...
const content = {
'tasks': [
{'tweet_id': '20'},
{'tweet_id': '21'},
{'tweet_id': '22'}
]
}
repeat_task = '3'
const lastCampaign = await client.force.getMyLastCampaign()
const batch = client.force.createBatch(campaign.id, content, repeat_task)

Results

All that still needs to be done is to wait for the results to come pouring in. When a worker has done one of your microtask, it will become available to you. All you have to do is call getTaskSubmissionsForBatch() method.

# index.js
...
const batches = await client.force.getCampaignBatches(lastCampaign.id)const submissions = await client.force.getTaskSubmissionsForBatch(batches.pop().batch_id)

Now you can view what each worker filled in for each tweet, and you’ll be able to continue on with your research into tweet sentiment analysis!

Conclusion

Now you also have access to the largest workforce that is available on the Blockchain!

Take a look at our documentation at developer.effect.network for more information on how to use the Effect-JS library or to learn more about Effect Network.

Join our community on Discord to get in touch with the team and meet with the rest of our community.

Finally, sign up at effect-network-hackathon.devpost.com to join the hackathon and win $55K in prize money.

Happy Hacking!

P.S.

Don’t forget to check out: Effect Network Hackathon Workshop — Hands-on with the Effect SDK, presented by Laurens.

--

--