<dependency> <groupId>io.github.quintystyle.ethjdbc</groupId> <artifactId>eth-jdbc-driver</artifactId> <version>1.0.0</version> </dependency> groovy implementation 'io.github.quintystyle.ethjdbc:eth-jdbc-driver:1.0.0' import io.github.quintystyle.ethjdbc.EthereumJdbcDriver; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; EthereumJdbcDriver.register(); String url = "jdbc:ethereum://localhost:8545"; String user = "your_username"; String password = "your_password"; try (Connection conn = DriverManager.getConnection(url, user, password)) { } catch (SQLException e) { e.printStackTrace(); } import io.github.quintystyle.ethjdbc.EthereumConnection; import io.github.quintystyle.ethjdbc.contracts.Contract; import io.github.quintystyle.ethjdbc.results.ExecutionResult; try (EthereumConnection ethConnection = conn.unwrap(EthereumConnection.class)) { Contract contract = new Contract(ethConnection, "0xCfEB869F69431e42cdB54A4F4f105C19C080A601"); ExecutionResult executionResult = contract.callFunction("balanceOf", "0x1234567890abcdef"); if (executionResult.isSuccessful()) { String balance = executionResult.getOutput().getString(0); } else { } } catch (SQLException e) { e.printStackTrace(); }


上一篇:
下一篇:
切换中文