Skip to content

Instantly share code, notes, and snippets.

View ernestognw's full-sized avatar
👨‍💻

Ernesto García ernestognw

👨‍💻
View GitHub Profile
@ernestognw
ernestognw / index.html
Created March 9, 2020 09:40
Stellar react template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Stellar App</title>
</head>
<body>
<main id="app"></main>
@ernestognw
ernestognw / index.js
Created March 9, 2020 09:41
Index of stellar app
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
const target = document.getElementById("app");
ReactDOM.render(<App />, target);
@ernestognw
ernestognw / App.js
Created March 9, 2020 09:42
Stellar App.js
import React from "react";
import { Box } from "@chakra-ui/core";
import { ThemeProvider, CSSReset } from "@chakra-ui/core";
import Wallet from "./components/wallet";
const App = () => {
return (
<ThemeProvider>
<CSSReset />
<Box
@ernestognw
ernestognw / index.js
Created March 9, 2020 09:49
Dummy component
import React from "react";
const Wallet = () => {
return <p>Hola mundo!</p>;
};
export default Wallet;
import StellarSdk from "stellar-sdk";
const server = new StellarSdk.Server("https://horizon-testnet.stellar.org");
const loadAccount = async publicKey => {
// Cargamos la cuenta a través del sdk de Stellar
const account = await server.loadAccount(publicKey);
return account;
};
import StellarSdk from "stellar-sdk";
const server = new StellarSdk.Server("https://horizon-testnet.stellar.org");
const sendTransaction = async (secret, destination, amount) => {
try {
const sourceKeys = StellarSdk.Keypair.fromSecret(secret);
// Revisamos que la cuenta exista para evitar errores
// y cobros innecesarios de comisiones
await server.loadAccount(destination);
// utils/create-pair.js
import StellarSdk from "stellar-sdk";
const pair = StellarSdk.Keypair.random();
const createTestAccount = () => {
// Creamos nuestro par de llaves
const secret = pair.secret();
const publicKey = pair.publicKey();
import React, { useState } from "react";
import CopyKey from "./components/copy-key";
import Start from "./components/start";
import Main from "./components/main";
const Wallet = () => {
// Valores de las llaves
const [secret, setSecret] = useState(localStorage.secret);
const [publicKey, setPublicKey] = useState(localStorage.publicKey);
import React, { useState } from "react";
import StellarSdk from "stellar-sdk";
import {
Heading,
Text,
Button,
InputGroup,
Input,
useToast
} from "@chakra-ui/core";
import React from "react";
import { activeTestAccount } from "../../../../utils/create-pair";
import {
Stack,
Alert,
AlertIcon,
Text,
Box,
Button,
useClipboard,