Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliegibbs/how_to_deploy_contract-basic
smart contract deploy
https://github.com/juliegibbs/how_to_deploy_contract-basic
blockchain deployment smart-contracts
Last synced: about 2 months ago
JSON representation
smart contract deploy
- Host: GitHub
- URL: https://github.com/juliegibbs/how_to_deploy_contract-basic
- Owner: JulieGibbs
- Created: 2024-03-20T17:32:53.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-20T17:33:01.000Z (11 months ago)
- Last Synced: 2024-04-30T17:22:36.651Z (9 months ago)
- Topics: blockchain, deployment, smart-contracts
- Language: JavaScript
- Homepage:
- Size: 299 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to deploy Contract on BSC testnet
## 1.Set up Truffle
```
npm install -g truffle
```
Make an empty repository, cd into it, then
```
truffle init
```
Install HDWalletProvider
```
npm install --save truffle-hdwallet-provider
```
## 2. Create your contract
In ./contracts create a new contract called HelloWorld.sol with the following code:
```
pragma solidity ^0.4.23;
contract HelloWorld {
function sayHello() public pure returns(string){
return(“hello world”);
}
}
```
## 3. Deploy your contract
In ./migrations, create a deployment script specifically named 2_deploy_contracts.js with the following code:
```
var HelloWorld = artifacts.require(“HelloWorld”);
module.exports = function(deployer) {
deployer.deploy(HelloWorld, “hello”);
// Additional contracts can be deployed here
};
```
## 4. Configure BSC testnet network and the provider
```
const HDWalletProvider = require('@truffle/hdwallet-provider');
const path = require("path");
require('dotenv').config()module.exports = {
// See
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "client/src/contracts"),
networks: {
develop: {
port: 8545
},
testnet: {
provider: () => new HDWalletProvider(process.env.MNEMONIC, `https://data-seed-prebsc-1-s1.binance.org:8545`),
network_id: 97,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true
},
bsc: {
provider: () => new HDWalletProvider(process.env.MNEMONIC, `https://bsc-dataseed1.binance.org`),
network_id: 56,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true
},
}
};
```
```
truffle deploy --network ropsten
```
## 5. Access your deployed contract
```
truffle console --network testnet
```
## 6. Finally, invoke contract function and say hello!
```
HelloWorld.deployed().then(function(instance){return instance.sayHello()});Also, Read
```