Skip to content

Instantly share code, notes, and snippets.

pragma solidity ^0.5.0;
contract HelloWorld {
string public sentence;
constructor() public {
sentence = "HelloWorld !";
}
const Migrations = artifacts.require("Migrations");
const HelloWorld = artifacts.require("HelloWorld");
module.exports = function(deployer) {
deployer.deploy(Migrations);
deployer.deploy(HelloWorld);
};
@Chanutg
Chanutg / concat
Created April 12, 2019 10:41
Concat
function concat(string memory _base, string memory _value) internal pure returns (string memory) {
bytes memory _baseBytes = bytes(_base);
bytes memory _valueBytes = bytes(_value);
string memory _tmpValue = new string(_baseBytes.length + _valueBytes.length);
bytes memory _newValue = bytes(_tmpValue);
uint i;
uint j;
@Chanutg
Chanutg / HelloWorld.sol
Created April 12, 2019 12:10
HelloWorld
pragma solidity ^0.5.0;
contract HelloWorld {
string public sentence;
string public userName;
constructor() public {
sentence = "HelloWorld !";
userName = "Guillaume";
}
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { Drizzle } from "drizzle";
import HelloWorld from "./contracts/HelloWorld.json";
const options = {
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import HelloWorld from "./HelloWorld";
class App extends Component {
state = { loading: true, drizzleState: null };
componentDidMount() {
const { drizzle } = this.props;
import React from "react";
class HelloWorld extends React.Component {
state = { sentence: null };
componentDidMount() {
const { drizzle, drizzleState } = this.props;
const helloWorld = drizzle.contracts.HelloWorld;
const sentence = helloWorld.methods["saySomething"].cacheCall({ from: drizzleState.accounts[0], gas:3000000});
import React from "react";
import Button from 'react-bootstrap/Button';
class HelloWorld extends React.Component {
state = { sentence: null, newSentence: "", stackId: null };
changeSentence = e => {
this.setState({newSentence: e.target.value});
}
totalSupply() public view returns (uint256 totalSupply)
#Fonction permettant d'obtenir le nombre de tokens existants.
balanceOf(address _owner) public view returns (uint256 balance)
#Fonction retournant le nombre de tokens qu'une adresse possède.
transfer(address _to, uint256 _value) public returns (bool success)
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
#Ces événements permettent d’afficher des informations lors de modifications, transfert de token par exemple.
function balanceOf(address _owner) external view returns (uint256);