{"modulePath":"github.com/hyperledger/burrow","version":"v0.34.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package native\n\n## Variables\n\n```go\nvar Permissions = New().MustContract(\"Permissions\",\n\t`* Interface for managing Secure Native authorizations.\n\t\t* @dev This interface describes the functions exposed by the native permissions layer in burrow.\n\t\t`,\n\tFunction{\n\t\tComment: `\n\t\t\t* @notice Adds a role to an account\n\t\t\t* @param _account account address\n\t\t\t* @param _role role name\n\t\t\t* @return _result whether role was added\n\t\t\t`,\n\t\tPermFlag: permission.AddRole,\n\t\tF:        addRole,\n\t},\n\tFunction{\n\t\tComment: `\n\t\t\t* @notice Removes a role from an account\n\t\t\t* @param _account account address\n\t\t\t* @param _role role name\n\t\t\t* @return _result whether role was removed\n\t\t\t`,\n\t\tPermFlag: permission.RemoveRole,\n\t\tF:        removeRole,\n\t},\n\tFunction{\n\t\tComment: `\n\t\t\t* @notice Indicates whether an account has a role\n\t\t\t* @param _account account address\n\t\t\t* @param _role role name\n\t\t\t* @return _result whether account has role\n\t\t\t`,\n\t\tPermFlag: permission.HasRole,\n\t\tF:        hasRole,\n\t},\n\tFunction{\n\t\tComment: `\n\t\t\t* @notice Sets the permission flags for an account. Makes them explicitly set (on or off).\n\t\t\t* @param _account account address\n\t\t\t* @param _permission the base permissions flags to set for the account\n\t\t\t* @param _set whether to set or unset the permissions flags at the account level\n\t\t\t* @return _result is the permission flag that was set as uint64\n\t\t\t`,\n\t\tPermFlag: permission.SetBase,\n\t\tF:        setBase,\n\t},\n\tFunction{\n\t\tComment: `\n\t\t\t* @notice Unsets the permissions flags for an account. Causes permissions being unset to fall through to global permissions.\n      \t\t* @param _account account address\n      \t\t* @param _permission the permissions flags to unset for the account\n\t\t\t* @return _result is the permission flag that was unset as uint64\n      `,\n\t\tPermFlag: permission.UnsetBase,\n\t\tF:        unsetBase,\n\t},\n\tFunction{\n\t\tComment: `\n\t\t\t* @notice Indicates whether an account has a subset of permissions set\n\t\t\t* @param _account account address\n\t\t\t* @param _permission the permissions flags (mask) to check whether enabled against base permissions for the account\n\t\t\t* @return _result is whether account has the passed permissions flags set\n\t\t\t`,\n\t\tPermFlag: permission.HasBase,\n\t\tF:        hasBase,\n\t},\n\tFunction{Comment: `\n\t\t\t* @notice Sets the global (default) permissions flags for the entire chain\n\t\t\t* @param _permission the permissions flags to set\n\t\t\t* @param _set whether to set (or unset) the permissions flags\n\t\t\t* @return _result is the permission flag that was set as uint64\n\t\t\t`,\n\t\tPermFlag: permission.SetGlobal,\n\t\tF:        setGlobal,\n\t},\n)\n```\n\n```go\nvar Precompiles = New().\n\tMustFunction(`Recover public key/address of account that signed the data`,\n\t\tleftPadAddress(1),\n\t\tpermission.None,\n\t\tecrecover).\n\tMustFunction(`Compute the sha256 hash of input`,\n\t\tleftPadAddress(2),\n\t\tpermission.None,\n\t\tsha256).\n\tMustFunction(`Compute the ripemd160 hash of input`,\n\t\tleftPadAddress(3),\n\t\tpermission.None,\n\t\tripemd160Func).\n\tMustFunction(`Return an output identical to the input`,\n\t\tleftPadAddress(4),\n\t\tpermission.None,\n\t\tidentity).\n\tMustFunction(`Compute the operation base**exp % mod where the values are big ints`,\n\t\tleftPadAddress(5),\n\t\tpermission.None,\n\t\texpMod).\n\tMustFunction(`Compute the keccak256 hash of input`,\n\t\tleftPadAddress(20),\n\t\tpermission.None,\n\t\tkeccak256Func)\n```\n\n## Types\n\n```go\ntype Context struct {\n\tState engine.State\n\tengine.CallParams\n\n\tLogger *logging.Logger\n\t// contains filtered or unexported fields\n}\n```\nContext is the first argument to any native function. This struct carries all the context an native needs to access e.g. state in burrow.\n\n```go\ntype Contract struct {\n\t// Comment describing purpose of native contract and reason for assembling\n\t// the particular functions\n\tComment string\n\t// Name of the native contract\n\tName string\n\t// contains filtered or unexported fields\n}\n```\nContract is metadata for native contract. Acts as a call target from the EVM. Can be used to generate bindings in a smart contract languages.\n\n```go\nfunc NewContract(name string, comment string, logger *logging.Logger, fs ...Function) (*Contract, error)\n```\nCreate a new native contract description object by passing a comment, name and a list of member functions descriptions\n\n```go\nfunc (c *Contract) Address() crypto.Address\n```\nWe define the address of an native contact as the last 20 bytes of the sha3 hash of its name\n\n```go\nfunc (c *Contract) Call(state engine.State, params engine.CallParams) (output []byte, err error)\n```\nDispatch is designed to be called from the EVM once a native contract has been selected.\n\n```go\nfunc (c *Contract) ContractMeta() []*acm.ContractMeta\n```\n\n```go\nfunc (c *Contract) FullName() string\n```\n\n```go\nfunc (c *Contract) FunctionByID(id abi.FunctionID) (*Function, errors.CodedError)\n```\nGet function by calling identifier FunctionSelector\n\n```go\nfunc (c *Contract) FunctionByName(name string) *Function\n```\nGet function by name\n\n```go\nfunc (c *Contract) Functions() []*Function\n```\nGet functions in order of declaration\n\n```go\nfunc (c *Contract) SetExternals(externals engine.Dispatcher)\n```\n\n```go\ntype Function struct {\n\t// Comment describing function's purpose, parameters, and return value\n\tComment string\n\t// Permissions required to call function\n\tPermFlag permission.PermFlag\n\t// Whether this function writes to state\n\tPure bool\n\t// Native function to which calls will be dispatched when a containing\n\tF interface{}\n\t// contains filtered or unexported fields\n}\n```\nFunction is metadata for native functions. Act as call targets for the EVM when collected into an Contract. Can be used to generate bindings in a smart contract languages.\n\n```go\nfunc NewFunction(comment string, address crypto.Address, permFlag permission.PermFlag, f interface{}) (*Function, error)\n```\nCreated a new function mounted directly at address (i.e. no Solidity contract or function selection)\n\n```go\nfunc (f *Function) Abi() *abi.FunctionSpec\n```\nAbi returns the FunctionSpec for this function\n\n```go\nfunc (f *Function) Address() crypto.Address\n```\n\n```go\nfunc (f *Function) Call(state engine.State, params engine.CallParams) ([]byte, error)\n```\n\n```go\nfunc (f *Function) ContractMeta() []*acm.ContractMeta\n```\n\n```go\nfunc (f *Function) FullName() string\n```\n\n```go\nfunc (f *Function) NArgs() int\n```\nNArgs returns the number of function arguments\n\n```go\nfunc (f *Function) Name() string\n```\nFor templates\n\n```go\nfunc (f *Function) SetExternals(externals engine.Dispatcher)\n```\n\n```go\nfunc (f *Function) Signature() string\n```\nSignature returns the function signature as would be used for ABI hashing\n\n```go\nfunc (f *Function) String() string\n```\n\n```go\ntype Natives struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc DefaultNatives() (*Natives, error)\n```\n\n```go\nfunc Merge(nss ...*Natives) (*Natives, error)\n```\n\n```go\nfunc MustDefaultNatives() *Natives\n```\n\n```go\nfunc New() *Natives\n```\n\n```go\nfunc (ns *Natives) Callables() []engine.Callable\n```\n\n```go\nfunc (ns *Natives) Contract(name, comment string, functions ...Function) (*Natives, error)\n```\n\n```go\nfunc (ns *Natives) Dispatch(acc *acm.Account) engine.Callable\n```\n\n```go\nfunc (ns *Natives) Function(comment string, address crypto.Address, permFlag permission.PermFlag, f interface{}) (*Natives, error)\n```\n\n```go\nfunc (ns *Natives) GetByAddress(address crypto.Address) engine.Native\n```\n\n```go\nfunc (ns *Natives) GetByName(name string) engine.Native\n```\n\n```go\nfunc (ns *Natives) GetContract(name string) *Contract\n```\n\n```go\nfunc (ns *Natives) GetFunction(name string) *Function\n```\n\n```go\nfunc (ns *Natives) IsRegistered(address crypto.Address) bool\n```\n\n```go\nfunc (ns *Natives) MustContract(name, comment string, functions ...Function) *Natives\n```\n\n```go\nfunc (ns *Natives) MustFunction(comment string, address crypto.Address, permFlag permission.PermFlag, f interface{}) *Natives\n```\n\n```go\nfunc (ns *Natives) SetExternals(externals engine.Dispatcher)\n```\n\n```go\nfunc (ns *Natives) WithLogger(logger *logging.Logger) *Natives\n```\n\n```go\ntype State struct {\n\t// contains filtered or unexported fields\n}\n```\nThis wrapper provides a state that behaves 'as if' the natives were stored directly in state. TODO: we may want to actually store native account sentinel values (and their metadata) in on-disk state down the line\n\n```go\nfunc NewState(natives engine.Natives, backend acmstate.ReaderWriter) *State\n```\nGet a new state that wraps the backend but intercepts any calls to natives returning appropriate errors message or an Account sentinel for the particular native\n\n```go\nfunc (s *State) GetAccount(address crypto.Address) (*acm.Account, error)\n```\n\n```go\nfunc (s *State) GetStorage(address crypto.Address, key binary.Word256) ([]byte, error)\n```\n\n```go\nfunc (s *State) RemoveAccount(address crypto.Address) error\n```\n\n```go\nfunc (s *State) SetStorage(address crypto.Address, key binary.Word256, value []byte) error\n```\n\n```go\nfunc (s *State) UpdateAccount(updatedAccount *acm.Account) error\n```\n\n","path":"github.com/hyperledger/burrow/execution/native","name":"native","synopsis":"","isRedistributable":true}
