Giter Site home page Giter Site logo

fantoken-tutorial's Introduction

fantoken-tutoral

fantoken-tutorial's People

Contributors

0xneit avatar

Stargazers

 avatar  avatar  avatar deleted avatar PLeum.K avatar 大雄呀 avatar Xdefidev avatar GoldenBull avatar

Watchers

 avatar

fantoken-tutorial's Issues

error when tryingcto publish

when ever i run aptos move publish

this is what returns

C:\Users\user\Documents\Projects\token\aptos>aptos move publish
Compiling, may take a little while to download git dependencies...
INCLUDING DEPENDENCY AptosFramework
INCLUDING DEPENDENCY AptosStdlib
INCLUDING DEPENDENCY MoveStdlib
BUILDING nuklean
package size 2042 bytes
{
"Error": "Simulation failed with status: Transaction Executed and Committed with Error BACKWARD_INCOMPATIBLE_MODULE_UPDATE"
}

this is my code:

address admin{

module nuklean{
    use aptos_framework::coin;
    use std::signer;
    use std::string;

    struct NUKs{}

    struct CoinCapabilities<phantom NUKs> has key {
        mint_capability: coin::MintCapability<NUKs>,
        burn_capability: coin::BurnCapability<NUKs>,
        freeze_capability: coin::FreezeCapability<NUKs>
    }

    const E_NO_ADMIN:u64 =0;
    const E_NO_CAPABILITY:u64 =1;
    const E_HAS_CAPABILITY:u64 =2;

    public entry fun init_nuk(account: &signer){
        let(burn_capability,freeze_capability,mint_capability)=coin::initialize<NUKs>(
            account,
            string::utf8(b"Nuklean"),
            string::utf8(b"NUKs"),
            18,
            true
        );

        assert!(signer::address_of(account)==@admin,E_NO_ADMIN);
        assert!(!exists<CoinCapabilities<NUKs>>(@admin),E_HAS_CAPABILITY);

        move_to<CoinCapabilities<NUKs>>(account,CoinCapabilities<NUKs>{mint_capability,burn_capability,freeze_capability});
        
    }

     public fun mint<NUKs>(account: &signer,user:address ,amount:u64) acquires CoinCapabilities{
        let account_address = signer::address_of(account);
        assert!(account_address==@admin,E_NO_ADMIN);
        assert!(!exists<CoinCapabilities<NUKs>>(account_address),E_NO_CAPABILITY);
        let mint_capability= &borrow_global<CoinCapabilities<NUKs>>(account_address).mint_capability;
        let coins = coin::mint<NUKs>(amount,mint_capability);
        coin::deposit<NUKs>(user,coins)
    }
    
    public fun burn<NUKs>(coin: coin::Coin<NUKs>) acquires CoinCapabilities {
        let burn_capability= &borrow_global<CoinCapabilities<NUKs>>(@admin).burn_capability;
        coin::burn<NUKs>(coin,burn_capability);
    }
}

}

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.