top-block-game-cocos-demo/assets/typescript/test.ts

37 lines
1007 B
TypeScript

import { _decorator, Component, Node, NodeEventType } from "cc";
import TBG from "./tgb";
// import ercAbi from "./abi/abi";
const { ccclass, property } = _decorator;
const ETH_CONTRACT = "0x3865194cD048f7b14b465a96907fB6546B888216";
@ccclass("NewComponent")
export class NewComponent extends Component {
start() {
const tbg = new TBG({});
tbg.on("accountChange", () => {
console.log("hasChange");
});
this.node.on(
NodeEventType.MOUSE_DOWN,
async () => {
const account = await tbg.login();
const res2 = await tbg.sign({});
// const res2 = await tbg.createNft({
// abi: ercAbi,
// contract: ETH_CONTRACT,
// toAddress: account,
// });
const res = await tbg.sendTransaction({
from: account,
to: "0x96216849c49358B10257cb55b28eA603c874b05E",
value: "1000000000000000",
});
console.log(res);
},
this
);
}
update(deltaTime: number) {}
}