Skip to content

Commit

Permalink
deploy contract under evm account
Browse files Browse the repository at this point in the history
  • Loading branch information
ramtinms committed Oct 25, 2023
1 parent f7b18dd commit 9e88e95
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion fvm/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/onflow/flow-go/fvm/blueprints"
"github.com/onflow/flow-go/fvm/environment"
"github.com/onflow/flow-go/fvm/errors"
"github.com/onflow/flow-go/fvm/evm/stdlib"
"github.com/onflow/flow-go/fvm/meter"
"github.com/onflow/flow-go/fvm/storage"
"github.com/onflow/flow-go/fvm/storage/logical"
Expand Down Expand Up @@ -782,7 +783,17 @@ func (b *bootstrapExecutor) setStakingAllowlist(
func (b *bootstrapExecutor) setupEVM() {
// setup EVM root account
// TODO: maybe we reuse the service account key here
b.createAccount(nil)
addr := b.createAccount(nil)
tx := blueprints.DeployContractTransaction(
addr,
stdlib.ContractContent(),
stdlib.ContractName(),
)
txError, err := b.invokeMetaTransaction(
b.ctx,
Transaction(tx, 0),
)
panicOnMetaInvokeErrf("failed to deploy EVM contract: %s", txError, err)
}

func (b *bootstrapExecutor) registerNodes(service, fungibleToken, flowToken flow.Address) {
Expand Down
1 change: 1 addition & 0 deletions fvm/evm/stdlib/contract.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub contract EVM {}
14 changes: 14 additions & 0 deletions fvm/evm/stdlib/contract.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package stdlib

import _ "embed"

//go:embed contract.cdc
var contractContent string

func ContractName() string {
return "EVM"
}

func ContractContent() []byte {
return []byte(contractContent)
}

0 comments on commit 9e88e95

Please sign in to comment.