- decodeTag
- decryptResult
- encodeTag
- formatEth
- formatRLC
- getSignerFromPrivateKey
- parseEth
- parseRLC
- sumTags
• Const
NULL_ADDRESS: string
ethereum null/zero address
• Const
NULL_BYTES32: string
null bytes32
▸ decodeTag(tag
): string
[]
decode a bytes32 tag in an array of human readable tags
example:
console.log(decodeTag('0x0000000000000000000000000000000000000000000000000000000000000001'));
Name | Type |
---|---|
tag |
string |
string
[]
▸ decryptResult(encrypted
, beneficiaryKey
): Promise
<Buffer
>
decrypt an encrypted result file
example:
// somehow load the beneficiary RSA private key
const beneficaryKey = await loadBeneficiaryKey();
const response = await iexec.task.fetchResults('0x5c959fd2e9ea2d5bdb965d7c2e7271c9cb91dd05b7bdcfa8204c34c52f8c8c19');
const encFileBuffer = await response.arrayBuffer();
const decryptedFileBuffer = await decryptResult(encFileBuffer, beneficaryKey);
const binary = new Blob([decryptedFileBuffer]);
Name | Type |
---|---|
encrypted |
string | ArrayBuffer | Uint8Array | Buffer |
beneficiaryKey |
string | ArrayBuffer | Uint8Array | Buffer |
Promise
<Buffer
>
▸ encodeTag(tags
): string
encode an array of human readable tags in a bytes32 tag readable by iExec's smart contracts
example:
console.log(encodeTag(['tee', 'gpu']));
Name | Type |
---|---|
tags |
string [] |
string
▸ formatEth(wei
): string
format a wei amount in Eth
example:
console.log('500000000 wei =' + formatEth('500000000')) + 'ether');
Name | Type |
---|---|
wei |
WeiAmount |
string
▸ formatRLC(nRLC
): string
format a nRLC amount in RLC
- example:
console.log('500000000 nRLC =' + formatRLC('500000000') + 'RLC');
Name | Type |
---|---|
nRLC |
NRLCAmount |
string
▸ getSignerFromPrivateKey(host
, privateKey
, options?
): EnhancedWallet
create a signer connected to the specified blockchain host from a private key
example:
const ethProvider = getSignerFromPrivateKey('http://localhost:8545', '0x564a9db84969c8159f7aa3d5393c5ecd014fce6a375842a45b12af6677b12407');
const iexec = new IExec({ ethProvider });
Name | Type | Description |
---|---|---|
host |
string |
- |
privateKey |
string |
- |
options? |
Object |
- |
options.gasPrice? |
string |
gas price override |
options.providers |
ProviderOptions |
providers options |
options.getTransactionCount? |
(blockTag? : BlockTag ) => Promise <number > |
- |
▸ parseEth(value
, defaultUnit?
): BN
parse a string formatted Eht value in wei big number
supported units: 'wei', 'kwei', 'mwei', 'gwei', 'szabo', 'finney', 'ether' (or 'eth') default unit 'wei'
example:
console.log('5 gwei =' + parseEth('5 gwei') + 'wei');
console.log('5 gwei =' + parseEth(5, 'gwei') + 'wei');
Name | Type |
---|---|
value |
string |
defaultUnit? |
string |
BN
▸ parseRLC(value
, defaultUnit?
): BN
parse a string formatted RLC value in nRLC big number
supported units: 'nRLC', 'RLC' default unit 'nRLC'
example:
console.log('5 RLC =' + parseEth('5 RLC') + 'nRLC');
console.log('5 RLC =' + parseEth(5, 'RLC') + 'nRLC');
Name | Type |
---|---|
value |
string |
defaultUnit? |
string |
BN
▸ sumTags(tags
): string
sum an array of bytes32 tags
example:
const appTag = '0x0000000000000000000000000000000000000000000000000000000000000100';
const datasetTag = '0x0000000000000000000000000000000000000000000000000000000000000001';
const requestTag = '0x0000000000000000000000000000000000000000000000000000000000000000';
const workerpoolMinTag = sumTags([appTag, datasetTag, requestTag]);
console.log('workerpoolMinTag', workerpoolMinTag);
Name | Type |
---|---|
tags |
string [] |
string