Reputation: 407
I am currently diving into smart contract development for eosio. By walking through the tutorials I noticed a certain C++ language feature I have never seen before:
#include <eosio/eosio.hpp>
using namespace eosio;
class [[eosio::contract]] hello : public contract {
public:
using contract::contract;
[[eosio::action]]
void hi( name user ) {
print( "Hello, ", user);
}
};
My question is what does the [[eosio::contract]]
in the class declaration and the [[eosio::action]]
in the method declaration mean? What is the term for this C++ language feature?
Upvotes: 1
Views: 826
Reputation: 238311
What is the term for this C++ language feature?
The double square brackets are syntax for attributes. They are specified in the C++ standard section [dcl.attr]:
[dcl.attr]
Attributes specify additional information for various source constructs such as types, variables, names, blocks, or translation units.
My question is what does the [[eosio::contract]] in the class declaration and the [[eosio::action]] in the method declaration mean?
eosio
is a non-standard attribute-namespace, so you should consult their documentation for the meaning of their custom attributes.
Upvotes: 2