### Setting Up Python Virtual Environment Bash
Source: https://github.com/algorand/code-samples/blob/master/algorand-alexa-skill-python/README.md
Provides bash commands to navigate to the project directory, create a Python virtual environment, activate it, and install the required dependencies listed in `requirements.txt` using pip. This prepares the environment for building the Lambda deployment package.
```bash
$ cd {PATH_TO_DIR}/algorand-alexa-skill-python
$ python3 -m venv {ENV_NAME}
$ source {ENV_NAME}/bin/activate
$ pip3 install -r requirements.txt
```
--------------------------------
### Clone and Install Dependencies
Source: https://github.com/algorand/code-samples/blob/master/react-app-acct-txn-msig-assetoptin/README.md
Provides the necessary shell commands to clone the project repository from GitHub, navigate into the project directory, and install all required Node.js dependencies using npm.
```Shell
git clone https://github.com/algorand/code-samples.git
cd react-app-acct-txn-msig-assetoptin
npm i
```
--------------------------------
### Packaging Main Python Files with Starter Zip Bash
Source: https://github.com/algorand/code-samples/blob/master/algorand-alexa-skill-python/README.md
Provides bash commands to navigate to the project root directory and zip all `.py` files into the `lambda-deploy.zip` package, specifically when starting with a pre-built dependency zip file. This adds the main application code to the pre-packaged dependencies.
```bash
$ zip -r9 lambda-deploy.zip *.py
```
--------------------------------
### Start the React Application
Source: https://github.com/algorand/code-samples/blob/master/react-app-acct-txn-msig-assetoptin/README.md
Provides the shell command to start the local development server for the React application, making it accessible in a web browser.
```Shell
npm run start
```
--------------------------------
### Packaging Python Dependencies for Lambda Bash
Source: https://github.com/algorand/code-samples/blob/master/algorand-alexa-skill-python/README.md
Provides bash commands to navigate into the virtual environment's site-packages directory and zip its contents into a deployment package file named `lambda-deploy.zip`. This step includes all installed dependencies required by the Lambda function.
```bash
# Add dependencies
$ cd {ENV_NAME}/lib/python3.{VERSION}/site-packages/
$ zip -r9 {PATH_TO_DIR}/algorand-alexa-skill-python/lambda-deploy.zip .
```
--------------------------------
### Clone and Navigate to Project Directory (Bash)
Source: https://github.com/algorand/code-samples/blob/master/point-of-sale/pos-gui/README.md
Clones the Algorand code samples repository from GitHub and changes the current directory to the point-of-sale GUI project directory.
```bash
git clone https://github.com/algorand/code-samples.git
cd point-of-sale/pos-gui
```
--------------------------------
### Build Point-of-Sale Project with Maven (Bash)
Source: https://github.com/algorand/code-samples/blob/master/point-of-sale/pos-gui/README.md
Builds the point-of-sale GUI application using the Maven build tool, compiling the source code and packaging it into an executable JAR file.
```bash
mvn package
```
--------------------------------
### Cloning Algorand Code Samples Repository - Shell
Source: https://github.com/algorand/code-samples/blob/master/point-of-sale/wallet-gui/README.md
Clones the Algorand code samples repository from GitHub and navigates into the specific point-of-sale wallet-gui directory to prepare for building and running the application.
```Shell
git clone https://github.com/algorand/code-samples.git
cd point-of-sale/wallet-gui
```
--------------------------------
### Run Point-of-Sale Application JAR (Bash)
Source: https://github.com/algorand/code-samples/blob/master/point-of-sale/pos-gui/README.md
Executes the built point-of-sale GUI application using the Java runtime environment by specifying the path to the generated JAR file.
```bash
java -jar target/appservicegui-1.0-SNAPSHOT.jar
```
--------------------------------
### Packaging Main Python Files for Lambda Bash
Source: https://github.com/algorand/code-samples/blob/master/algorand-alexa-skill-python/README.md
Provides bash commands to navigate back to the project root directory and zip all `.py` files into the existing `lambda-deploy.zip` package. This adds the main application code files to the package alongside the dependencies.
```bash
# Add main lambda code and related .py files.
$ cd {PATH_TO_DIR}/algorand-alexa-skill-python
$ zip -r9 lambda-deploy.zip *.py
```
--------------------------------
### Configuring Algorand Client API Key Python
Source: https://github.com/algorand/code-samples/blob/master/algorand-alexa-skill-python/README.md
Shows the structure of the `pick_client` function in `algorand.py` and indicates where to insert your Purestake API token for connecting to the Algorand network. Instructions are also provided for modifying this if using self-hosted nodes instead of Purestake.
```python
def pick_client(network):
"""
Return a client connected to the supplied network.
"""
algod_token = ""
headers = {
"X-API-Key": "" # Add your API token here
}
...
```
--------------------------------
### Building Point-of-Sale Wallet GUI with Maven - Shell
Source: https://github.com/algorand/code-samples/blob/master/point-of-sale/wallet-gui/README.md
Uses Maven to build the point-of-sale wallet GUI application, creating a runnable JAR file in the target directory. Requires Maven and JDK 11.
```Shell
mvn package
```
--------------------------------
### Cloning Algorand Alexa Skill Sample Bash
Source: https://github.com/algorand/code-samples/blob/master/algorand-alexa-skill-python/README.md
Provides bash commands to initialize a git repository, configure sparse checkout to include only the specified directory, and pull the content from the remote repository. This is used to obtain just the necessary files for the Alexa skill sample from a larger repository.
```bash
$ mkdir {PATH_TO_DIR}
$ cd {PATH_TO_DIR}
$ git init
$ git remote add origin -f git@github.com:algorand/code-samples.git
$ git config core.sparseCheckout true
$ echo "/algorand-alexa-skill-python/" > .git/info/sparse-checkout
$ git pull origin master
```
--------------------------------
### Running Point-of-Sale Wallet GUI JAR - Shell
Source: https://github.com/algorand/code-samples/blob/master/point-of-sale/wallet-gui/README.md
Executes the built point-of-sale wallet GUI application using the Java runtime. This command runs the JAR file generated by the Maven package command.
```Shell
java -jar target/appwalletgui-1.0-SNAPSHOT.jar
```
--------------------------------
### React Component for Account Creation
Source: https://github.com/algorand/code-samples/blob/master/react-app-acct-txn-msig-assetoptin/README.md
A React functional component that renders a button. Clicking the button triggers the generation of a new Algorand account using the algosdk library and passes the generated key pair to a parent component via a prop.
```JavaScript
const CreateAccountButton = props => {
// this will create a new account and push it to props createAccount
let generateAccount = () => {
// generating new account
let keys = algosdk.generateAccount();
// calling the props createAccount
props.createAccount(keys);
};
return (
);
};
```
--------------------------------
### Create ASA Opt-in Transaction
Source: https://github.com/algorand/code-samples/blob/master/react-app-acct-txn-msig-assetoptin/README.md
Demonstrates the use of the algosdk.makeAssetTransferTxn function to construct a transaction specifically for an account to opt-in to an Algorand Standard Asset (ASA). The transaction sends zero amount of the asset from the account to itself.
```JavaScript
// create opt-in transaction
let opttxn = algosdk.makeAssetTransferTxn(recoveredAccount.addr, recoveredAccount.addr, undefined, undefined,
params.fee, 0, params.lastRound, endRound, undefined, params.genesishashb64, params.genID, assetID);
```
--------------------------------
### React Component for Account Recovery
Source: https://github.com/algorand/code-samples/blob/master/react-app-acct-txn-msig-assetoptin/README.md
A React functional component that renders a button. When clicked, it uses the algosdk library to convert a provided mnemonic string into an Algorand secret key pair, passing the result to a parent component via a prop.
```JavaScript
const RestoreAccountButton = props => {
// this will create a new account and push it to props createAccount
let restoreAccount = () => {
// generating new account
var keys = algosdk.mnemonicToSecretKey(props.mnemonic);
// calling the props createAccount
props.restoreAccount(keys);
};
return (
);
};
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.