https://developers.minepi.com/doc/javascript
Ejemplo:
https://github.com/rockcesar/PiNetworkDevelopments/tree/master/PiDevelopment_test1
Ejemplo en HTML:
<html>
<head>
<script type="text/javascript" src="jquery-3.5.1.min.js"></script>
<!--<script src="https://downloads.minepi.com/sdk/v1/dev.js"></script>-->
<script src="https://downloads.minepi.com/sdk/v1/prod.js"></script>
</head>
<body>
<input id="pi_donate" name="pi_donate" type="text" />
<input id="button_click" name="button_click" value="Donate" type="button"/>
<script type="text/javascript">
$( document ).ready(function() {
PiNetworkClient = window.PiNetwork;
//alert(PiNetworkClient);
async function auth() {
try {
const user = await PiNetworkClient.Authenticate();
alert('Hello ' + user.username);
$( "#button_click" ).click(function() {
transfer();
//alert("Click");
});
} catch (err) {
alert(err);
// Not able to fetch the user
}
}
async function transfer() {
try {
const transferRequest = await PiNetworkClient.RequestTransfer(parseFloat($("#pi_donate").text()), "Demo transfer request");
alert(transferRequest.status);
} catch(err) {
alert(err);
// Technical problem (eg network failure). Please try again
}
}
auth();
});
</script>
</body> </html>
No hay comentarios:
Publicar un comentario