Skip to content

Latest commit

 

History

History
82 lines (61 loc) · 2.41 KB

polycli_wrap-contract.md

File metadata and controls

82 lines (61 loc) · 2.41 KB

polycli wrap-contract

Auto-generated documentation.

Table of Contents

Description

Wrap deployed bytecode into create bytecode.

polycli wrap-contract bytecode|file [flags]

Usage

This command takes the runtime bytecode, the bytecode deployed on-chain, as input and converts it into creation bytecode, the bytecode used to create the contract

$ polycli wrap-contract 69602a60005260206000f3600052600a6016f3
$ echo 69602a60005260206000f3600052600a6016f3 | polycli wrap-contract 

You can also provide a path to a file, and the bytecode while be read from there.

$ polycli wrap-contract bytecode.txt
$ polycli wrap-contract ../bytecode.txt
$ polycli wrap-contract /tmp/bytecode.txt
$ echo /tmp/bytecode.txt | polycli wrap-contract

Additionally, you can provide storage for the contract in JSON

$ polycli wrap-contract 0x4455 --storage '{"0x01":"0x0034"}'
$ polycli wrap-contract 0x4455 --storage '{"0x01":"0x0034", "0x02": "0xFF"}'
$ echo 69602a60005260206000f3600052600a6016f3 | polycli wrap-contract --storage '{"0x01":"0x0034", "0x02": "0xFF"}'

The resulting bytecode will be formatted this way:

	0x??   // storage initialization code if any
	63??   // PUSH4 to indicate the size of the data that should be copied into memory
	63??   // PUSH4 to indicate the offset in the call data to start the copy
	6000   // PUSH1 00 to indicate the destination offset in memory
	39     // CODECOPY
	63??   // PUSH4 to indicate the size of the data to be returned from memory
	6000   // PUSH1 00 to indicate that it starts from offset 0
	F3     // RETURN
	??,    // Deployed Bytecode

Flags

  -h, --help             help for wrap-contract
      --storage string   Provide storage slots in json format k:v

The command also inherits flags from parent commands.

      --config string   config file (default is $HOME/.polygon-cli.yaml)
      --pretty-logs     Should logs be in pretty format or JSON (default true)
  -v, --verbosity int   0 - Silent
                        100 Panic
                        200 Fatal
                        300 Error
                        400 Warning
                        500 Info
                        600 Debug
                        700 Trace (default 500)

See also

  • polycli - A Swiss Army knife of blockchain tools.