The Init actor plays an important role as the ONLY actor able to create other actors. Specifically, the Init actor must be used to create any of the following Instanced actors:
Note that the Account actor, which is also Instanced, is not created explicitly through the Init actor's Exec method. Instead, Account actors are created implicitly whenever a top-level message invokes a method on an actor that does not exist yet.
Actor Type:
Exported Methods:
type State struct {
AddressMap cid.Cid
NextID abi.ActorID
NetworkName string
}
AddressMap
: Often referred to as the "Init actor's table". Maintains a reference of all actors created via the Init actor, as well as all created Account actors.
map[Address]ActorID
NextID
: The ActorID that will be assigned to the next created actor.
NextID
.NextID
is incremented by 1.NextID >= 100
(see builtin.FirstNonSingletonActorId
)NetworkName
: Arbitrary network name value. Actual value TBD.
func (a Actor) Constructor(rt runtime.Runtime, params *ConstructorParams) *adt.EmptyValue
The Init constructor initializes State
with the actor's NetworkName
, and sets st.NextID
to 100. New actors will be assigned sequential ID addresses, starting with this value.
type ConstructorParams struct {
NetworkName string
}
NetworkName
: Arbitrary network name value. Actual value TBD.
func (a Actor) Exec(rt runtime.Runtime, params *ExecParams) *ExecReturn
Used to create new actors.
rt.NewActorAddress()
Message().ValueReceived()
type ExecParams struct {
CodeCID cid.Cid
ConstructorParams []byte
}
CodeCID
: The CID of the code the Caller wishes to instantiate
builtin/codes.go
.CodeCID
refers to the Miner actor, Caller must be the Power actor.CodeCID
refers to the PaymentChannel or Multisig actors, no requirements exist.CodeCID
is any other value, method will fail.ConstructorParams
: The parameters that will be sent to the created actor's Constructor.
type ExecReturn struct {
IDAddress addr.Address
RobustAddress addr.Address
}
IDAddress
: The newly-created actor's ID address.
st.NextID
RobustAddress
: The newly-created actor's ACTOR address.
rt.NewActorAddress()
rt.GetActorCodeCID(Caller)
fails)or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing