这是indexloc提供的服务,不要输入任何密码
Skip to content

Sui doc content issue or request #22869

@asher-gh

Description

@asher-gh

I'm going through the Weather Oracle example, and the explanation doesn't match with the code sample in the Weather Oracle Module.

fun init(otw: WEATHER, ctx: &mut TxContext) {
    package::claim_and_keep(otw, ctx); // Claim ownership of the one-time witness and keep it

    let cap = AdminCap { id: object::new(ctx) }; // Create a new admin capability object
    transfer::share_object(WeatherOracle {
        id: object::new(ctx),
        address: ctx.sender(),
        name: b"SuiMeteo".to_string(),
        description: b"A weather oracle.".to_string(),
    });
    transfer::public_transfer(cap, ctx.sender()); // Transfer the admin capability to the sender.
}
  • The init function creates and sends the Publisher and AdminCap objects to the sender.

Is the Publisher capability implicitly passed to the sender? Or does it have to transferred with something like:

  let pub_cap = package::claim_and_keep(otw, ctx);
  transfer::public_transfer(pub_cap, ctx.sender());

Metadata

Metadata

Assignees

Labels

doc-issueIssue submitted using the Doc issue template

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions