99 "github.com/onflow/flow-core-contracts/lib/go/templates"
1010
1111 usdc "github.com/onflow/bridged-usdc/lib/go/contracts"
12+ bridge "github.com/onflow/flow-evm-bridge"
1213 storefront "github.com/onflow/nft-storefront/lib/go/contracts"
1314
1415 "github.com/onflow/flow-go/fvm/accountV2Migration"
@@ -446,7 +447,8 @@ func (b *bootstrapExecutor) Execute() error {
446447 b .deployStakingCollection (service , & env )
447448
448449 // sets up the EVM environment
449- b .setupEVM (service , nonFungibleToken , fungibleToken , flowToken )
450+ b .setupEVM (service , nonFungibleToken , fungibleToken , flowToken , & env )
451+ b .setupVMBridge (service , & env )
450452
451453 err = expectAccounts (systemcontracts .EVMStorageAccountIndex )
452454 if err != nil {
@@ -978,7 +980,7 @@ func (b *bootstrapExecutor) setStakingAllowlist(
978980 panicOnMetaInvokeErrf ("failed to set staking allow-list: %s" , txError , err )
979981}
980982
981- func (b * bootstrapExecutor ) setupEVM (serviceAddress , nonFungibleTokenAddress , fungibleTokenAddress , flowTokenAddress flow.Address ) {
983+ func (b * bootstrapExecutor ) setupEVM (serviceAddress , nonFungibleTokenAddress , fungibleTokenAddress , flowTokenAddress flow.Address , env * templates. Environment ) {
982984 if b .setupEVMEnabled {
983985 // account for storage
984986 // we dont need to deploy anything to this account, but it needs to exist
@@ -998,6 +1000,38 @@ func (b *bootstrapExecutor) setupEVM(serviceAddress, nonFungibleTokenAddress, fu
9981000 Transaction (tx , 0 ),
9991001 )
10001002 panicOnMetaInvokeErrf ("failed to deploy EVM contract: %s" , txError , err )
1003+
1004+ env .EVMAddress = env .ServiceAccountAddress
1005+ }
1006+ }
1007+
1008+ func (b * bootstrapExecutor ) setupVMBridge (serviceAddress flow.Address , env * templates.Environment ) {
1009+ if b .setupEVMEnabled {
1010+
1011+ bridgeEnv := bridge.Environment {}
1012+
1013+ // Create a COA in the bridge account
1014+ tx := blueprints .CreateCOATransaction (serviceAddress , bridgeEnv , * env )
1015+ txError , err := b .invokeMetaTransaction (
1016+ NewContextFromParent (b .ctx , WithEVMEnabled (true )),
1017+ Transaction (tx , 0 ),
1018+ )
1019+ panicOnMetaInvokeErrf ("failed to create COA in Service Account: %s" , txError , err )
1020+
1021+ gasLimit := 15000000
1022+ deploymentValue := 0.0
1023+
1024+ // Retrieve the factory bytecode from the JSON args
1025+ factoryBytecode := bridge .GetBytecodeFromArgsJSON ("cadence/args/deploy-factory-args.json" )
1026+
1027+ // deploy the Solidity Factory contract to the service account's COA
1028+ tx = blueprints .DeployEVMContractTransaction (serviceAddress , factoryBytecode , gasLimit , deploymentValue , bridgeEnv , * env )
1029+
1030+ txError , err = b .invokeMetaTransaction (
1031+ NewContextFromParent (b .ctx , WithEVMEnabled (true )),
1032+ Transaction (tx , 0 ),
1033+ )
1034+ panicOnMetaInvokeErrf ("failed to deploy the Factory in the Service Account COA: %s" , txError , err )
10011035 }
10021036}
10031037
0 commit comments