Search code examples
blockchaincorda

Front end of the notary in cordapp-samples


I want to set up the UI for the notary in cordApp samples. As the notary's Web port is not configured by default,I am trying to change the client's Gradle file to configure the notary.

Is there any other way to configure the notary's UI ?

I checked,It can be seen through the Node Explorer.Is there any other way to check the notary on web front?


Solution

  • You can configure the notary's webport in a similar way as you would configure for any other node. Your notary must have an RPC address configured. Once you have an rpc address configured, you can either use the default corda webserver (which is now deprecated) or you must configure your own webserver or use spring-webserver). Without specifying the web port you can define your spring boot server, and connect to the node via RPC.

    Step 1 Define your Spring boot server

    @SpringBootApplication
    private open class Starter
    
        /**
         * Starts our Spring Boot application.
         */
        fun main(args: Array<String>) {
            val app = SpringApplication(Starter::class.java)
            app.setBannerMode(Banner.Mode.OFF)
            app.isWebEnvironment = true
            app.run(*args)
        }
    

    Step 2 Start your server by defining a starter task in your gradle build file

    task runPartyAServer(type: JavaExec) {
        classpath = sourceSets.main.runtimeClasspath
        main = 'net.corda.server.ServerKt'
    }
    

    Step 3 Define the rpc configuration used to connect to the node.

    server.port=10055
    config.rpc.username=user1
    config.rpc.password=test
    config.rpc.host=localhost
    config.rpc.port=10008
    

    Step 4 Connect to the node using the above config defined.

     val rpcAddress = NetworkHostAndPort(host, rpcPort)
     val rpcClient = CordaRPCClient(rpcAddress)
     val rpcConnection = rpcClient.start(username, password)
     proxy = rpcConnection.proxy
    

    Step 5 Use the proxy to connect to the notary node.

    You can refer to the complete code here.