Basic implementation
The following is an overview of an example smart contract that uses vRAM
1
#pragma once
2
​
3
#include "../dappservices/ipfs.hpp"
4
#include "../dappservices/multi_index.hpp"
5
​
6
#define DAPPSERVICES_ACTIONS() \
7
XSIGNAL_DAPPSERVICE_ACTION \
8
IPFS_DAPPSERVICE_ACTIONS
9
​
10
/*** IPFS: (xcommit)(xcleanup)(xwarmup) ***/
11
#define DAPPSERVICE_ACTIONS_COMMANDS() \
12
IPFS_SVC_COMMANDS()
13
​
14
/*** UPDATE CONTRACT NAME ***/
15
#define CONTRACT_NAME() mycontract
16
​
17
using std::string;
18
​
19
CONTRACT_START()
20
public:
21
​
22
/*** YOUR LOGIC ***/
23
​
24
private:
25
struct [[eosio::table]] vramaccounts {
26
asset balance;
27
uint64_t primary_key()const { return balance.symbol.code().raw(); }
28
};
29
​
30
/*** VRAM MULTI_INDEX TABLE ***/
31
typedef dapp::multi_index<"vaccounts"_n, vramaccounts> cold_accounts_t;
32
​
33
/*** FOR CLIENT SIDE QUERY SUPPORT ***/
34
typedef eosio::multi_index<".vaccounts"_n, vramaccounts> cold_accounts_t_v_abi;
35
TABLE shardbucket {
36
std::vector<char> shard_uri;
37
uint64_t shard;
38
uint64_t primary_key() const { return shard; }
39
};
40
typedef eosio::multi_index<"vaccounts"_n, shardbucket> cold_accounts_t_abi;
41
​
42
/*** ADD ACTIONS ***/
43
CONTRACT_END((your)(actions)(here))
Copied!
Copy link