Code Monkey home page Code Monkey logo

agora-scores's Introduction

Agora Governance SCORE

This repository contains SCORE (Smart Contract for ICON) examples written in Java.

Requirements

You need to install JDK 11 or later version. Visit OpenJDK.net for prebuilt binaries. Or you can install a proper OpenJDK package from your OS vendors.

In macOS:

$ brew tap AdoptOpenJDK/openjdk
$ brew cask install adoptopenjdk11

In Linux (Ubuntu 20.04):

$ sudo apt install openjdk-11-jdk

How to Run

1. Build the project

$ ./gradlew build

The compiled jar bundle will be generated at ./app/build/libs/app-0.2.0.jar.

2. Optimize the jar

You need to optimize your jar bundle before you deploy it to local or ICON networks. This involves some pre-processing to ensure the actual deployment successful.

gradle-javaee-plugin is a Gradle plugin to automate the process of generating the optimized jar bundle. Run the optimizedJar task to generate the optimized jar bundle.

$ ./gradlew optimizedJar

The output jar will be located at ./app/build/libs/app-0.2.0-optimized.jar.

3. Deploy the optimized jar

Using goloop CLI command

Now you can deploy the optimized jar to ICON networks that support the Java SCORE execution environment. Assuming you are running a local network that is listening on port 9082 for incoming requests, you can create a deploy transaction with the optimized jar and deploy it to the local network as follows.

$ goloop rpc sendtx deploy ./app/build/libs/app-0.2.0-optimized.jar \
    --uri http://localhost:9082/api/v3 \
    --key_store <your_wallet_json> --key_password <password> \
    --nid 3 --step_limit=1000000 \
    --content_type application/java

[Note] The content type should be application/java instead of application/zip to differentiate it with the Python SCORE deployment.

Using deployJar extension

Starting with version 0.7.2 of gradle-javaee-plugin, you can also use the deployJar extension to specify all the information required for deployment.

deployJar {
    endpoints {
        local {
            uri = 'http://localhost:9082/api/v3'
            nid = 3
        }
    }
    keystore = rootProject.hasProperty('keystoreName') ? "$keystoreName" : ''
    password = rootProject.hasProperty('keystorePass') ? "$keystorePass" : ''
}

Now you can run deployToLocal task as follows.

$ ./gradlew app:deployToLocal -PkeystoreName=<your_wallet_json> -PkeystorePass=<password>

> Task :app:deployToLocal
>>> deploy to http://localhost:9082/api/v3
>>> optimizedJar = ./app/build/libs/app-0.2.0-optimized.jar
>>> keystore = <your_wallet_json>
Succeeded to deploy: 0x699534c9f5277539e1b572420819141c7cf3e52a6904a34b2a2cdb05b95ab0a3
SCORE address: cxd6d044b01db068cded47bde12ed4f15a6da9f1d8

[Note] If you want to deploy to Lisbon testnet, use the following configuration for the endpoint and run deployToLisbon task.

deployJar {
    endpoints {
        lisbon {
            uri = 'https://lisbon.net.solidwallet.io/api/v3'
            nid = 0x2
        }
        ...
    }
}

agora-scores's People

Contributors

lucas-l avatar sink772 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.