@@ -186,6 +186,17 @@ func run(cmd *cobra.Command, args []string) {
186186 inputBoxBlockNumber = block .Uint64 ()
187187 }
188188
189+ // ensure there is a contract deployed at the input box address
190+ hasCode , err := hasCodeAt (ctx , * inputBoxAddress )
191+ if err != nil {
192+ fmt .Fprintf (os .Stderr , "failed to probe input box address for contract: %v\n " , err )
193+ os .Exit (1 )
194+ }
195+ if ! hasCode {
196+ fmt .Fprintf (os .Stderr , "input box address has no code: %v\n " , consensus )
197+ os .Exit (1 )
198+ }
199+
189200 application := model.Application {
190201 Name : validName ,
191202 IApplicationAddress : address ,
@@ -229,6 +240,25 @@ func getTemplateHash(
229240 return ethutil .GetTemplateHash (ctx , client , appAddress )
230241}
231242
243+ func hasCodeAt (
244+ ctx context.Context ,
245+ consensusAddress common.Address ,
246+ ) (bool , error ) {
247+ ethEndpoint , err := config .GetBlockchainHttpEndpoint ()
248+ if err != nil {
249+ return false , fmt .Errorf ("failed to get blockchain http endpoint address: %w" , err )
250+ }
251+ client , err := ethclient .Dial (ethEndpoint .String ())
252+ if err != nil {
253+ return false , fmt .Errorf ("failed to connect to the blockchain http endpoint: %s" , ethEndpoint .Redacted ())
254+ }
255+ bytes , err := client .CodeAt (ctx , consensusAddress , nil )
256+ if err != nil {
257+ return false , fmt .Errorf ("failed to retrieve code at consensus address: %s" , consensusAddress )
258+ }
259+ return len (bytes ) != 0 , nil
260+ }
261+
232262func getConsensus (
233263 ctx context.Context ,
234264 appAddress common.Address ,
0 commit comments