Documentation ¶
Overview ¶
Package policy allows to work with the native PolicyContract contract via RPC.
Safe methods are encapsulated into ContractReader structure while Contract provides various methods to perform PolicyContract state-changing calls.
Index ¶
- Variables
- type Actor
- type Contract
- func (c *Contract) BlockAccount(account util.Uint160) (util.Uint256, uint32, error)
- func (c *Contract) BlockAccountTransaction(account util.Uint160) (*transaction.Transaction, error)
- func (c *Contract) BlockAccountUnsigned(account util.Uint160) (*transaction.Transaction, error)
- func (c *Contract) SetAttributeFee(t transaction.AttrType, value int64) (util.Uint256, uint32, error)
- func (c *Contract) SetAttributeFeeTransaction(t transaction.AttrType, value int64) (*transaction.Transaction, error)
- func (c *Contract) SetAttributeFeeUnsigned(t transaction.AttrType, value int64) (*transaction.Transaction, error)
- func (c *Contract) SetExecFeeFactor(value int64) (util.Uint256, uint32, error)
- func (c *Contract) SetExecFeeFactorTransaction(value int64) (*transaction.Transaction, error)
- func (c *Contract) SetExecFeeFactorUnsigned(value int64) (*transaction.Transaction, error)
- func (c *Contract) SetFeePerByte(value int64) (util.Uint256, uint32, error)
- func (c *Contract) SetFeePerByteTransaction(value int64) (*transaction.Transaction, error)
- func (c *Contract) SetFeePerByteUnsigned(value int64) (*transaction.Transaction, error)
- func (c *Contract) SetStoragePrice(value int64) (util.Uint256, uint32, error)
- func (c *Contract) SetStoragePriceTransaction(value int64) (*transaction.Transaction, error)
- func (c *Contract) SetStoragePriceUnsigned(value int64) (*transaction.Transaction, error)
- func (c *Contract) UnblockAccount(account util.Uint160) (util.Uint256, uint32, error)
- func (c *Contract) UnblockAccountTransaction(account util.Uint160) (*transaction.Transaction, error)
- func (c *Contract) UnblockAccountUnsigned(account util.Uint160) (*transaction.Transaction, error)
- type ContractReader
- func (c *ContractReader) GetAttributeFee(t transaction.AttrType) (int64, error)
- func (c *ContractReader) GetExecFeeFactor() (int64, error)
- func (c *ContractReader) GetFeePerByte() (int64, error)
- func (c *ContractReader) GetStoragePrice() (int64, error)
- func (c *ContractReader) IsBlocked(account util.Uint160) (bool, error)
- type Invoker
Constants ¶
This section is empty.
Variables ¶
var Hash = state.CreateNativeContractHash(nativenames.Policy)
Hash stores the hash of the native PolicyContract contract.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor interface { Invoker MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error) MakeRun(script []byte) (*transaction.Transaction, error) MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error) MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error) SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error) SendRun(script []byte) (util.Uint256, uint32, error) }
Actor is used by Contract to create and send transactions.
type Contract ¶
type Contract struct { ContractReader // contains filtered or unexported fields }
Contract represents a PolicyContract contract client that can be used to invoke all of its methods.
func New ¶
New creates an instance of Contract to perform actions using the given Actor. Notice that PolicyContract's state can be changed only by the network's committee, so the Actor provided must be a committee actor for all methods to work properly.
func (*Contract) BlockAccount ¶
BlockAccount creates and sends a transaction that blocks an account on the network (via `blockAccount` method), it fails (with FAULT state) if it's not successful. The returned values are transaction hash, its ValidUntilBlock value and an error if any.
func (*Contract) BlockAccountTransaction ¶
func (c *Contract) BlockAccountTransaction(account util.Uint160) (*transaction.Transaction, error)
BlockAccountTransaction creates a transaction that blocks an account on the network and checks for the result of the appropriate call, failing the transaction if it's not true. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) BlockAccountUnsigned ¶
func (c *Contract) BlockAccountUnsigned(account util.Uint160) (*transaction.Transaction, error)
BlockAccountUnsigned creates a transaction that blocks an account on the network and checks for the result of the appropriate call, failing the transaction if it's not true. This transaction is not signed and just returned to the caller.
func (*Contract) SetAttributeFee ¶ added in v0.104.0
func (c *Contract) SetAttributeFee(t transaction.AttrType, value int64) (util.Uint256, uint32, error)
SetAttributeFee creates and sends a transaction that sets the new attribute fee value for the specified attribute. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.
func (*Contract) SetAttributeFeeTransaction ¶ added in v0.104.0
func (c *Contract) SetAttributeFeeTransaction(t transaction.AttrType, value int64) (*transaction.Transaction, error)
SetAttributeFeeTransaction creates a transaction that sets the new attribute fee value for the specified attribute. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) SetAttributeFeeUnsigned ¶ added in v0.104.0
func (c *Contract) SetAttributeFeeUnsigned(t transaction.AttrType, value int64) (*transaction.Transaction, error)
SetAttributeFeeUnsigned creates a transaction that sets the new attribute fee value for the specified attribute. This transaction is not signed and just returned to the caller.
func (*Contract) SetExecFeeFactor ¶
SetExecFeeFactor creates and sends a transaction that sets the new execution fee factor for the network to use. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.
func (*Contract) SetExecFeeFactorTransaction ¶
func (c *Contract) SetExecFeeFactorTransaction(value int64) (*transaction.Transaction, error)
SetExecFeeFactorTransaction creates a transaction that sets the new execution fee factor. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) SetExecFeeFactorUnsigned ¶
func (c *Contract) SetExecFeeFactorUnsigned(value int64) (*transaction.Transaction, error)
SetExecFeeFactorUnsigned creates a transaction that sets the new execution fee factor. This transaction is not signed and just returned to the caller.
func (*Contract) SetFeePerByte ¶
SetFeePerByte creates and sends a transaction that sets the new minimal per-byte network fee value. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.
func (*Contract) SetFeePerByteTransaction ¶
func (c *Contract) SetFeePerByteTransaction(value int64) (*transaction.Transaction, error)
SetFeePerByteTransaction creates a transaction that sets the new minimal per-byte network fee value. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) SetFeePerByteUnsigned ¶
func (c *Contract) SetFeePerByteUnsigned(value int64) (*transaction.Transaction, error)
SetFeePerByteUnsigned creates a transaction that sets the new minimal per-byte network fee value. This transaction is not signed and just returned to the caller.
func (*Contract) SetStoragePrice ¶
SetStoragePrice creates and sends a transaction that sets the storage price for contracts. The action is successful when transaction ends in HALT state. The returned values are transaction hash, its ValidUntilBlock value and an error if any.
func (*Contract) SetStoragePriceTransaction ¶
func (c *Contract) SetStoragePriceTransaction(value int64) (*transaction.Transaction, error)
SetStoragePriceTransaction creates a transaction that sets the storage price for contracts. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) SetStoragePriceUnsigned ¶
func (c *Contract) SetStoragePriceUnsigned(value int64) (*transaction.Transaction, error)
SetStoragePriceUnsigned creates a transaction that sets the storage price for contracts. This transaction is not signed and just returned to the caller.
func (*Contract) UnblockAccount ¶
UnblockAccount creates and sends a transaction that removes previously blocked account from the stop list. It uses `unblockAccount` method and checks for the result returned, failing the transaction if it's not true. The returned values are transaction hash, its ValidUntilBlock value and an error if any.
func (*Contract) UnblockAccountTransaction ¶
func (c *Contract) UnblockAccountTransaction(account util.Uint160) (*transaction.Transaction, error)
UnblockAccountTransaction creates a transaction that unblocks previously blocked account via `unblockAccount` method and checks for the result returned, failing the transaction if it's not true. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) UnblockAccountUnsigned ¶
func (c *Contract) UnblockAccountUnsigned(account util.Uint160) (*transaction.Transaction, error)
UnblockAccountUnsigned creates a transaction that unblocks the given account if it was blocked previously. It uses `unblockAccount` method and checks for its return value, failing the transaction if it's not true. This transaction is not signed and just returned to the caller.
type ContractReader ¶
type ContractReader struct {
// contains filtered or unexported fields
}
ContractReader provides an interface to call read-only PolicyContract contract's methods.
func NewReader ¶
func NewReader(invoker Invoker) *ContractReader
NewReader creates an instance of ContractReader that can be used to read data from the contract.
func (*ContractReader) GetAttributeFee ¶ added in v0.104.0
func (c *ContractReader) GetAttributeFee(t transaction.AttrType) (int64, error)
GetAttributeFee returns current fee for the specified attribute usage. Any contract saving data to the storage pays for it according to this value.
func (*ContractReader) GetExecFeeFactor ¶
func (c *ContractReader) GetExecFeeFactor() (int64, error)
GetExecFeeFactor returns current execution fee factor used by the network. This setting affects all executions of all transactions.
func (*ContractReader) GetFeePerByte ¶
func (c *ContractReader) GetFeePerByte() (int64, error)
GetFeePerByte returns current minimal per-byte network fee value which affects all transactions on the network.
func (*ContractReader) GetStoragePrice ¶
func (c *ContractReader) GetStoragePrice() (int64, error)
GetStoragePrice returns current per-byte storage price. Any contract saving data to the storage pays for it according to this value.