Skip to content

Commit

Permalink
add support to constructor arguments on deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
MCarlomagno committed Jul 8, 2024
1 parent bf73579 commit 9321e3c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,25 @@ type Chain struct {
kettleAddr common.Address
}

func (c *Chain) DeployContract(path string) *Contract {
func (c *Chain) DeployContract(path string, args ...interface{}) *Contract {
artifact, err := ReadArtifact(path)
if err != nil {
panic(err)
}

bytecode := artifact.Code

// add contructor arguments
if len(args) > 0 {
packedArgs, err := artifact.Abi.Pack("", args...)
if err != nil {
panic(err)
}
bytecode = append(bytecode, packedArgs...)
}

// deploy contract
txnResult, err := sdk.DeployContract(artifact.Code, c.clt)
txnResult, err := sdk.DeployContract(bytecode, c.clt)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 9321e3c

Please sign in to comment.