Pipeline Class
Pipeline is a custom class to sign transactions with MyAlgo Connect, check balances and send transactions (via AlgoExplorer).
tip
We recommend using this class only for more advanced users who do not wish to use the Algo Components with hard-coded onClick functions.
info
WalletConnect and AlgoSigner are now supported in all Pipeline libraries!
info
Pipeline Class now supports ASA creation / NFT minting and smart contract deployment and interaction!
Use in browser (NEW!)
<button onclick="connect()">TEST</button>
<script src="https://unpkg.com/@pipeline-ui-2/pipeline@1.3.4/dist/index.js"></script>
<script>
const Pipeline = window.pipeline
const wallet = Pipeline.init()
function connect(){
Pipeline.connect(wallet).then(data => {
console.log(data)
})
}
</script>
Note: For faster loading, the codesandbox example below imports the Pipeline class from @pipeline-ui-2/pipeline
. If you have installed pipeline-ui
, the class is bundled with it and can be imported like below:
import { Pipeline } from 'pipeline-ui';
Note: Pipeline.connect
, Pipeline.send
and Pipeline.balance
are 'asyc' functions. They initally return a promise, so to get the returned data, the .then(data => doSomeThingwithData)
notation must be used when calling them (if the returned data is needed.)
info
The following example is experiencing issues in codesandbox due to incompatability with some nodJS functions. If errors are encountered, try forking the linked gihub repo which will work without issues in VSCode or gitpod.
Use Example
warning
The above example will send 1 micro Algo to the Headline Dev Team test account. We recommend changing the value const recipient
(currently on line 5) to your preferred testing addressing before sending a transaction.
Fields/Properties
info
We have add a sizeable number of new smart contract methods to the Pipeline class. Documentation for these new methods will be coming soon! In the meantime, these new methods have all been implemented in the Pipeline-UI react library and documented in the AlgoComponents
tab.
The Pipeline class has several fields or properties that developers can use to change several settings for Pipeline.
Pipeline.main = false; //switch to testNet
Field | Default | Options | Effect |
---|---|---|---|
Pipeline.pipeConnector | string "myAlgoWallet" | "myAlgoWallet" or currently any other string | Switch between MyAlgo and WalletConnect wallets |
Pipeline.main | true | Boolean | Switch between mainNet and testNet |
Methods
Method | Returns | Description |
---|---|---|
Pipeline.init() | new instance of MyAlgo | Must be called once before connect or send methods |
Pipeline.balance() | string (balance + "Algos") | Takes input string address. Pipeline.init not neccesary for use. |
Pipeline.connect() | string (address) | Generates pop-up to sign in. Must be called before Pipeline.send |
Pipeline.send() | string (transaction id) | Can only be called after Pipeline.init and Pipeline.connect. |
Pipeline.createAsa() | string (transaction id) | Should only be called after Pipeline.init and Pipeline.connect. |
Arguments
Pipeline.balance()
Argument | Type | Description |
---|---|---|
address | string | Algorand address |
Pipeline.connect()
Argument | Type | Description |
---|---|---|
wallet | reference | instance of Pipeline.init() that is called once in app |
Pipeline.send()
Argument | Type | Description |
---|---|---|
address | string | recipient's Algorand address |
amt | integer | amount to send in microAlgos |
myNote | string | note |
sendingAddress | string | senders's Algorand address |
wallet | reference | instance of Pipeline.init() that is called once in app |
index | integer | 0 = Algorand, otherwise asset index number |
Pipeline.createAsa()
Argument | Type | Description |
---|---|---|
asaObject | object | object containing parameters for the creation of an asset creation transaction |
asaObject Fields
Key | Type | Default value |
---|---|---|
creator | string | empty string |
note | string | empty string |
amount | integer | 1 |
decimals | integer | 0 |
deafultFrozen | boolean | false |
manager | string | undefined |
clawback | string | undefined |
reserve | string | undefined |
freeze | string | undefined |
assetName | string | empty string |
assetUnit | string | assetName |
assetURL | string | undefined |
assetMetadataHash | string | undefined |