I'm new to creating Smart Contracts on EOS and I've followed a few tutorials (for example the official Hello World guide).
Would someone be able explain why all of the examples seem to use the namespace eosio?
Is it possible to use a different namespace?
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
using namespace eosio;
class hello : public eosio::contract {
public:
using contract::contract;
/// @abi action
void hi( account_name user ) {
print( "Hello, ", name{user} );
}
};
EOSIO_ABI( hello, (hi) )
If it is possible to use a different namespace, what are some example situations in which you would use one?
If it isn't possible to use a different namespace, is there any reason why this needs to be in the code and couldn't be left for the compiler to add?
eosiolib
is under eosio namespace to avoid collisions and maintain good practices. it's just standard language-agnostic programming practice to namespace imports