Giter Site home page Giter Site logo

vesting's Introduction

## Functionality

This application includes functionality for locking and unlocking assets within a smart contract on the Terra blockchain. Below are the details on how to use these features in the code.

### Locking Assets

To lock assets, the application constructs a message to execute a smart contract on the Terra blockchain. This is done by specifying the amount to lock and a memo for the transaction. Here's an example of how to lock `1,000,000` units of an asset:

```javascript
case 'lock':
    const amountToLock = '1000000'; // Specify the amount to lock
    const lockMsg = {
        lock: {
            memo: 'I got $BEEF yo!' // Add a memo to the lock transaction
        }
    };
    msg = new MsgExecuteContract(
        wallet.key.accAddress, // Your Terra wallet address
        'terra164kf48vusvnmsku8v37uy9ynxpr5u333hvcz0wd6mfr8el56wx9sfzuhxq', // The address of the contract to execute
        {
            send: {
                contract: 'terra126krz76md6ykyvnltme2u5uhl640r7pcnsec9kcmnaak9vm7agjqcq3y0q', // The contract to which assets are being locked
                amount: amountToLock,
                msg: Buffer.from(JSON.stringify(lockMsg)).toString('base64') // The lock message, base64 encoded
            }
        },
        {} // Additional options can be specified here
    );
    break;

Unlocking Assets

To unlock assets, you need to specify the lock_id that was generated when the assets were locked. This example demonstrates how to unlock assets:

case 'unlock':
    const lockIdToUnlock = 'terra10p0n98g39xj8k5twpd99c068s6ykuzgcv28a5k_terra164kf48vusvnmsku8v37uy9ynxpr5u333hvcz0wd6mfr8el56wx9sfzuhxq_1'; // The lock_id of the assets to unlock
    msg = new MsgExecuteContract(
        wallet.key.accAddress, // Your Terra wallet address
        'terra126krz76md6ykyvnltme2u5uhl640r7pcnsec9kcmnaak9vm7agjqcq3y0q', // The address of the contract to execute
        {
            unlock: {
                lock_id: lockIdToUnlock // Specify the lock_id to unlock
            },
        },
        {} // Additional options can be specified here
    );
    break;

vesting's People

Contributors

przmyst 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.