bdcontract-sdk-javascript/test/ws.html

52 lines
1.3 KiB
HTML
Raw Normal View History

2023-03-14 17:15:57 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<script src="./sm2.js"></script>
<script src="./cryptico.iife.js"></script>
<script src="../lib/index.js"></script>
<script>
function print(string) {
document.write(`${string}\n\n`)
}
const url = 'ws://39.104.201.40:18010/SCIDE/SCExecutor'
const client = new bdcontract.WsClient(
url,
(ev) => {
console.log(JSON.stringify(ev))
},
(ev, ws) => {
console.log(ev.data)
},
)
setTimeout(async () => {
const status = client.status()
console.log(status)
try {
let data = await client.executeContract(
'AnnotationExample0608',
'main',
'abacd',
)
print(JSON.stringify(data))
data = await client.executeContract(
'NonExistentContract',
'random',
'abacd',
)
print(JSON.stringify(data))
} catch (data) {
print(JSON.stringify(data))
}
}, 1000)
</script>
<link rel="icon" type="image/svg+xml" href="favicon.svg"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Vite App</title>
</head>
<body></body>
</html>