Coder Social home page Coder Social logo

learn-near / ncd.l1.sample--thanks Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 22.0 409 KB

Say "thanks!" to other students of the NCD by calling their instance of this contract. You can optionally attach tokens to your message, or even leave an anonymous tip.

JavaScript 0.80% Shell 38.26% TypeScript 60.95%
near-protocol blockchain assemblyscript

ncd.l1.sample--thanks's Introduction

Thanks

Say "thanks!" to other students of the NCD by calling their instance of this contract.

You can optionally attach tokens to your message, or even leave an anonymous tip.

Of course keep in mind that your signing account will be visible on the blockchain via NEAR Explorer even if you send an anonymous message.

⚠️ Warning

Any content produced by NEAR, or developer resources that NEAR provides, are for educational and inspiration purposes only. NEAR does not encourage, induce or sanction the deployment of any such applications in violation of applicable laws or regulations.

Contract

// ------------------------------------
// contract initialization
// ------------------------------------

/**
 * initialize contract with owner ID and other config data
 *
 * (note: this method is called "constructor" in the singleton contract code)
 */
function init(owner: AccountId, allow_anonymous: bool = true): void

// ------------------------------------
// public methods
// ------------------------------------

/**
 * give thanks to the owner of the contract
 * and optionally attach tokens
 */
function say(message: string, anonymous: bool): bool

// ------------------------------------
// owner methods
// ------------------------------------

/**
 * show all messages and users
 */
function list(): Array<Message>

/**
 * generate a summary report
 */
function summarize(): Contract

/**
 * transfer received funds to owner account
 */
function transfer(): void

Usage

Development

To deploy the contract for development, follow these steps:

  1. clone this repo locally
  2. run yarn to install dependencies
  3. run ./scripts/1.dev-deploy.sh to deploy the contract (this uses near dev-deploy)

Your contract is now ready to use.

To use the contract you can do any of the following:

Public scripts

2.say-thanks.sh         # post a message saying thank you, optionally attaching NEAR tokens
2.say-anon-thanks.sh    # post an anonymous message (otherwise same as above)

Owner scripts

o-report.sh             # generate a summary report of the contract state
o-transfer.sh           # transfer received funds to the owner account

Production

It is recommended that you deploy the contract to a subaccount under your MainNet account to make it easier to identify you as the owner

  1. clone this repo locally

  2. run ./scripts/x-deploy.sh to rebuild, deploy and initialize the contract to a target account

    requires the following environment variables

    • NEAR_ENV: Either testnet or mainnet
    • OWNER: The owner of the contract and the parent account. The contract will be deployed to thanks.$OWNER
  3. run ./scripts/x-remove.sh to delete the account

    requires the following environment variables

    • NEAR_ENV: Either testnet or mainnet
    • OWNER: The owner of the contract and the parent account. The contract will be deployed to thanks.$OWNER

ncd.l1.sample--thanks's People

Contributors

amgando avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ncd.l1.sample--thanks's Issues

script '1.dev-deploy.sh' does not work

When run the ./scripts/1.dev-deploy.sh it gives below error

An error occured
Error: Signer dev-xxxxxxxxxxxxx-xxxxxxxxxxxxxx does not exist
We attempted to send transaction 78r88p1XWFbNtRHvv1J4RUWAqfjPZwh8VMyU2stESiT3 to NEAR, but something went wrong.
To see the transaction in the transaction explorer, please open this url in your browser
https://explorer.testnet.near.org/transactions/78r88p1XWFbNtRHvv1J4RUWAqfjPZwh8VMyU2stESiT3
Note: if the transaction was invalid (e.g. not enough balance), it will show as "Not started" or "Finalizing"

When i use only the near dev-deploy ./build/release/thanks.wasm command it works fine.

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.