Error when transfering erc777 tokens to crowdsale contract

Hi! I have a crowdsale contract that would receive the total supply from the erc777 token contract in the migrations script. I am aware that when you transfer from an erc20 contract, the transfer() function is used with the address of the crowdsale contract and the total supply as parameters. I tried to made something similar with the send() function for the erc777:

const ERC777Token = artifacts.require('ERC777Token');
const ERC777Recipient = artifacts.require('ERC777Recipient');
const Crowdsale = artifacts.require('Crowdsale');
const { web3 } = require('@openzeppelin/test-helpers/src/setup');
require('@openzeppelin/test-helpers/configure')({ provider: web3.currentProvider, environment: 'truffle' 
//require('dotenv').config({path: '../.env'});
 const BN = require('bn.js');
const { singletons } = require('@openzeppelin/test-helpers');
const { ZERO_BYTES32 } = require('@openzeppelin/test-helpers/src/constants');

module.exports = async function (deployer, network, accounts) {
if (network === 'development') {
    // In a test environment an ERC777 token requires deploying an ERC1820 registry
    await singletons.ERC1820Registry(accounts[0]);
const defaultOperators = [];
await deployer.deploy(ERC777Token,"TokenName", "TKN", defaultOperators);
const token = await ERC777Token.deployed();
await deployer.deploy(Crowdsale, 20,accounts[0],token.address);
const crowdsale = await Crowdsale.deployed();
await deployer.deploy(ERC777Recipient, token.address);
await token.send(crowdsale.address,await token.totalSupply(),ZERO_BYTES32);//here is the error


I am using ganache-cli for testing, but when I run truffle migrateand the send() method is executed I get the following error:
Error: Returned error: VM Exception while processing transaction: revert at module.exports (C:\Users\raa1\Desktop\ese\migrations\1_initial_migration.js:23:17)

I don’t know if I am passing the right parameters to the send function or if there is any method to transfer the tokens to the crowdsale contract.

This is my code so far:


`pragma solidity ^0.8.0;
 import "@openzeppelin/contracts/token/ERC777/ERC777.sol";
 import "@openzeppelin/contracts/access/Ownable.sol";
  //import "./Crowdsale.sol";
 contract ERC777Token is ERC777,Ownable {
  uint256 private _totalSupply;
 // Crowdsale instance;
constructor(string memory name, string memory symbol, address[] memory defaultOperators_ ) public 
  ERC777("TokenName", "TKN", new address[](0)) {
    _totalSupply = 10000000 * 10**18;
 // instance = Crowdsale(payable(msg.sender));
    _mint(msg.sender, _totalSupply, "", "");



  pragma solidity ^0.8.0;
  import "./ERC777Mintable.sol";
  import "./ERC777Token.sol";
  import "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract Crowdsale {
 using SafeMath for uint256;

  ERC777Token public token;
  address payable public wallet;
   uint256 public rate;
    uint256 public weiRaised;

 event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
constructor(uint256 _rate, address payable _wallet, ERC777Token _token)public {
require(_rate > 0);
require(_wallet != address(0));
require(address(_token) != address(0));

rate = _rate;
wallet = _wallet;
token = ERC777Token(_token);
 receive () external payable {

   function buyTokens(address _beneficiary) public payable {

    uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);

// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);

// update state
weiRaised = weiRaised.add(weiAmount);

_processPurchase(_beneficiary, tokens);
emit TokenPurchase(

_updatePurchasingState(_beneficiary, weiAmount);

_postValidatePurchase(_beneficiary, weiAmount);

 function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
require(_beneficiary != address(0));
require(_weiAmount != 0);
 function _postValidatePurchase(
address _beneficiary,
uint256 _weiAmount
// optional override
 function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
        ERC777Mintable(address(token)).mint(_beneficiary, _beneficiary, _tokenAmount, "", ""),
            "MintedCrowdsale: minting failed"

 function _processPurchase(
address _beneficiary,
uint256 _tokenAmount
_deliverTokens(_beneficiary, _tokenAmount);

 function _updatePurchasingState(
address _beneficiary,
uint256 _weiAmount
// optional override

 function _getTokenAmount(uint256 _weiAmount)
internal view returns (uint256)
return _weiAmount.mul(rate);
 function _forwardFunds() internal {


   `pragma solidity ^0.8.0;
    import "./Crowdsale.sol";

    contract ICO is Crowdsale {
  constructor(uint rate , address payable wallet, ERC777Token token) public Crowdsale(rate, wallet, 


In truffle-config.js I have the following network configuration:

  module.exports = {
    networks: {

 development: {
  host: "",     // Localhost (default: none)
  port: 8545,            // Standard Ethereum port (default: none)
  network_id: "*",       // Any network (default: none)

These are the versions for truffle and node.js:

      Truffle v5.3.6 (core: 5.3.6)
       Node v14.16.1

I would really appreciate the help! My code is inspired from @abcoathup SimpleToken and Crowdsale contract.If there’s sth I missed, please let me know.

Ok, my bad! Apparently I overcomplicated things. The simple transfer method works for erc777 as well. :smiley: