在EOSIO智能合约中将具有返回类型的操作名称传递给EOSIO_DISPATCH

时间:2019-02-19 04:32:58

标签: c++ smartcontracts eos

我有以下EOSIO智能合约:

import 'package:flutter/material.dart';

void main() {
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'My Title',
      home: new MyHomePage(),
    );
  }
}


class MyHomePage extends StatefulWidget {

  static void setIndex(BuildContext context, int _newIndex) {
    _MyHomePageState state = context.ancestorStateOfType(TypeMatcher<_MyHomePageState>());
    state.setState(() {
      state.selectedPageIndex =_newIndex;
    });
  }

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}


class _MyHomePageState extends State<MyHomePage> {
  var selectedPageIndex = 0;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Container(),
      bottomNavigationBar:
          MyClass().buildBottomNavigationBar(context,selectedPageIndex),
    );
  }
}

class MyClass {
  BottomNavigationBar buildBottomNavigationBar(context,selectedPageIndex) {
    return new BottomNavigationBar(
      type: BottomNavigationBarType.fixed,
      items: [
        BottomNavigationBarItem(
          title: Text("Page1"),
          icon: Icon(Icons.account_circle),
        ),
        BottomNavigationBarItem(
          title: Text("Page2"),
          icon: Icon(Icons.account_circle),
        ),
      ],
      onTap: (index) {
    MyHomePage.setIndex(context, index);
    },
      currentIndex: selectedPageIndex,
    );
  }
}

我没有得到如何在#include <eosiolib/eosio.hpp> #include <eosiolib/print.hpp> using namespace eosio; class random : public contract { public: using contract::contract; [[eosio::action]] void hi(name user) { print("Hello and welcome to the future ", user); } [[eosio::action]] int compute(int x) { // unsigned means no negative values which increases the range of numbers the variable can hold const unsigned int FIVE = 5; // FIVE = 3; // would throw an error as FIVE is declared constant return x * x + FIVE; } }; EOSIO_DISPATCH(random, (compute)) 中调用compute的操作,因为它具有返回类型int。有人可以帮我吗?我想在testnet上部署此智能合约。 当我执行EOSIO_DISPATCH(random, (compute))时会产生以下错误:

eosio-cpp -o random.wasm random.cpp --abigen

0 个答案:

没有答案