3 Star 2 Fork 0

小野喵 / TaYi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Zlib

TaYi

介绍

TaYi Chain,基于NFT数据关系以及所有权转移和查询的区块链

如何引入

Maven引入

<dependency>
  <groupId>com.xymtop</groupId>
  <artifactId>tayi</artifactId>
  <version>0.0.3</version>
</dependency>

Gradle引入

dependencies {
  compile 'com.xymtop:tayi:0.0.3'
}

智能合约实例

//为了实现自己的合约内容并且调用,你只需要7步
/*
* 1. 继承TaYiJavaContract
* 2.实现Serializable接口,方便序列化
* 3.实现info方法,注册合约信息
* 4.编写自己的方法
* 5.打包为jar包并且上传到IPFS
* 6.在TaYi中部署合约
* 7.调用智能合约方法
* */

@Data
public class Application extends TaYiJavaContract implements Serializable {

    private int count;

    private List<Cat> cats = new ArrayList<>();

    public boolean addCat(){
        Cat cat = new Cat();
        cat.setName("老王");
        cats.add(cat);
        return true;
    }


    public int getName(){
        return count;
    }

    public void  addName(){
         count++;
    }

    @Override
    public ContractInfo info() {
        ContractInfo info = new ContractInfo();
        info.setName("hello,TaYi!");
        return info;
    }


    //获取单属性
    public String getHeight() throws Exception {
        That that = getThat();
        BlockUtils blockUtils = that.getBlockUtils();
        long chainBlockHeight = blockUtils.getChainBlockHeight();
        return "当前区块高度:" + chainBlockHeight;
    }

    //获取对象
    public  Object getObj() throws Exception {
        //执行其他
        NFTMeta nftMeta = new NFTMeta();

        nftMeta.setTitle("TaYi");
        nftMeta.setDescription("美好的生活从现在开始!");
        nftMeta.setImage("https://upload.wikimedia.org/wikipedia/zh/4/4a/Xinjiang_University_logo.png");


        return nftMeta;
    }
    

}

TaYi的前端web3js框架引入

npm install tayijs
yarn add tayijs

前端初始化示例

import {TaYi} from "tayijs/dist/web3/TaYi";


let tayi:TaYi;

const connTaYi = ()=>{
    try {
        tayi =  new TaYi("0x1048f6de58fe9a82d6aa0245f3adbedca08a5fa4","ws://127.0.0.1:8081");

    }catch (e) {
        
    }
 
}

const getTaYi = ()=>{
    if (tayi == null){
        connTaYi();
    }
    return tayi;
}


export {getTaYi}
let  trNFT = "a6e79b6648968a496e75f9949d4f0f0c33e5d7fd999f804ccd4f06976fd9ea4d";

let tayi = getTaYi()
//部署合约
// console.log(await tayi.deploy("Qmcgx8bz2yujVQksvafgxiCmFfg9FJXrFd2NAtyJhhmbLN"))



// mint(address to, string memory tokenURI)
async function mintNFT(to:any,tokenURI:any){
   //调用合约
    return tayi.call(trNFT,"mintNFT",{
        id:Date.now(),
        to,
        tokenURI
    })
}
zlib License (C) 2024 小野喵 This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.

简介

TaYi-基于所有权交易和图结构关系查询的区块链 展开 收起
Zlib
取消

发行版 (3)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/xymtop/tayi.git
git@gitee.com:xymtop/tayi.git
xymtop
tayi
TaYi
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891