I get this error
yekaideMacBook-Pro:pdjtask yk$ cleos set contract yekai ../pdjtask/
Reading WAST/WASM from ../pdjtask/pdjtask.wasm...
Using already assembled WASM...
Publishing contract...
1303654ms thread-0 main.cpp:2350 main ] Failed with error: Assert Exception (10)
!"unresolvable": env._ZN8pdjtoken6createEyN5eosio5assetEhhh
pdjtask.hpp
#pragma once
#include <eosiolib/asset.hpp>
#include <eosiolib/eosio.hpp>
#include "pdjtoken.hpp"
#include <string>
using namespace eosio ;
using std::string;
uint64_t tk_id = 1001;
class pdjtask : public contract {
public:
pdjtask( account_name self ): contract(self),ptoken(self){
}
/// @abi action
//创建任务
void createtatask( account_name creator, account_name worker, asset taskBonus, string memo );
//提交任务
void commit( uint64_t taskID, string memo );
//验收任务
void confirm( uint64_t taskID );
private:
/// @abi table tasks i64
struct task {
uint64_t taskID;
account_name creator;
account_name worker;
asset bonus;
uint8_t status = 0;
string remark;
string comment;
uint64_t primary_key()const { return taskID; }
};
typedef eosio::multi_index<N(tasks), task> tasks;
private:
pdjtoken ptoken;
private:
uint64_t getKeyID() {
return tk_id++;
}
};
pdjtask.cpp
#include "pdjtask.hpp"
void pdjtask::createtatask( account_name creator, account_name worker, asset taskBonus, string memo )
{
//创建任务-指定作者-奖金数量-描述
//检查creator 和 worker是否都存在
require_auth(creator);
require_auth(worker);
auto sym = taskBonus.symbol;
eosio_assert( sym.is_valid(), "invalid symbol name" );
uint64_t id = getKeyID();
tasks tk( _self, _self );
asset airToken = taskBonus;
airToken.amount = 100000000;
ptoken.create( _self, airToken, 1, 1, 1 );
tk.emplace(creator,[&](auto &t){
t.creator = creator;
t.worker = worker;
t.taskID = id;
t.bonus = taskBonus;
t.remark = memo;
});
}
void pdjtask::commit( uint64_t taskID, string memo )
{
}
EOSIO_ABI( pdjtask, (createtatask)(commit) )
pdjtoken is another contract
void ocaskans::send_deferred_transferfrom_transaction(oct::transferfromact tf){
eosio::print("transferfromact:", tf.from, tf.to, tf.quantity);
eosio::asset fromBalance = oct::currency(tokenContract).get_balance(tf.from, tf.quantity.symbol.value);
eosio_assert(fromBalance.amount >= tf.quantity.amount,NOT_ENOUGH_OCT_TO_DO_IT);
uint64_t allowed = oct::currency(tokenContract).allowanceOf(tf.from, tf.to, tf.quantity.symbol.value);
eosio_assert(allowed>= tf.quantity.amount, NOT_ENOUGH_ALLOWED_OCT_TO_DO_IT);
using namespace eosio;
auto trx = eosio::transaction();
test_action_action<tokenContract, N(transferfrom)> transferfromcurrency;
copy_data((char*)&tf, sizeof(tf), transferfromcurrency.data);
trx.actions.emplace_back(vector<permission_level>{{currentAdmin, N(active)}},transferfromcurrency);
trx.delay_sec = 2;
trx.send( 0xffffffffffffffff, currentAdmin);
}
@yekai1003
@chenlian2015 thank you
@chenlian2015 Do you have more specific , exmaple about contract inheritance? , I just learning now , thank you!
eg:
ticdist.token.cpp
action(
permission_level{_self, N(active)},
eosio.token, N(transfer),
std::make_tuple(_self, unlocker, lockinf.quantity, memo)
).send();
this realized ticdist.token call eosio.token->transfer
permission_level{_self, N(active)} is check ticdist.token have authority eosio.code,like:
cleos set account permission ticdist.toke active '{"threshold": 1,"keys": [],"accounts": [{"permission":{"actor":"ticdist.toke","permission":"eosio.code"},"weight":1}]}' owner -p ticdist.toke@owner
std::make_tuple(_self, unlocker, lockinf.quantity, memo) is transfer interface parameters.
2018-08-21
wang_yi_lin
发件人: dksuper
发送时间: 2018-08-20 14:20:05
收件人: EOSIO/eos
抄送: wangyilin; Comment
主题: Re: [EOSIO/eos] How can I call another contract in a contract?(#3109)
@chenlian2015 Do you have more specific , exmaple about contract inheritance? , I just learning now , thank you!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
@wangyilin1987
Thanks a lot!
Most helpful comment
void ocaskans::send_deferred_transferfrom_transaction(oct::transferfromact tf){
eosio::print("transferfromact:", tf.from, tf.to, tf.quantity);
eosio::asset fromBalance = oct::currency(tokenContract).get_balance(tf.from, tf.quantity.symbol.value);
eosio_assert(fromBalance.amount >= tf.quantity.amount,NOT_ENOUGH_OCT_TO_DO_IT);
}