-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (52 loc) · 2.46 KB
/
Program.cs
File metadata and controls
58 lines (52 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Nethereum.Hex.HexConvertors.Extensions;
using System.Numerics;
using Nethereum.Signer;
using Newtonsoft.Json;
namespace NethereumSample
{
class Program
{
static async Task Main(string[] args)
{
var privateKey = Environment.GetEnvironmentVariable("PRIVATE_KEY");
if (privateKey == null)
{
throw new Exception("PRIVATE_KEY is not defined");
}
var order = new Order
{
marketHash = "0x78d2b90f2b585ead37b34005997f551e3f7de26b194b09322f0df6e5246b6f86",
baseToken = "0x6A383cf1F8897585718DCA629a8f1471339abFe4",
totalBetSize = BigInteger.Parse("1000000000000000000000"),
percentageOdds = BigInteger.Parse("51302654005356720000"),
maker = new EthECKey(privateKey).GetPublicAddress(),
executor = "0x3259E7Ccc0993368fCB82689F5C534669A0C06ca",
isMakerBettingOutcomeOne = true,
apiExpiry = DateTimeOffset.Now.AddSeconds(1000).ToUnixTimeSeconds(),
salt = Order.Random32Bytes()
};
Console.WriteLine("Order hash: " + order.GetHash().ToHex(true));
Console.WriteLine("Order signature: " + order.GetSignature(privateKey));
var api = new SportXAPI { url = "https://mumbai.api.sportx.bet" };
var newOrderResult = await api.PostNewOrder(order.GetSignedOrder(privateKey));
Console.WriteLine("New order result: " + newOrderResult);
var deserialized = JsonConvert.DeserializeAnonymousType(
newOrderResult,
new { status = default(string), data = new { orders = default(string[]) } }
);
Console.WriteLine("Deserialized new order result: " + deserialized);
var cancelSignature = await Order.GetCancelSignature(
deserialized.data.orders,
privateKey,
80001 // use 137 if mainnet. 80001 = mumbai testnet, 137 = polygon mainnet
);
Console.WriteLine("Cancel signature: " + cancelSignature);
var cancelOrderResult = await api.CancelOrder(
deserialized.data.orders,
"Are you sure you want to cancel these orders",
cancelSignature
);
Console.WriteLine("Cancel API call result: " + cancelOrderResult);
}
}
}