Basic Implementation
LiquidAccount Consumer Example Contract used in unit tests
in zeus_boxes/contracts/eos/vaccountsconsumer/vaccountsconsumer.cpp
The consumer contract is a great starting point for playing around with the LiquidAccount syntax.
/* DELAY REMOVAL OF USER DATA INTO VRAM */
/* ALLOWS FOR QUICKER ACCESS TO USER DATA WITHOUT THE NEED TO WARM DATA UP */
#define VACCOUNTS_DELAYED_CLEANUP 120
/* ADD NECESSARY LIQUIDACCOUNT / VRAM INCLUDES */
#include "../dappservices/vaccounts.hpp"
#include "../dappservices/ipfs.hpp"
#include "../dappservices/multi_index.hpp"
/* ADD LIQUIDACCOUNT / VRAM RELATED ACTIONS */
#define DAPPSERVICES_ACTIONS() \
XSIGNAL_DAPPSERVICE_ACTION \
IPFS_DAPPSERVICE_ACTIONS \
VACCOUNTS_DAPPSERVICE_ACTIONS
#define DAPPSERVICE_ACTIONS_COMMANDS() \
IPFS_SVC_COMMANDS()VACCOUNTS_SVC_COMMANDS()
#define CONTRACT_NAME() vaccountsconsumer
CONTRACT_START()
/* THE FOLLOWING STRUCT DEFINES THE PARAMS THAT MUST BE PASSED */
struct dummy_action_hello {
name vaccount;
uint64_t b;
uint64_t c;
EOSLIB_SERIALIZE( dummy_action_hello, (vaccount)(b)(c) )
};
/* DATA IS PASSED AS PAYLOADS INSTEAD OF INDIVIDUAL PARAMS */
[[eosio::action]] void hello(dummy_action_hello payload) {
/* require_vaccount is the equivalent of require_auth for EOS */
require_vaccount(payload.vaccount);
print("hello from ");
print(payload.vaccount);
print(" ");
print(payload.b + payload.c);
print("\n");
}
[[eosio::action]] void hello2(dummy_action_hello payload) {
print("hello2(default action) from ");
print(payload.vaccount);
print(" ");
print(payload.b + payload.c);
print("\n");
}
[[eosio::action]] void init(dummy_action_hello payload) {
}
/* EACH ACTION MUST HAVE A STRUCT THAT DEFINES THE PAYLOAD SYNTAX TO BE PASSED */
VACCOUNTS_APPLY(((dummy_action_hello)(hello))((dummy_action_hello)(hello2)))
CONTRACT_END((init)(hello)(hello2)(regaccount)(xdcommit)(xvinit)(xvauth))
Last updated