GithubHelp home page GithubHelp logo

shufune / functions-lens-eventbrite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smartcontractkit/functions-lens-eventbrite

0.0 0.0 0.0 917 KB

License: MIT License

JavaScript 16.37% Solidity 83.63%

functions-lens-eventbrite's Introduction

Functions Lens Eventbrite

This project combines Chainlink Functions with Lens Publication Actions to demonstrate how one can generate discount codes for events on Eventbrite using Collect module.

Prerequisites

Getting Started

  1. Install packages
npm install
  1. Compile contracts
forge build

What are we building?

Using Chainlink Functions and Lens Publication Actions, we are going to develop a system for generating discount codes for events (like Smartcon or Raave for example) hosted on Eventbrite.

The event organizer will need to create a new event on Eventbrite, following these instructions.

event

To develop and use this project, you will need to obtain a free Eventbrite API key.

Once you generate an Eventbrite API key, you can visit the following web page to validate it works as expected https://www.eventbriteapi.com/v3/users/me/?token=<YOUR_API_KEY_GOES_HERE>

Next, you will need to get your

  • Organization ID, by visiting https://www.eventbriteapi.com/v3/users/me/organizations/?token=<YOUR_API_KEY_GOES_HERE>
  • Event ID, by visiting https://www.eventbriteapi.com/v3/organizations/<ORGANIZATION_ID_GOES_HERE>/events/?token=<YOUR_API_KEY_GOES_HERE>

The core logic is stored in the DiscountPublicationAction.sol smart contract which implements IPublicationActionModule and FunctionsClient interfaces. On Lens collect, it will make a Chainlink Functions request to execute the JavaScript code from the source.js file, which will resolve User's address to a Lens handle and generate the Eventbrite discount code for the provided event. The DiscountPublicationAction.sol smart contract will then store the returned discount code.

discount

Usage

For setting up environment variables we are going to use the @chainlink/env-enc package for extra security. It encrypts sensitive data instead of storing them as plain text in the .env file, by creating a new, .env.enc file. Although it's not recommended to push this file online, if that accidentally happens your secrets will still be encrypted.

  1. Set a password for encrypting and decrypting the environment variable file. You can change it later by typing the same command.
npx env-enc set-pw
  1. Now set the API_KEY environment variable by typing:
npx env-enc set

After you are done, the .env.enc file will be automatically generated.

If you want to validate your inputs you can always run the following command:

npx env-enc view
  1. Run local simulation
forge test -vvv --ffi

test

Disclaimer

This tutorial offers educational examples of how to use a Chainlink system, product, or service and is provided to demonstrate how to interact with Chainlink’s systems, products, and services to integrate them into your own. This template is provided “AS IS” and “AS AVAILABLE” without warranties of any kind, it has not been audited, and it may be missing key checks or error handling to make the usage of the system, product, or service more clear. Do not use the code in this example in a production environment without completing your own audits and application of best practices. Neither Chainlink Labs, the Chainlink Foundation, nor Chainlink node operators are responsible for unintended outputs that are generated due to errors in code.

functions-lens-eventbrite's People

Contributors

andrejrakic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.