Redirecting the result to the user contract
To redirect the result to the user's contract, the following code should be added to the contract:
#pragma once
#include <string>
#include <eosio/eosio.hpp>
#include <eosio/singleton.hpp>
namespace eosio {
using std::string;
class [[eosio::contract("eosio.demo")]] demo: public contract {
public:
using contract::contract;
[[eosio::action]]
void result( const name &payer, const name &owner_random_value, const string& random_value );
using result_action = eosio::action_wrapper<"result"_n, &demo::result>;
private:
struct [[eosio::table]] randresult {
name owner_random_value;
string random_value;
};
using random_result = eosio::singleton<"randresult"_n, randresult>;
};
}When buying a random, enter the name of your account where the smart contract is located in the memo field (<account name for result forward>)
It is mandatory to put the word contract before the account name (see example above).
Last updated