-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
967 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# CALL_AELF_CHAIN | ||
|
||
```javascript | ||
const txid = 'c45edfcca86f4f528cd8e30634fa4ac53801aae05365cfefc3bfe9b652fe5768'; | ||
aelf.chain.getTxResult(txid, (err, result) => { | ||
console.log('>>>>>>>>>>>>> getTxResult >>>>>>>>>>>>>'); | ||
console.log(err, result); | ||
}); | ||
|
||
// result = { | ||
// Status: "NotExisted" | ||
// TransactionId: "ff5bcd126f9b7f22bbfd0816324390776f10ccb3fe0690efc84c5fcf6bdd3fc6" | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# CALL_AELF_CONTRACT | ||
|
||
```javascript | ||
tokenContract.Transfer( | ||
{ | ||
symbol: 'ELF', | ||
to: '6WZNJgU5MHWsvzZmPpC7cW6g3qciniQhDKRLCvbQcTCcVFH', | ||
amount: 100 | ||
}, | ||
(err, result) => { | ||
console.log('>>>>>>>>>>>>>>>>>>>', result); | ||
} | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# CALL_AELF_CONTRACT_READONLY | ||
|
||
```javascript | ||
tokenContract.GetBalance.call( | ||
{ | ||
symbol: 'AELF', | ||
owner: '65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9' | ||
}, | ||
(err, result) => { | ||
console.log('>>>>>>>>>>>>>>>>>>>', result); | ||
} | ||
); | ||
|
||
// result = { | ||
// symbol: "AELF", | ||
// owner: "65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9", | ||
// balance: 0 | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# CHECK_PERMISSION / checkPermission | ||
|
||
```javascript | ||
aelf.checkPermission({ | ||
appName: 'test', | ||
type: 'address', // if you did not set type, it aways get by domain. | ||
address: '4WBgSL2fSem9ABD4LLZBpwP8eEymVSS1AyTBCqXjt5cfxXK' | ||
}, (error, result) => { | ||
console.log('checkPermission>>>>>>>>>>>>>>>>>', result); | ||
}); | ||
|
||
// result = { | ||
// ..., | ||
// permissions:[ | ||
// { | ||
// address: '...', | ||
// appName: 'test', | ||
// contracts: [{ | ||
// chainId: 'AELF', | ||
// contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', | ||
// contractName: 'token', | ||
// description: 'token contract', | ||
// github: '' | ||
// }, | ||
// { | ||
// chainId: 'AELF TEST', | ||
// contractAddress: 'TEST contractAddress', | ||
// contractName: 'TEST contractName', | ||
// description: 'contract description', | ||
// github: '' | ||
// }], | ||
// domian: 'Dapp domain' | ||
// } | ||
// ] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# INIT_AELF_CONTRACT / contractAtAsync | ||
|
||
```javascript | ||
// In aelf-sdk.js wallet is the realy wallet. | ||
// But in extension sdk, we just need the address of the wallet. | ||
const tokenContract; | ||
const wallet = { | ||
address: '2JqnxvDiMNzbSgme2oxpqUFpUYfMjTpNBGCLP2CsWjpbHdu' | ||
}; | ||
// It is different from the wallet created by Aelf.wallet.getWalletByPrivateKey(); | ||
// There is only one value named address; | ||
aelf.chain.contractAtAsync( | ||
'4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', | ||
wallet, | ||
(error, result) => { | ||
console.log('>>>>>>>>>>>>> contractAtAsync >>>>>>>>>>>>>'); | ||
console.log(error, result); | ||
tokenContract = result; | ||
} | ||
); | ||
|
||
// result = { | ||
// Approve: ƒ (), | ||
// Burn: ƒ (), | ||
// ChargeTransactionFees: ƒ (), | ||
// ClaimTransactionFees: ƒ (), | ||
// .... | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# GET_ADDRESS / getAddress | ||
|
||
```javascript | ||
aelf.getAddress({ | ||
appName: 'test' | ||
}, (error, result) => { | ||
console.log('>>>>>>>>>>>>>>>>>>>', result); | ||
}); | ||
|
||
// result = { | ||
// ..., | ||
// addressList: [ | ||
// { | ||
// address: '...', | ||
// name: '...', | ||
// publicKey: { | ||
// x: '...', | ||
// y: '...' | ||
// } | ||
// } | ||
// ] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# GET_CHAIN_INFORMATION / getChainInformation | ||
|
||
```javascript | ||
const aelf = new window.NightElf.AElf({ | ||
// Enter your test address in this location | ||
httpProvider: [ | ||
'https://127.0.0.1:8000/chain', // host | ||
null, // timeout | ||
null, // user | ||
null, // password | ||
// header | ||
[{ | ||
name: 'Accept', | ||
value: 'text/plain;v=1.0' | ||
}] | ||
], | ||
appName // your Dapp name | ||
}); | ||
|
||
aelf.chain.getChainInformation((error, result) => { | ||
console.log('>>>>>>>>>>>>> connectChain >>>>>>>>>>>>>'); | ||
console.log(error, result); | ||
}); | ||
|
||
// result = { | ||
// ChainId: "AELF" | ||
// GenesisContractAddress: "61W3AF3Voud7cLY2mejzRuZ4WEN8mrDMioA9kZv3H8taKxF" | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# LOGIN / login | ||
|
||
```javascript | ||
aelf.login({ | ||
appName: 'test', | ||
chainId: 'AELF', | ||
payload: { | ||
method: 'LOGIN', | ||
contracts: [{ | ||
chainId: 'AELF', | ||
contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', | ||
contractName: 'token', | ||
description: 'token contract', | ||
github: '' | ||
}, { | ||
chainId: 'AELF TEST', | ||
contractAddress: '2Xg2HKh8vusnFMQsHCXW1q3vys5JxG5ZnjiGwNDLrrpb9Mb', | ||
contractName: 'TEST contractName', | ||
description: 'contract description', | ||
github: '' | ||
}] | ||
} | ||
}, (error, result) => { | ||
console.log('login>>>>>>>>>>>>>>>>>>', result); | ||
}); | ||
|
||
// keychain = { | ||
// keypairs: { | ||
// name: 'your keypairs name', | ||
// address: 'your keypairs address', | ||
// mnemonic: 'your keypairs mnemonic', | ||
// privateKey: 'your keypairs privateKey', | ||
// publicKey: { | ||
// x: 'f79c25eb......', | ||
// y: '7fa959ed......' | ||
// } | ||
// }, | ||
// permissions: [{ | ||
// appName: 'test', | ||
// address: 'your keyparis address', | ||
// contracts: [{ | ||
// chainId: 'AELF', | ||
// contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', | ||
// contractName: 'token', | ||
// description: 'token contract', | ||
// github: '' | ||
// }], | ||
// domain: 'Dapp domain' | ||
// }] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# REMOVE_CONTRACT_PERMISSION / removeContractPermission | ||
|
||
```javascript | ||
aelf.removeContractPermission({ | ||
appName: 'test', | ||
chainId: 'AELF', | ||
payload: { | ||
contractAddress: '2Xg2HKh8vusnFMQsHCXW1q3vys5JxG5ZnjiGwNDLrrpb9Mb' | ||
} | ||
}, (error, result) => { | ||
console.log('removeContractPermission>>>>>>>>>>>>>>>>>>>', result); | ||
}); | ||
|
||
// keychain = { | ||
// keypairs: {...}, | ||
// permissions: [{ | ||
// appName: 'test', | ||
// address: 'your keyparis address', | ||
// contracts: [{ | ||
// chainId: 'AELF', | ||
// contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', | ||
// contractName: 'token', | ||
// description: 'token contract', | ||
// github: '' | ||
// }], | ||
// domain: 'Dapp domain' | ||
// }] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# REMOVE_METHODS_WHITELIST / removeMethodsWhitelist | ||
|
||
```javascript | ||
aelf.removeMethodsWhitelist({ | ||
appName: 'test', | ||
chainId: 'AELF', | ||
payload: { | ||
contractAddress: '2Xg2HKh8vusnFMQsHCXW1q3vys5JxG5ZnjiGwNDLrrpb9Mb', | ||
whitelist: ['Approve'] | ||
} | ||
}, (error, result) => { | ||
console.log('removeWhitelist>>>>>>>>>>>>>>>>>', result); | ||
}); | ||
// keychain = { | ||
// keypairs: {...}, | ||
// permissions: [{ | ||
// appName: 'test', | ||
// address: 'your keyparis address', | ||
// contracts: [{ | ||
// chainId: 'AELF', | ||
// contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', | ||
// contractName: 'token', | ||
// description: 'token contract', | ||
// github: '', | ||
// whitelist: {} | ||
// }], | ||
// domain: 'Dapp domain' | ||
// }] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# SET_CONTRACT_PERMISSION / setContractPermission | ||
|
||
```javascript | ||
aelf.setContractPermission({ | ||
appName: 'test', | ||
hainId: 'AELF', | ||
payload: { | ||
address: '2JqnxvDiMNzbSgme2oxpqUFpUYfMjTpNBGCLP2CsWjpbHdu', | ||
contracts: [{ | ||
chainId: 'AELF', | ||
contractAddress: 'TEST contractAddress', | ||
contractName: 'AAAA', | ||
description: 'contract description', | ||
github: '' | ||
}] | ||
} | ||
}, (error, result) => { | ||
console.log('>>>>>>>>>>>>>', result); | ||
}); | ||
|
||
// keychain = { | ||
// keypairs: {...}, | ||
// permissions: [{ | ||
// appName: 'test', | ||
// address: 'your keyparis address', | ||
// contracts: [{ | ||
// chainId: 'AELF', | ||
// contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', | ||
// contractName: 'token', | ||
// description: 'token contract', | ||
// github: '', | ||
// whitelist: {} | ||
// }, | ||
// { | ||
// chainId: 'AELF', | ||
// contractAddress: 'TEST contractAddress', | ||
// contractName: 'AAAA', | ||
// description: 'contract description', | ||
// github: '' | ||
// }], | ||
// domain: 'Dapp domain' | ||
// }] | ||
// } | ||
``` |
Oops, something went wrong.